Fixed many small mistakes
This commit is contained in:
parent
e0d9a447df
commit
2b47088921
1 changed files with 6 additions and 6 deletions
12
src/TR.jl
12
src/TR.jl
|
|
@ -137,13 +137,13 @@ return U
|
||||||
end
|
end
|
||||||
|
|
||||||
"""
|
"""
|
||||||
function TRVirCV(X, y, lambdas, regType="L2", regParam1=0, regParam2=1e-14)
|
function TRVirCV(X, y, segments, lambdas, regType="L2", regParam1=0, regParam2=1e-14)
|
||||||
|
|
||||||
Segmented virtual cross-validation (VirCV) for TR models.
|
Segmented virtual cross-validation (VirCV) for TR models.
|
||||||
Outputs: b, press, lambda_min, lambda_min_ind, GCV
|
Outputs: b, press, lambda_min, lambda_min_ind, GCV
|
||||||
b are (virtual) press-minimal regression coefficients.
|
b are (virtual) press-minimal regression coefficients.
|
||||||
"""
|
"""
|
||||||
function TRVirCV(X, y, lambdas, regType="L2", regParam1=0, regParam2=1e-14)
|
function TRVirCV(X, y, segments, lambdas, regType="L2", regParam1=0, regParam2=1e-14)
|
||||||
|
|
||||||
U_segments = TRSegmentOrth(X, segments);
|
U_segments = TRSegmentOrth(X, segments);
|
||||||
bs = vec(sum(U_segments, dims=1).^2);
|
bs = vec(sum(U_segments, dims=1).^2);
|
||||||
|
|
@ -181,23 +181,23 @@ end
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
function TRSegCV(X, y, lambdas, folds, regType="L2", regParam1=0, regParam2=1e-14)
|
function TRSegCV(X, y, lambdas, cv, regType="L2", regParam1=0, regParam2=1e-14)
|
||||||
|
|
||||||
Segmented cross-validation based on the Sherman-Morrison-Woodbury updating formula.
|
Segmented cross-validation based on the Sherman-Morrison-Woodbury updating formula.
|
||||||
Inputs:
|
Inputs:
|
||||||
- X : Data matrix
|
- X : Data matrix
|
||||||
- y : Response vector
|
- y : Response vector
|
||||||
- lambdas : Vector of regularization parameter values
|
- lambdas : Vector of regularization parameter values
|
||||||
- folds : Vector of length n indicating segment membership for each sample
|
- cv : Vector of length n indicating segment membership for each sample
|
||||||
- regType, regParam1, regParam2 : Inputs to regularizationMatrix function
|
- regType, regParam1, regParam2 : Inputs to regularizationMatrix function
|
||||||
|
|
||||||
Outputs: rmsecv, b, lambda_min, lambda_min_ind.
|
Outputs: rmsecv, b, lambda_min, lambda_min_ind.
|
||||||
b are regression coefficients corresponding to the lambda value minimising the CV-error.
|
b are regression coefficients corresponding to the lambda value minimising the CV-error.
|
||||||
"""
|
"""
|
||||||
function TRSegCV(X, y, lambdas, folds, regType="L2", regParam1=0, regParam2=1e-14)
|
function TRSegCV(X, y, lambdas, cv, regType="L2", regParam1=0, regParam2=1e-14)
|
||||||
|
|
||||||
TR = TRSVDDecomp(X, regType, regParam1, regParam2);
|
TR = TRSVDDecomp(X, regType, regParam1, regParam2);
|
||||||
n_seg = maximum(folds);
|
n_seg = maximum(cv);
|
||||||
n_lambdas = length(lambdas);
|
n_lambdas = length(lambdas);
|
||||||
my = mean(y);
|
my = mean(y);
|
||||||
y = y .- my;
|
y = y .- my;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue