cv.glmmLasso | R Documentation |
Does k-fold cross validation for glmmLasso
cv.glmmLasso(fix, rnd, data, family = stats::gaussian(link = "identity"),
kfold = 5, lambdas = NULL, nlambdas = 100,
lambda.min.ratio = ifelse(nobs < nvars, 0.01, 1e-04), loss,
lambda.final = c("lambda.1se", "lambda.min"), ...)
fix |
A two-sided linear formula object describing the fixed-effects part of the model, with the response on the left of a ~ operator and the terms, separated by + operators, on the right. For categorical covariables use as.factor(.) in the formula. Note, that the corresponding dummies are treated as a group and are updated blockwise |
rnd |
A two-sided linear formula object describing the random-effects part of the model, with the grouping factor on the left of a ~ operator and the random terms, separated by + operators, on the right; aternatively, the random effects design matrix can be given directly (with suitable column names). If set to NULL, no random effects are included. |
data |
The data frame containing the variables named in formula. |
family |
A GLM family, see |
kfold |
Number of folds - default is 10. Although k-folds can be as large as the sample size (leave-one-out CV), it is not recommended for large datasets. Smallest value allowable is nfolds = 3 |
lambdas |
Optional user-supplied lambda sequence; default is NULL, and glmmLasso_MultLambdas chooses its own sequence |
nlambdas |
The number of lambdas values, default value is 100 if lambdas is not user-supplied |
lambda.min.ratio |
Smallest value for lambda, as a fraction of lambda.max, the (data derived) entry value (i.e. the smallest value for which all coefficients are zero). The default depends on the sample size nobs relative to the number of variables nvars. If nobs > nvars, the default is 0.0001, close to zero. If nobs < nvars, the default is 0.01. |
loss |
Loss function used to calculate error, default values is based on family:
|
lambda.final |
Choice for final model to use lambda.1se or lambda.min, default is lambda.1se |
... |
can receive parameters accepted by glmmLasso |
Build multiple models given a sequence of lambda values
A list of cross-validation values including:
The values of lambda used in the fits
The mean cross-validated error - a vector of length length(lambda)
Estimate of standard error of cvm.
Upper curve = cvm+cvsd.
Lower curve = cvm-cvsd.
A fitted glmmLasso object for the full data
Value of lambda that gives minimum cvm
Largest value of lambda such that error is within 1 standard error of the minimum
Pirapong Jitngamplang, Jared Lander
data("soccer", package = "glmmLasso")
soccer[,c(4,5,9:16)]<-scale(soccer[,c(4,5,9:16)],center=TRUE,scale=TRUE)
soccer <- data.frame(soccer)
mod1 <- cv.glmmLasso(fix = points ~ transfer.spendings + ave.unfair.score +
ball.possession + tackles, rnd = list(team=~1), data = soccer,
family = gaussian(link = "identity"), kfold = 5, lambda.final = 'lambda.1se')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.