I would like to perform a Fixed effect logit estimation in R. Can someone point out a package that can do the job?

Note: For the time being I'm not really interested in the random effect.


Essentially I wonder if there is the plm package for a binary response model.

Here is some documentation for the plm package:


  • $\begingroup$ It might help to post the head() of your data. $\endgroup$
    – Jack Ryan
    Mar 26 '14 at 18:09

There is a new R Package called "bife" that performs Fixed Effects binary logit Models.


  • 3
    $\begingroup$ While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review $\endgroup$
    – Sycorax
    Oct 1 '16 at 15:47
  • 1
    $\begingroup$ Sycorax, in general you're right, but the question was "Can someone point out a package that can do the job?". Therefore, I don't see why my answer doesn't include "the essential parts of the answer here". $\endgroup$
    – oelshie
    Oct 8 '16 at 20:46
  • $\begingroup$ Thanks for the link. I think the package is best for FE logit model in R. However, I want to include lags of dependent & independent variables in logit regression of daily time series dataset. Is there any package for it? $\endgroup$ Oct 3 '17 at 8:43
  • $\begingroup$ looks like the link changed... :D $\endgroup$
    – Jakob
    Sep 3 '19 at 15:37
  • $\begingroup$ @Mumbo.Jumbo Did you find an R package that makes it easy to include lags in a longitudinal dataset for logistic regression? $\endgroup$
    – Jeremy K.
    Feb 19 '20 at 6:04

If you mean logistic regression, for example, along the lines of

$Y_i\sim\text{Bernoulli}(1,p_i)\,$, with

$\text{logit}(p_i) = X\beta\,$,

(equivalently, $P[Y_i=1] = \frac{\exp(X\beta)}{1+\exp(X\beta)},$)

then use glm. For example:


There are examples in the help at ?glm.predict, ?infert and ?esoph.

If you mean fitting a logistic curve via least squares, like

$E(Y) = \alpha \cdot(\frac{\exp(\beta_0+\beta_1 x)}{1+\exp(\beta_0+\beta_1 x)})$

then use nls. There's an example of fitting a logistic function in the help at ?nls.

Both are part of the standard R installation.

If you mean something else, you need to clarify what you want.

I see from this answer that apparently economists use 'fixed effect model' to refer to a conditional logit model, even though it's far from the only fixed effect model involving a logit. Who would have thought.

As ndoogan mentions in one of the other answers, there's a conditional logistic regression model (clogit) in the survival package.


I'm almost certain that you mean conditional logistic regression. This will estimate the within-group relationship between your independent variables and your binary dependent variable. It's similar to adding a dummy for each individual (as in fixed effects). In which case, use the clogit() function in the survival package that is included with R.


Standard fixed effects assumptions break down in nonlinear models (like logit).

When you can assume gaussian disturbance, you can model: $$ y_{it} = X_{it}\beta + u_{it}\\ y_{it} = X_{it}\beta + \alpha_i + \epsilon_{it}\\ y_{it} - \bar{y}_i = (X_{it}-\bar{X}_i) \beta + \alpha_i - \bar\alpha_i + \epsilon_{it} -\bar\epsilon_i\\ y_{it}^{dm} = X_{it}^{dm} \beta + \epsilon_{it}^{dm} $$ where $dm$ is the deviation from the mean. This is the within transformation. You get rid of all of your time-invariant heterogeneity, and if you can make an argument that $E[\epsilon_{it}|X,\alpha]=0$, then $\beta$ gets a causal interpretation.

Try this math with a logit link functions and you'll see that it all breaks down. Other approaches exist -- one of the other answerers suggested conditional logit.

  • $\begingroup$ This is true but hardly comes close to answering the question. $\endgroup$ Mar 22 '20 at 10:12

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.