Error in storage.mode(xd) in `glmsmurf()`

Viewed 81

Consider the following R code (which should be a standard exercise):

library(dplyr)
library(smurf)
library(glmnet)
library(grpreg)


data("rent", package = "catdata")

rent$quality <- as.factor(rent$good + 2 * rent$best)
levels(rent$quality) <- c("fair", "good", "excellent")

formu <- rent ~ p(size, pen="lasso") + 
                p(rooms, pen="lasso") + 
                p(year, pen="lasso") + 
                p(quality, pen="lasso")

munich.fit.cv <- glmsmurf(formula = formu, 
                          family = gaussian(), 
                          data = rent, 
                          pen.weights = "glm.stand", 
                          lambda = "cv.mse")

What I get upon execution of the last statement is

Error in storage.mode(xd) <- "double" : 
  no method for coercing this S4 class to a vector

What's the issue? This code is basically copied from a source which claimed it to be working...

1 Answers

I had the same problem and installing an older version of glmnet fixed it.

Try this:

packageurl <- "http://cran.r-project.org/src/contrib/Archive/glmnet/glmnet_4.0-2.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
Related