简体   繁体   English

交互项中变量的绘图效果

[英]Plot Effects of Variables in Interaction Terms

I would like to plot the effects of variables in interaction terms, using panel data and a FE model. 我想使用面板数据和有限元模型以交互条件绘制变量的影响。

I have various interaction effects in my equation, for example this one here: 我的方程式中有多种交互作用,例如这里的一个:

FIXED1 <- plm(GDPPCgrowth ~ FDI * PRIVCR, data = dfp)

I can only find solutions for lm, but not for plm. 我只能找到lm的解决方案,而找不到plm的解决方案。

So on the x-axis there should be PRIVCR and on the y-axis the effect of FDI on growth. 因此,在x轴上应该有PRIVCR,在y轴上应该有FDI对增长的影响。

Thank you for your help! 谢谢您的帮助!

Lisa 丽莎

I am not aware of a package that supports plm objects directly. 我不知道直接支持plm对象的软件包。 As you are asking for FE models, you can just take an LSDV approach for FE and do the estimation by lm to get an lm object which works with the effects package. 当您需要有限元模型时,您可以对有限元采用LSDV方法,并通过lm进行估算,以获得与effects包一起工作的lm对象。 Here is an example for the Grunfeld data: 这是Grunfeld数据的示例:

library(plm)
library(effects)
data("Grunfeld", package = "plm")

mod_fe <- plm(inv ~ value + capital + value:capital, data = Grunfeld, model = "within")
Grunfeld[ , "firm"] <- factor(Grunfeld[ , "firm"]) # needs to be factor in the data NOT in the formula [required by package effects]
mod_lsdv <- lm(inv ~ value + capital + value:capital + firm, data = Grunfeld)
coefficients(mod_fe)    # estimates are the same
coefficients(mod_lsdv)  # estimates are the same

eff_obj <- effects::Effect(c("value", "capital"), mod_lsdv)
plot(eff_obj)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM