Hello I have been trying to run a lasso analysis using glmnet with the help of this tutorial:
I have turned both my X and Y tables into matrices and I have no idea why it is still not working.
This is how my code lookslike
library(glmnet) muscleY1 <- as.matrix(muscleY) is.matrix(muscleY1) as.matrix(muscleX) muscleX1 <- as.matrix(muscleX) is.matrix(muscleX1) ## CV = cv.glmnet(x=muscleX1, y=muscleY1, family= "gaussian", type.measure = "class", alpha = 1, nlambda = 100) ## plot(CV) ## fit = (glmnet(x=muscleX.xlsx, y=muscleY.xlsx, family= "poisson", alpha=1, lambda=CV$lambda.1se) ## fit$beta[,1]
I'm getting the following message when I run the 8th line:
Error in fishnet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs, : NA/NaN/Inf in foreign function call (arg 4) In addition: Warning messages: 1: In storage.mode(y) = "double" : NAs introduced by coercion 2: In fishnet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs, : NAs introduced by coercion
I have tried removing the names of my patients from the columns, because I assumed that letters were not allowing it to be interpreted as a matrix, leaving only numbers, and now I'm getting this error instead:
In cv.fishnet(list(list(a0 = c(1.09743483746064, 1.08940083327634, : Only 'deviance', 'mse' or 'mae' available for Poisson models; 'deviance' used
Can anyone tell what's wrong?