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

Error plotting interactions in fixed effects models (plm) #594

Closed
bkinne opened this issue Feb 11, 2020 · 4 comments
Closed

Error plotting interactions in fixed effects models (plm) #594

bkinne opened this issue Feb 11, 2020 · 4 comments

Comments

@bkinne
Copy link

bkinne commented Feb 11, 2020

Hello,

I'm encountering an error when trying to plot interactions from plm fit objects, specifically for models with fixed effects included. Here's an MWE with twoway fixed effects:

library(plm)
library(sjPlot)
data("Produc", package="plm")
fit  <- plm(pcap ~ hwy + water + hwy*water, data=Produc, effect="twoway", index=c("state", "year"), model="within")
plot_model(fit, type="pred", terms=c("hwy", "water"))
#> Error in crossprod(beta, t(X)) : non-conformable arguments

I get the same error if I use only individual-level fixed effects. The error disappears and the effect plots correctly if I switch to a pooled model in the plm specification (model="pooling"), but that of course defeats the purpose of estimating a panel model.

I'm using the most recent versions of both packages.

Brandon

@strengejacke
Copy link
Owner

This looks like an issue in plm, not sjPlot.

@benckrick
Copy link

Bump. I have same exact question. Have not been able to resolve

@tappek
Copy link

tappek commented Apr 17, 2022

There is now support for predict for plm's within models in the development version available here: https://github.com/ycroissant/plm

As the within case is special, one likely wants to input a pdata.frame and not a plain data frame; the help page ?predict.plm has the details.

@tappek
Copy link

tappek commented Aug 19, 2022

For models produced by plm::plm(), there is a predict method available since plm version 2.6-2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants