2

我正在使用 glht 函数 (multcomp) 来计算回归后系数线性组合的点估计值和标准误差。回归包括一个四向交互项,并非所有组合都有数据点,因此它们的系数缺失。当我使用 glht 函数时,我收到以下错误消息:

modelparm.default(model, ...) 中的错误:

系数和协方差矩阵的维度不匹配

当我对不包括 NA 系数的回归结果(例如没有 4 路交互)做同样的事情时, glht 命令有效,这让我认为 NA 行是问题所在。我已经在 Stata 中做到了这一点并且它有效,但我不确定 Stata 对这些 NA 行做了什么。

回归

reg4 <- lm(choice_n ~ 
         sex+e*c*r*r1+brit_par+occupation+residency, data = newdata, 
na.action=na.omit, weights = Weight)
summary(reg4)

多压缩包

install.packages("multcomp")
library(multcomp)

爱尔兰的线性组合*优秀的英语

summary(glht(reg4, linfct =c("cIreland+eExcellent:cIreland=0")))

这些是回归结果的一部分

Call:
lm(formula = choice_n ~ sex + e * c * r * r1 + brit_par + occupation + 
residency, data = innovation_panel, weights = Weight, na.action = 
na.exclude)

Weighted Residuals:
Min      1Q  Median      3Q     Max 
-2.0214 -0.3679  0.1630  0.2728  1.1978 

Coefficients: (159 not defined because of singularities)
                                      Estimate Std. Error t value
(Intercept)                               1.727242   0.028168  61.318
sexWoman                                 -0.002559   0.006775  -0.378
eGood                                     0.123681   0.036599   3.379
eExcellent                                0.073905   0.035809   2.064
cPoland                                   0.068136   0.040527   1.681
cItaly                                    0.010660   0.038552   0.277
cIndia                                    0.083874   0.040283   2.082
cPakistan                                 0.008349   0.052466   0.159
cNigeria                                 -0.063009   0.051064  -1.234
cIreland                                  0.080269   0.031548   2.544
cAustralia                                0.069785   0.031285   2.231
cSyria                                   -0.025254   0.056821  -0.444
cSomalia                                  0.018274   0.051287   0.356
rMuslim                                  -0.094982   0.064429  -1.474
rNo religion                              0.016348   0.035872   0.456
r1Yes                                    -0.002653   0.066710  -0.040
r1NA                                            NA         NA      NA
brit_parBritish grandparent              -0.034635   0.008292  -4.177
brit_parNeither                          -0.096933   0.008268 -11.724
occupationDoctor                          0.045576   0.014274   3.193
occupationIT professional                 0.020612   0.014246   1.447
occupationLanguage teacher               -0.008675   0.014467  -0.600
occupationAdmin worker                   -0.049867   0.014283  -3.491
occupationFarmer                         -0.066845   0.014500  -4.610
occupationCleaner                        -0.093354   0.014352  -6.505
occupationUnemployed                     -0.359872   0.014304 -25.159
occupationStay at home parent            -0.170595   0.014394 -11.851
residency6 years                          0.023541   0.009569   2.460
residency10 years                         0.085133   0.009553   8.912
residency20 years                         0.115200   0.009600  12.000
eGood:cPoland                            -0.104022   0.060583  -1.717
eExcellent:cPoland                       -0.074505   0.058459  -1.274
eGood:cItaly                             -0.021625   0.056038  -0.386
eExcellent:cItaly                         0.014001   0.056616   0.247
eGood:cIndia                             -0.085940   0.057982  -1.482
eExcellent:cIndia                        -0.022007   0.058273  -0.378
eGood:cPakistan                          -0.063008   0.074928  -0.841
eExcellent:cPakistan                      0.024541   0.073136   0.336
eGood:cNigeria                           -0.016136   0.069657  -0.232
eExcellent:cNigeria                       0.071779   0.070881   1.013
eGood:cIreland                                  NA         NA      NA
eExcellent:cIreland                             NA         NA      NA
eGood:cAustralia                                NA         NA      NA
eExcellent:cAustralia                           NA         NA      NA
4

0 回答 0