Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`data` argument breaks with `glm` but works with `lm` #32

Closed
vincentarelbundock opened this issue Mar 10, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@vincentarelbundock
Copy link
Contributor

commented Mar 10, 2019

  • a possible bug
  • a question about package functionality
  • a suggested code or documentation change, improvement to the code, or feature request

Bugfix proposed here: #33

I was trying to track down a problem in my margins ggplot branch, and came upon this behavior I did not expect. Passing a data to prediction works with lm objects but not glm ones.

library(prediction)
data(mtcars)

# `data` with lm works
mod <- lm(am ~ hp + drat, data = mtcars)
prediction(mod, data = data.frame(hp = 110, drat = 3.9))
#> Data frame with 1 predictions from
#>  lm(formula = am ~ hp + drat, data = mtcars)
#> with average prediction: 0.5947

# `data` with glm doesn't work
mod <- glm(am ~ hp + drat, data = mtcars)
prediction(mod, data = data.frame(hp = 110, drat = 3.9))
#> Warning in model$family$mu.eta(predictions_link) * model_mat: longer object
#> length is not a multiple of shorter object length
#> Error in is.data.frame(x): dims [product 3] do not match the length of object [32]

Created on 2019-03-10 by the reprex package (v0.2.1)

@vincentarelbundock

This comment has been minimized.

Copy link
Contributor Author

commented Mar 10, 2019

This issue is fixed in #33

@leeper leeper closed this Jun 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.