jepusto / clubSandwich

Cluster-robust (sandwich) variance estimators with small-sample corrections
http://jepusto.github.io/clubSandwich/
47 stars 8 forks source link

support for MASS::polr #65

Open pouwelskb opened 3 years ago

pouwelskb commented 3 years ago

I have build an ordered logistic regression model with MASS::polr and would like to get clustered standard errors for the marginal predictions. However this throws the following error, suggesting that MASS::polr is currently not supported:

> Error in split.default(resid, cluster): first argument must be a vector

jepusto commented 3 years ago

ReprEx:

require(foreign)
require(MASS)
library("clubSandwich")

dat <- read.dta("https://stats.idre.ucla.edu/stat/data/ologit.dta")
head(dat)

dat <- read.dta("https://stats.idre.ucla.edu/stat/data/ologit.dta")

## fit ordered logit model and store results 'm'
m <- polr(apply ~ pared + public + gpa, data = dat, Hess=TRUE)

clubSandwich::vcovCR(m, cluster = dat$public, type = "CR0")