**10**wrote:

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?

Provide a reproducible example (maybe a very small subset of your data). Otherwise, read, read, read as if there is no tomorrow.

29kWhen using as.matrix() on a data.frame containing characters, you're converting everything to character type, hence the warnings you get about NAs introduced by coercion then you get an error because your matrices are full of NAs. The second warning you're getting is because only deviance is acceptable as argument to type.measure. Also in both glmnet() and cv.glmnet(), the lambda parameter should be a sequence of values for lambda.

21kThank you for the replies

This is what my data looks like

muscleX1

muscleY1

What is deviance? From a brief read, is it a unit I need to transform my data into? Sorry, I'm a bio undergrad, so I know very little about statistics.

This I think I understand. You mean

CV = cv.glmnet(x=muscleX1, y=muscleY1, family= "gaussian", type.measure = "class", alpha = 1,

nlambda = 100) correct? I did find it odd only 100 was provided as lambda, I assumed it would use 100 different lambda values or something. Should it be likethen?

thank you, I'm looking into it!

10You may want to take a look here:

Kevin

55k