# Logistic regression with panel data

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.

• 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 – paqmo May 20 '18 at 0:31
• @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? – abu May 22 '18 at 21:50
• 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. – paqmo May 25 '18 at 18:28
• In the end I am using a random-effects model so pglm is perfectly fine (or lme4). Thanks! – 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.
• 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. – generic_user May 19 '18 at 20:45
• I had thought that it could include both? Perhaps clogistic() within Epi` could be useful. – NatWH May 19 '18 at 20:57