Logistic regression with persistent clustered standard errors in R

Newbie question: does anyone know how to trigger a logical regression with cluster standard errors in R? In Stata, it's just logit Y X1 X2 X3, vce(cluster Z) , but unfortunately I did not understand how to do the same analysis in R. Thanks in advance!

+7
source share
2 answers

You might want to check out the rms package (regression modeling strategies). So lrm is a logistic regression model, and if fit is the name of your output, you will have something like this:

 fit=lrm(disease ~ age + study + rcs(bmi,3), x=T, y=T, data=dataf) fit robcov(fit, cluster=dataf$id) bootcov(fit,cluster=dataf$id) 

You must specify x=T , y=T in the model statement. rcs stands for bounded 3-node cubic splines.

+13
source

I hit my head about this issue in the last two days; I magically found what seems like a new package that seems to be designed for big things - for example, I also use some cluster-resistant Tobit models in my analysis, and this package also has built-in functionality. Not to mention that the syntax is much cleaner than in all the other solutions I've seen (we say that the levels near Stata are clean).

So, for your toy example, I would run:

 library(Zelig) logit<-zelig(Y~X1+X2+X3,data=data,model="logit",robust=T,cluster="Z") 

Et voilร !

+2
source

All Articles