Similar to tidymodels/parsnip#483
library(tidymodels)
#> Registered S3 method overwritten by 'tune':
#> method from
#> required_pkgs.model_spec parsnip
library(poissonreg)
n <- 2e3
set.seed(123)
x1 <- MASS::rnegbin(n, mu = 28, theta = 0.6)
x2 <- rnorm(n, 5, 10)
x3 <- as.factor(rnorm(n) < 0)
y <- as.integer(x1 + x2 + as.numeric(x3))
y[y < 0] <- 0
data <- tibble(y, x1, x2, x3)
poisson_reg(penalty = 0.5) %>%
set_engine("glmnet") %>%
fit(y ~ x1 + x2, data = data) %>%
pluck("fit") %>%
class()
#> [1] "fishnet" "glmnet"
# 'fishnet' is their class of Poisson models
poisson_reg(penalty = 0.5) %>%
set_engine("glmnet", family = quasipoisson()) %>%
fit(y ~ x1 + x2, data = data) %>%
pluck("fit") %>%
class()
#> [1] "glmnetfit" "glmnet"
# Now the class is not Poisson specific, so our methods don't know what to do
Created on 2021-05-04 by the reprex package (v1.0.0.9000)
We should add class to the parsnip model or restrict this family for this engine.
Similar to tidymodels/parsnip#483
Created on 2021-05-04 by the reprex package (v1.0.0.9000)
We should add class to the
parsnipmodel or restrict this family for this engine.