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
|
||||
|
||||
"""
|
||||
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.
|
||||
Outputs: b, press, lambda_min, lambda_min_ind, GCV
|
||||
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);
|
||||
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.
|
||||
Inputs:
|
||||
- X : Data matrix
|
||||
- y : Response vector
|
||||
- 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
|
||||
|
||||
Outputs: rmsecv, b, lambda_min, lambda_min_ind.
|
||||
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);
|
||||
n_seg = maximum(folds);
|
||||
n_seg = maximum(cv);
|
||||
n_lambdas = length(lambdas);
|
||||
my = mean(y);
|
||||
y = y .- my;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue