Description Usage Arguments Value Examples
Does nfolds cross-validation for compCL, return value of lam
.
The function is modified based on the cv
function from glmnet
package
1 2 |
y |
a vector of response variable with length n. |
Z |
a n*p matrix after taking log transformation on compositional data. |
Zc |
a design matrix of other covariates considered. Default is |
intercept |
Whether to include intercept in the model. Default is TRUE. |
lam |
a user supplied lambda sequence. Typically, by leaving this option unspecified users can have the
program compute its own |
nfolds |
number of folds - default is 10. Smallest value allowable is nfolds=3. |
foldid |
an optional vector of values between 1 and |
trim |
a scaler specifying percentage to be trimmed off for prediction error - default is 0. |
... |
other arguments that can be passed to compCL. |
an object of class cv.compCL
is returned.
compCL.fit |
a fitted |
lam |
the values of |
Ftrim |
a list of cross-validation result without trimming.
|
Ttrim |
a list of cross-validation result with
|
foldid |
the values of |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | p = 30
n = 50
beta = c(1, -0.8, 0.6, 0, 0, -1.5, -0.5, 1.2)
beta = c( beta, rep(0, times = p - length(beta)) )
Comp_data = comp_simulation(n = n, p = p,
rho = 0.2, sigma = 0.5,
gamma = 0.5, add.on = 1:5,
beta = beta, intercept = FALSE)
Comp_data$Zc
cvm <- cv.compCL(y = Comp_data$y,
Z = Comp_data$X.comp, Zc = Comp_data$Zc,
intercept = Comp_data$intercept,
lam = NULL, nfolds = 10, trim = 0.05, lambda.factor = 0.0001,
dfmax = p, mu_ratio = 1, outer_eps = 1e-10, inner_eps = 1e-8, inner_maxiter = 1e4)
plot(cvm)
coef(cvm, s = "lam.min")
cvm$compCL.fit
#apply(cvm$compCL.fit$beta[1:p, ], 2, function(x) which(abs(x) > 0))
which(abs(coef(cvm, s = "lam.min")$beta[1:p]) > 0)
which(abs(coef(cvm, s= "lam.1se")$beta[1:p]) > 0)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.