I am looking for a package/library to run logistic regression on panel data. I already did some research and most of the sources suggest Stata, however, I would like to use R or Python, as I am using one of these for data preparation. I have found this, but this is not a well know package as far as I know. Any suggestions would be welcome.

  • $\begingroup$ pglm package in R. You also run glm with family = “binomial” and include your entity variable as a factor and correct the standard errors with the sandwich` package $\endgroup$ – paqmo May 20 '18 at 0:31
  • $\begingroup$ @paqmo The coefficients will be the same in case of using both of the packages and only the standard errors will be different? If so, could you please show some reference so I can read on the subject? $\endgroup$ – abu May 22 '18 at 21:50
  • $\begingroup$ I should correct myself -- it's a bit more complicated to do a fixed-effect logistic regression, e.g. (see here). But there's the bife package that does fixed-effects for panel data with binary outcomes. $\endgroup$ – paqmo May 25 '18 at 18:28
  • $\begingroup$ In the end I am using a random-effects model so pglm is perfectly fine (or lme4). Thanks! $\endgroup$ – abu Jun 3 '18 at 20:17

You can model longitudinal data within a Generalized Linear Mixed Model (GLMM) framework, if you're looking to implement logistic regressions. One commonly used R package is lme4, you can use the glmer() function.

| cite | improve this answer | |
  • 2
    $\begingroup$ Note that glmer implements random, rather than fixed effects. If you're attempting inference and want to control for all cross-sectional heterogeneity, glmer won't get you there. You'd need some implementation of the conditional logit model. $\endgroup$ – generic_user May 19 '18 at 20:45
  • $\begingroup$ I had thought that it could include both? Perhaps clogistic() within Epi could be useful. $\endgroup$ – NatWH May 19 '18 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.