Reputation: 7089
I'm very new to R and was playing with the glmnet package. When I try a toy example following the Stanford vignette, I get an error that says:
Error in print(fit) : object 'fit' not found
I've tried two slightly different toy models to the same result, and was wondering if anyone know if I was missing something obvious?
Try 1:
library(glmnet)
data("AirPassengers")
fit = glmnet(x, y)
plot(fit)
Try 2:
library(glmnet)
fit = glmnet(as.matrix(mtcars[-1]), mtcars[,1])
plot(fit, xvar='lambda')
One thing that I've noticed is that the x, y are not explicitly defined in the first case and in the second case, the data is not explicitly loaded. From what I could gather from the vignette, this shouldn't be a problem but if it is, then any suggestions as to what modifications should be made will be immensely helpful!
Upvotes: 0
Views: 2454
Reputation: 151
It looks like you are following this vignette: https://web.stanford.edu/~hastie/glmnet/glmnet_alpha.html
In that tutorial, x and y are loaded with:
load("QuickStartExample.RData")
However, in your Try 1
, you have not defined x and y.
Try 2
works for me.
Upvotes: 1