cv.gamlr | R Documentation |
Cross validation for gamma lasso penalty selection.
cv.gamlr(x, y, nfold=5, foldid=NULL, verb=FALSE, cl=NULL, ...)
## S3 method for class 'cv.gamlr'
plot(x, select=TRUE, df=TRUE, ...)
## S3 method for class 'cv.gamlr'
coef(object, select=c("1se","min"), ...)
## S3 method for class 'cv.gamlr'
predict(object, newdata, select=c("1se","min"), ...)
x |
Covariates; see |
y |
Response; see |
nfold |
The number of cross validation folds. |
foldid |
An optional length-n vector of fold memberships for each observation. If specified, this dictates |
verb |
Whether to print progress through folds. |
cl |
possible |
... |
Arguments to |
object |
A gamlr object. |
newdata |
New |
select |
In prediction and coefficient extraction,
select which "best" model to return:
|
df |
Whether to add to the plot degrees of freedom along the top axis. |
Fits a gamlr
regression to the full dataset, and then performs nfold
cross validation to evaluate out-of-sample (OOS)
performance for different penalty weights.
plot.cv.gamlr
can be used to plot the results: it
shows mean OOS deviance with 1se error bars.
gamlr |
The full-data fitted |
nfold |
The number of CV folds. |
foldid |
The length-n vector of fold memberships. |
cvm |
Mean OOS deviance by |
cvs |
The standard errors on |
seg.min |
The index of minimum |
seg.1se |
The index of |
lambda.min |
Penalty at minimum |
lambda.1se |
Penalty at |
Matt Taddy mataddy@gmail.com
Taddy (2017 JCGS), One-Step Estimator Paths for Concave Regularization, http://arxiv.org/abs/1308.5623
gamlr, hockey
n <- 100
p <- 100
xvar <- matrix(ncol=p,nrow=p)
for(i in 1:p) for(j in i:p) xvar[i,j] <- 0.5^{abs(i-j)}
x <- matrix(rnorm(p*n), nrow=n)%*%chol(xvar)
beta <- matrix( (-1)^(1:p)*exp(-(1:p)/10) )
mu = x%*%beta
y <- mu + rnorm(n,sd=sd(as.vector(mu))/2)
## fit with gamma=1 concavity
cvfit <- cv.gamlr(x, y, gamma=1, verb=TRUE)
coef(cvfit)[1:3,] # 1se default
coef(cvfit, select="min")[1:3,] # min OOS deviance
predict(cvfit, x[1:2,], select="min")
predict(cvfit$gamlr, x[1:2,], select=cvfit$seg.min)
par(mfrow=c(1,2))
plot(cvfit)
plot(cvfit$gamlr)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.