我正在尝试使用函数的 Hessian 矩阵输出来计算 polr 模型的方差-协方差矩阵。这是来自 polr 帮助文件中的示例。
house.plr <- polr(Sat ~ Infl + Type + Cont, weights = Freq, data = housing, Hess=TRUE)
house.plr
vcov(house.plr)
产量:
InflMedium InflHigh TypeApartment TypeAtrium TypeTerrace ContHigh Low|Medium Medium|High
InflMedium 0.0109522057 0.0058388698 -0.0001186328 0.0003571197 0.0001194372 0.0005232715 0.005775204 0.006214155
InflHigh 0.0058388698 0.0161686862 -0.0011185535 -0.0005789764 -0.0002820811 0.0014699005 0.005527505 0.006480153
TypeApartment -0.0001186328 -0.0011185535 0.0142177040 0.0096212170 0.0096814809 -0.0013601564 0.008675546 0.008249148
TypeAtrium 0.0003571197 -0.0005789764 0.0096212170 0.0240787651 0.0097933321 -0.0019949511 0.008588096 0.008323855
TypeTerrace 0.0001194372 -0.0002820811 0.0096814809 0.0097933321 0.0229480160 -0.0020860814 0.008860681 0.008043844
ContHigh 0.0005232715 0.0014699005 -0.0013601564 -0.0019949511 -0.0020860814 0.0091270890 0.004438238 0.004703586
Low|Medium 0.0057752039 0.0055275049 0.0086755464 0.0085880959 0.0088606811 0.0044382384 0.015586835 0.014367825
Medium|High 0.0062141551 0.0064801526 0.0082491485 0.0083238553 0.0080438438 0.0047035861 0.014367825 0.015743208
当我取 Hessian 矩阵的逆时,除了最后一行和最后一列,我得到相同的矩阵,它对应于中|高截距。
(solve(house.plr$Hessian))
产量:
InflMedium InflHigh TypeApartment TypeAtrium TypeTerrace ContHigh Low|Medium Medium|High
InflMedium 0.0109522057 0.0058388698 -0.0001186328 0.0003571197 0.0001194372 0.0005232715 0.005775204 0.0003698475
InflHigh 0.0058388698 0.0161686862 -0.0011185535 -0.0005789764 -0.0002820811 0.0014699005 0.005527505 0.0008026733
TypeApartment -0.0001186328 -0.0011185535 0.0142177040 0.0096212170 0.0096814809 -0.0013601564 0.008675546 -0.0003592705
TypeAtrium 0.0003571197 -0.0005789764 0.0096212170 0.0240787651 0.0097933321 -0.0019949511 0.008588096 -0.0002226414
TypeTerrace 0.0001194372 -0.0002820811 0.0096814809 0.0097933321 0.0229480160 -0.0020860814 0.008860681 -0.0006882434
ContHigh 0.0005232715 0.0014699005 -0.0013601564 -0.0019949511 -0.0020860814 0.0091270890 0.004438238 0.0002235743
Low|Medium 0.0057752039 0.0055275049 0.0086755464 0.0085880959 0.0088606811 0.0044382384 0.015586835 -0.0010271027
Medium|High 0.0003698475 0.0008026733 -0.0003592705 -0.0002226414 -0.0006882434 0.0002235743 -0.001027103 0.0018418271
如果我然后尝试使用 Hessian 派生的方差-协方差矩阵 导出系数的标准误差sqrt(diag(solve(house.plr$Hessian)))
,我最终会得到中 | 高截距的标准误差的不同估计值,我会从summary(house.plr)
. 有人可以解释这里发生了什么吗?
编辑:下面的 aosmith 评论提供了这个问题的简单答案,vcov.polr
它不仅返回逆 Hessian,还涉及估计的阈值。我的困惑,其解释可能对其他人有用,源于这样一个事实,即使用vcov
从调查包中的有序逻辑函数返回的对象svyolr
返回一个不考虑估计阈值的矩阵。看起来好像vcov.svyolr
只是简单地返回 Hessian 的逆矩阵,这不足以在有序逻辑模型中推导方差 - 协方差矩阵(如果我在这方面错了,请纠正我)。假设当我试图在进一步分析中使用它时它确实给我带来了麻烦。(我最终通过从summary.svyolr
,它计算正确的 vcov 以确定标准误差。)
为了说明我的意思,我通过重新格式化上面的数据集来继续上面的代码,以便它可以被 使用svyolr
,然后尝试使用“vcov”提取 vcov 矩阵:
#Formatting
housing.long<-expand.table(housing, freq="Freq")
housing.long$Sat<-ordered(housing.long$Sat, levels=c("Low","Medium","High"))
housing.long$Infl<-relevel(housing.long$Infl,ref="Low")
housing.long$Type<-relevel(housing.long$Type,ref="Tower")
housing.long$Cont<-relevel(housing.long$Cont,ref="Low")
#create svy objecct
house.plrsvy <- svydesign(ids=~1, data=housing.long)
#store model
house.plrsvy <-svyolr(Sat ~ Infl + Type + Cont, design=house.plrsvy)
vcov(house.plrsvy) [c(2,1,3,4,5,6,7,8),c(2,1,3,4,5,6,7,8)] #reording so it matches the matrix above
这将返回一个可以与上面返回的矩阵进行对比的矩阵vcov(house.plr)
,注意最后一行和最后一列:
InflMedium InflHigh TypeApartment TypeAtrium TypeTerrace ContHigh Low|Medium Medium|High
InflMedium 0.0107386871 0.0056386668 -0.0002981046 -0.0001050978 -0.0002336774 0.0004818157 0.005346583 0.0003733560
InflHigh 0.0056386668 0.0165482681 -0.0010957497 -0.0003494497 -0.0002874101 0.0012244473 0.005220762 0.0008554517
TypeApartment -0.0002981046 -0.0010957497 0.0146171435 0.0099883268 0.0100760460 -0.0011474964 0.009094801 -0.0003656346
TypeAtrium -0.0001050978 -0.0003494497 0.0099883268 0.0234161270 0.0102936420 -0.0020927259 0.008830475 -0.0003345245
TypeTerrace -0.0002336774 -0.0002874101 0.0100760460 0.0102936420 0.0231356022 -0.0023225443 0.008963416 -0.0006818656
ContHigh 0.0004818157 0.0012244473 -0.0011474964 -0.0020927259 -0.0023225443 0.0092707384 0.004737418 0.0001668623
Low|Medium 0.0053465831 0.0052207623 0.0090948014 0.0088304752 0.0089634162 0.0047374180 0.015934585 -0.0010762218
Medium|High 0.0003733560 0.0008554517 -0.0003656346 -0.0003345245 -0.0006818656 0.0001668623 -0.001076222 0.0018436991