Error using cv.glmnet in R for polynomial

When I try to use cv.glmnet to cv.glmnet my data, I got an error

 Error in apply(nz, 1, median) : dim(X) must have a positive length 

In the line below, y is a level 3 variable (I used as.factor() for the original variable). The predictor x consists of one continuous variable (magician) and some factor variables (again, as.factor() for categorical variables). As suggested by another post on the Internet, my code for collecting all the predictors was as follows:

 xfactors <- model.matrix(ANYHEART ~ mrace+frace+sex+smoke+alcohol+bmi+dbt+ben+tol+ xyl+car+chl+met+per+tca+tce+sto+chlor+arom)[,-1] x <- as.matrix(data.frame(mage, xfactors)) y <- as.factor(ANYHEART) fit = glmnet(x, y, family="multinomial", type.multinomial="grouped") 

Following cross validation using:

 cvfit <- cv.glmnet(x, y, family="multinomial", type.multinomial="grouped") 

I was wondering if anyone had encountered this problem before and what could be the possible reasons.

+7
r glmnet
source share

No one has answered this question yet.

See related questions:

6
R error - cv.glmnet: matrices must have the same number of columns
3
Is there a function or step method for cv.glmnet?
3
Error using cv.glmnet
2
Is there a summary for the cv.glmnet function in R?
2
Extract polynomial coefficients cv.glmnet
one
Incorrect size error when using the cv.glmnet function in R
one
glmnet doesn't converge for lambda.min from cv.glmnet
one
Statistical Learning - LASSO Prediction Classification Model
0
Error in cv.glmnet for poissons with offset
0
Understanding glmnet and cv.glmnet for a multidimensional model

All Articles