Closed joranE closed 1 year ago
You are correct. The reason for this is that the glmnet package itself won't accept a predictor matrix with less than 2 columns:
library(glmnet)
#> Loading required package: Matrix
#> Loaded glmnet 4.1-4
data("seniors", package = "poissonreg")
alcohol_num <- ifelse(seniors$alcohol == "yes", 1, 0)
glmnet(y = seniors$count, x = matrix(alcohol_num, ncol = 1))
#> Error in glmnet(y = seniors$count, x = matrix(alcohol_num, ncol = 1)): x should be a matrix with 2 or more columns
Created on 2022-12-19 with reprex v2.0.2
Yeah, I guess that makes sense now that I think about it. No regularization path with only one variable. I guess I naively assumed that in a degenerate case like that glmnet would simply revert to an unregularized model or something, but I'm sure there are math-y reasons why that doesn't make sense.
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
Any
poisson_reg()
model fails with theglmnet
engine if there is only one covariate.versus
Session info: