![](/img/trans.png)
[英]Linear Model: Calculate all possible combinations of variables with interaction: interaction terms must be in main effects
[英]Plot Effects of Variables in Interaction Terms
我想使用面板數據和有限元模型以交互條件繪制變量的影響。
我的方程式中有多種交互作用,例如這里的一個:
FIXED1 <- plm(GDPPCgrowth ~ FDI * PRIVCR, data = dfp)
我只能找到lm的解決方案,而找不到plm的解決方案。
因此,在x軸上應該有PRIVCR,在y軸上應該有FDI對增長的影響。
謝謝您的幫助!
麗莎
我不知道直接支持plm
對象的軟件包。 當您需要有限元模型時,您可以對有限元采用LSDV方法,並通過lm
進行估算,以獲得與effects
包一起工作的lm對象。 這是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.