I want to test for significant differences of the intercepts in an ordered logit model.
library(MASS)
house.plr <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing)
summary(house.plr)$coefficients
# Value Std. Error t value
# Infl -0.3907221 0.05856668 -6.671406
# Type 0.5654170 0.04921585 11.488515
# Cont 0.0998870 0.09008336 1.108829
# 1|2 -0.6937440 0.20773639 -3.339540
# 2|3 0.7906212 0.20701136 3.819216
# 3|4 2.0574730 0.21396779 9.615807
Hypothesis testing on the coefficients works fine (the associated method is car:::linearHypothesis.polr
).
library(car)
linearHypothesis(house.plr, hypothesis.matrix="Infl + Type + Cont")$`Pr(>Chisq)`[2]
# [1] 0.01679297
However, testing the intercepts doesn't work, even though the intercepts are included in the vcov
.
signif(vcov(house.plr), 3)
# Infl Type Cont 1|2 2|3 3|4
# Infl 0.003430 -0.000269 0.000320 0.00666 0.00623 0.00595
# Type -0.000269 0.002420 -0.000442 0.00365 0.00410 0.00464
# Cont 0.000320 -0.000442 0.008120 0.01240 0.01250 0.01260
# 1|2 0.006660 0.003650 0.012400 0.04320 0.04130 0.04140
# 2|3 0.006230 0.004100 0.012500 0.04130 0.04290 0.04270
# 3|4 0.005950 0.004640 0.012600 0.04140 0.04270 0.04580
Failing attempts:
linearHypothesis(house.plr, "(1|2 - 2|3) + (2|3 - 3|4) = 0")
linearHypothesis(house.plr, "1|2")
Or, since the documentation suggests to add a vcov
:
The default method will work with any model object for which the coefficient vector can be retrieved by coef and the coefficient-covariance matrix by vcov (otherwise the argument vcov. has to be set explicitly).
linearHypothesis(house.plr, "1|2", vcov.=vcov(house.plr))
All yielding:
Error in constants(lhs, cnames_symb) :
The hypothesis "1|2" is not well formed: contains bad coefficient/variable names.
In addition: Warning message:
In constants(lhs, cnames_symb) : NAs introduced by coercion
I noticed that coefficients and intercepts are stored in different objects, but that didn't help me much either.
house.plr$coefficients
# Infl Type Cont
# -0.3907221 0.5654170 0.0998870
house.plr$zeta
# 1|2 2|3 3|4
# -0.6937440 0.7906212 2.0574730
How may I properly define the hypothesis.matrix=
for the in car::linearHypothesis
to test the intercepts?
Or, has anyone already done this from scratch?
The expected result is (from Stata):
( 1) [cut1]_cons - 2*[cut2]_cons + [cut3]_cons = 0
chi2( 1) = 6.53
Prob > chi2 = 0.0106
Data:
data(housing, package="MASS")
housing$Sat <- as.factor(1:4)
housing[2:5] <- lapply(housing[2:5], as.integer)