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

get_predicted() for new models #614

Open
1 of 3 tasks
strengejacke opened this issue Aug 16, 2022 · 3 comments
Open
1 of 3 tasks

get_predicted() for new models #614

strengejacke opened this issue Aug 16, 2022 · 3 comments
Labels
Enhancement 💥 Implemented features can be improved or revised get_predicted Function specific issues

Comments

@strengejacke
Copy link
Member

strengejacke commented Aug 16, 2022

@strengejacke strengejacke added Enhancement 💥 Implemented features can be improved or revised get_predicted Function specific issues labels Aug 16, 2022
@strengejacke
Copy link
Member Author

problem for plm: get_modelmatrix() (resp. the underlying model.matrix() and model.frame() from the plm package) don't return model matrix for a pre-defined data frame:

library(plm)
data("Produc", package = "plm")

m <- plm(pcap ~ hwy + water + hwy * water, data = Produc, effect = "twoway", index = c("state", "year"), model = "within")
d <- insight::get_datagrid(m, c("hwy", "water"), range = "grid", include_response = TRUE)
insight::get_modelmatrix(m, data = d) |> dim()
#> [1] 816   3

m <- lm(pcap ~ hwy + water + hwy * water, data = Produc)
d <- insight::get_datagrid(m, c("hwy", "water"), range = "grid", include_response = TRUE)
model.matrix(m, data = d) |> dim()
#> [1] 30  4 # this is what we also want for plm

Created on 2022-09-11 with reprex v2.0.2

@strengejacke
Copy link
Member Author

@vincentarelbundock if you have any ideas, let me know - you seem to work more frequently with panel-regression-models.

@vincentarelbundock
Copy link
Contributor

vincentarelbundock commented Sep 11, 2022

Are you just hoping to make get_modelmatrix() work, or is the intention to use it in ˋget_predicted`? I'm overworked and won't be able to look into this seriously for a few weeks.

My initial reaction is that we should be super careful here, because plm models use a lot of complex de-meaning strategies, and it's not clear to me whether stock methods will return the design matrices we actually need to compute standard errors around fitted values. Until someone really investigated the issue, it would be safer to rely on the default predict methods, which work well since the last CRAN release of ˋplm`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement 💥 Implemented features can be improved or revised get_predicted Function specific issues
Projects
None yet
Development

No branches or pull requests

2 participants