# GLMNET LASSO - interpretation problem

We have a sample artificial dataset. The response variable y is binomial categorical:

nvar <- 10
nobs <- 100

set.seed(1024)
x <- matrix(rnorm(nobs * nvar), nobs, nvar)

set.seed(1024)
y <- sample(1:2,nobs, replace=TRUE)
y[which((y == 1) == TRUE)] <- "class.A"
y[which((y == 2) == TRUE)] <- "class.B"
(y <- as.factor(y))


Now, we do GLMNET and plot the results:

fit <- glmnet(x, y, alpha=1, family="binomial")
plot(fit, xvar="lambda", label=T)


If I interpret the figure well, every line represents one variable. Because nvar <- 10, we have 10 lines.

Now we change the response variable y which is now multinomial categorical (3 different levels):

set.seed(1000)
(y <- sample(1:3,nobs, replace=TRUE))
y[which((y == 1) == TRUE)] <- "class.A"
y[which((y == 2) == TRUE)] <- "class.B"
y[which((y == 3) == TRUE)] <- "class.C"
(y <- as.factor(y))


Now, similarly as above, we do GLMNET and plot the results:

fit <- glmnet(x, y, alpha=1, family="multinomial")
plot(fit, xvar="lambda", label=T)


QUESTIONS:

Note also that now the vertical label is Coefficients: Response Class.C. How to interpret it? Does this mean that only Class.C is taken into account? What about Class.A and Class.B?

Why on the second plot only 7 (in general, less than nvar <- 10) is visible? Does this mean that invisible variables are treated as irrelevant at all?

• from ?glmnet::plot.glmnet, the description says: "A coefficient profile plot is produced. If x is a multinomial model, a coefficient plot is produced for each class." As for the coefficient values, you can see them by coefficients(fit) and see how many are exactly zeros and so on for every $\lambda$ value – Nutle Apr 8 at 13:11