r - 从 plm 固定效应模型中提取方差-协方差矩阵

标签 r plm

我想从简单的 plm 固定效应模型中提取方差-协方差矩阵。例如:

library(plm)
data("Grunfeld")

M1 <- plm(inv ~ lag(inv) + value + capital, index = 'firm',
          data = Grunfeld)

通常的 vcov 函数给我:

vcov(M1)

              lag(inv)         value       capital
lag(inv)  3.561238e-03 -7.461897e-05 -1.064497e-03
value    -7.461897e-05  9.005814e-05 -1.806683e-05
capital  -1.064497e-03 -1.806683e-05  4.957097e-04

plmfixef 函数仅提供:

fixef(M1)
          1           2           3           4           5           6           7 
-286.876375  -97.190009 -209.999074  -53.808241  -59.348086  -34.136422  -34.397967 
      8           9          10 
-65.116699  -54.384488   -6.836448 

如果能帮助提取包含固定效应的方差-协方差矩阵,我们将不胜感激。

最佳答案

使用名称有时非常有用:

 names(M1)
[1] "coefficients" "vcov"         "residuals"    "df.residual" 
[5] "formula"      "model"        "args"         "call"        
 M1$vcov
              lag(inv)         value       capital
lag(inv)  1.265321e-03  3.484274e-05 -3.395901e-04
value     3.484274e-05  1.336768e-04 -7.463365e-05
capital  -3.395901e-04 -7.463365e-05  3.662395e-04

关于r - 从 plm 固定效应模型中提取方差-协方差矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31482442/

相关文章:

r - R中具有二元因变量的面板数据

r - R 中的 plm 包 - 空模型,仅包含每个个体不随时间变化的变量

r - 如何使用lfe包计算动态面板模型

r - data.table 中 dcast 的替代方案?

string - as.numeric 带有逗号小数分隔符?

r - Shiny 的/ Shiny 的仪表板 : Dynamic Number of Output Elements/valueBoxes

r - 在 R 中的数据框的每一行中保留唯一分数

R Shiny : Reuse lengthy computation for different output controls

linux - docdokuplm 安装后说明

r - 在 plm 数据框中创建滞后、超前和差异变量