2

I'm using the glht function (multcomp) to compute point estimates and standard errors of the linear combination of coefficients after a regression. The regression includes a four-way interaction term for which not all combinations have data points, so the coefficients are missing for them. When I use the glht function I get the following error message:

Error in modelparm.default(model, ...) :

dimensions of coefficients and covariance matrix don't match

When I do the same thing with regression results that don't include NA coefficients (so for instance with no 4-way interaction), the glht command works, which makes me think that the NA rows are the problem. I've done this in Stata and it works, but I'm not sure what Stata does with those NA rows.

regression

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

multcomp package

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

linear combination of Ireland*Excellent English

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

These are part of the results of the regression

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

0 Answers0