Variabler må kanskje defineres før de brukes...
This commit is contained in:
parent
38ca6f1aa7
commit
c144572d68
1 changed files with 3 additions and 2 deletions
|
|
@ -6,6 +6,7 @@ Fast k-fold cv for updating regression coefficients
|
||||||
"""
|
"""
|
||||||
function TRSegCVUpdate(X, y, lambdas, cv, bOld, regType="L2", derOrder=0)
|
function TRSegCVUpdate(X, y, lambdas, cv, bOld, regType="L2", derOrder=0)
|
||||||
|
|
||||||
|
n, p = size(X);
|
||||||
|
|
||||||
# Finding appropriate regularisation matrix
|
# Finding appropriate regularisation matrix
|
||||||
if regType == "bc"
|
if regType == "bc"
|
||||||
|
|
@ -35,7 +36,6 @@ elseif regType == "GL" # GL fractional derivative regulariztion
|
||||||
end
|
end
|
||||||
|
|
||||||
# Preliminary calculations
|
# Preliminary calculations
|
||||||
n, p = size(X);
|
|
||||||
mX = mean(X, dims=1);
|
mX = mean(X, dims=1);
|
||||||
X = X .- mX;
|
X = X .- mX;
|
||||||
my = mean(y);
|
my = mean(y);
|
||||||
|
|
@ -93,6 +93,8 @@ and so most regularization types are probably not meaningful.
|
||||||
"""
|
"""
|
||||||
function TRLooCVUpdate(X, y, lambdas, bOld, regType="L2", derOrder=0)
|
function TRLooCVUpdate(X, y, lambdas, bOld, regType="L2", derOrder=0)
|
||||||
|
|
||||||
|
n, p = size(X);
|
||||||
|
|
||||||
# Finding appropriate regularisation matrix
|
# Finding appropriate regularisation matrix
|
||||||
if regType == "bc"
|
if regType == "bc"
|
||||||
regMat = [I(p); zeros(derOrder,p)];
|
regMat = [I(p); zeros(derOrder,p)];
|
||||||
|
|
@ -120,7 +122,6 @@ end
|
||||||
|
|
||||||
|
|
||||||
# Preliminary calculations
|
# Preliminary calculations
|
||||||
n, p = size(X);
|
|
||||||
mX = mean(X, dims=1);
|
mX = mean(X, dims=1);
|
||||||
X = X .- mX;
|
X = X .- mX;
|
||||||
my = mean(y);
|
my = mean(y);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue