R:在MASS :: polr()中聚类标准错误 [英] R: Clustering standard errors in MASS::polr()

查看:109
本文介绍了R:在MASS :: polr()中聚类标准错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用MASS包的polr()函数估计具有聚类标准误差的序数逻辑回归.没有内置的聚类功能,因此我正在寻找(a)软件包或(b)使用模型输出使用模型输出来计算聚类标准误差的手动方法.我打算使用margins包来估计模型的边际效应.

I am trying to estimate an ordinal logistic regression with clustered standard errors using the MASS package's polr() function. There is no built-in clustering feature, so I am looking for (a) packages or (b) manual methods for calculating clustered standard errors using the model output. I plan to use margins package to estimate marginal effects from the model.

这里是一个例子:

library(MASS)
set.seed(1)
obs <- 500

# Create data frame
dat <- data.frame(y = as.factor(round(rnorm(n = obs, mean = 5, sd = 1), 0)),
              x = sample(x = 1:obs, size = obs, replace = T),
              clust = rep(c(1,2), 250))

# Estimate and summarize model
m1 <- MASS::polr(y ~x, data = dat, Hess = TRUE)

summary(m1)

尽管关于堆栈溢出的许多问题询问如何针对普通最小二乘模型(以及在某些情况下针对

While many questions on Stack Overflow ask about how to cluster standard errors in R for ordinary least squares models (and in some cases for logistic regression), it's unclear how to cluster errors in ordered logistic regression (i.e. proportional odds logistic regression). Additionally, the existing SO questions focus on packages that have other severe drawbacks (e.g. the classes of model outputs are not compatible with other standard packages for analysis and presentation of results) rather than using MASS::polr() which is compatible with predict().

推荐答案

这基本上是在

这篇关于R:在MASS :: polr()中聚类标准错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆