Description Usage Arguments Details Value See Also Examples
Does k
-fold cross-validation for pcLasso
.
1 2 3 |
x |
|
y |
|
w |
Observation weights. Default is 1 for each observation. |
ratio |
Ratio of shrinkage between the second and first principal components
in the absence of the \ell_1 penalty. More convenient way to specify the
strength of the quadratic penalty. A value between 0 and 1 (only 1 included).
|
theta |
Multiplier for the quadratic penalty: a non-negative real number.
|
groups |
A list describing which features belong in each group. The
length of the list should be equal to the number of groups, with
|
family |
Response type. Either |
nfolds |
Number of folds for CV (default is 10). Although |
foldid |
An optional vector of values between 1 and |
keep |
If |
verbose |
Print out progess along the way? Default is |
... |
Other arguments that can be passed to |
This function runs pcLasso nfolds+1
times: the first to get the
lambda
sequence, and the remaining nfolds
times to compute the
fit with each of the folds omitted. The error is accumulated, and the mean
error and standard deviation over the folds is compued. Note that
cv.pcLasso
does NOT search for values of theta
or ratio
.
A specific value of theta
or ratio
should be supplied.
An object of class "cv.pcLasso"
, which is a list with the
ingredients of the cross-validation fit.
glmfit |
A fitted |
theta |
Value of |
lambda |
The values of |
nzero |
If the groups overlap, the number of non-zero coefficients
in the model |
orignzero |
If the groups are overlapping, this is the number of
non-zero coefficients in the model |
fit.preval |
If |
cvm |
The mean cross-validated error: a vector of length
|
cvse |
Estimate of standard error of |
cvlo |
Lower curve = |
cvup |
Upper curve = |
lambda.min |
The value of |
lambda.1se |
The largest value of |
foldid |
If |
name |
Name of error measurement used for CV. |
call |
The call that produced this object. |
pcLasso
and plot.cv.pcLasso
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | set.seed(1)
x <- matrix(rnorm(100 * 20), 100, 20)
y <- rnorm(100)
groups <- vector("list", 4)
for (k in 1:4) {
groups[[k]] <- 5 * (k-1) + 1:5
}
cvfit1 <- cv.pcLasso(x, y, groups = groups, ratio = 0.8)
# change no. of CV folds
cvfit2 <- cv.pcLasso(x, y, groups = groups, ratio = 0.8, nfolds = 5)
# specify which observations are in each fold
foldid <- sample(rep(seq(5), length = length(y)))
cvfit3 <- cv.pcLasso(x, y, groups = groups, ratio = 0.8, foldid = foldid)
# keep=TRUE to have pre-validated fits and foldid returned
cvfit4 <- cv.pcLasso(x, y, groups = groups, ratio = 0.8, keep = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.