I have a (I suspect) simple question. I have time series cross section data on voting behaviour in the Council of the European Union (the monthly number of yes, no and abstentions for each member state from 1999 to 2007). So basically the variables are counts, thus a Poisson/negative binomial regression would be appropriate, possibly with lagged dependent variables on the right hand side to control for time dependencies. I have seen papers with people using such negative binomial models to forecast, for instance the number of monthly legislative acts adopted in the future, and I have three questions in this regard:

  1. How can i run a negative binomial regression on panel data without making any inferential mistakes?

  2. How can I use a negative binomial model with lags to forecast future values of the dependent variable.

  3. Can this be done in R?



2 Answers 2


After a bit of research, I can give a partial answer. In his book Wooldridge discusses Poisson and negative binomial regressions for cross-section and panel data. But for regression with lagged variables he only discusses Poisson regression. Maybe negative binomial is discussed in the new edition. The main conclusion is that for random effects Poisson regression with lagged random variable can be estimated by mixed effects Poisson regression model. The detailed description can be found here. The mixed effects Poisson regression in R can be estimated with glmer from package lme4. To adapt it to work with panel data, you will need to create lagged variable explicitly. Then your estimation command should look something like this:


You should also look into gplm package suggested by @dickoa. But be sure to check, whether it supports lagged variables. Yves Croissant, the creator of gplm and plm packages writes wonderful code, but unfortunately in my personal experience, the code is not tested enough, so bugs crop up more frequently than in standard R packages.

  • $\begingroup$ Thanks a lot for this! I am still a bit new to all of this, how would one write a function for forecasting? Is it a simple matter of fixing the independent variables, and then feed the predicted values back into the lag term in the model to get new predicted values? $\endgroup$ Jan 11, 2011 at 21:20
  • 1
    $\begingroup$ @Thomas Jensen, something like this. When you have data up until period $t$, you can calculate the forecast of $y_{t+1}$. You use this forecast when forecasting $y_{t+2}$ and so on. To implement this some kind of loop construct will be necessary. $\endgroup$
    – mpiktas
    Jan 11, 2011 at 21:28
  • $\begingroup$ Great I really appreciate the help! $\endgroup$ Jan 11, 2011 at 21:35

May be you can take a look at the pglm package (from the same author of plm), use the family negbin. You can also try from a Bayesian point of view the MCMCglmm package.

  • $\begingroup$ Thanks, this does indeed look very useful. Do you know how one would go about predicting future values from the pgml() function? $\endgroup$ Jan 11, 2011 at 20:44
  • $\begingroup$ @Thomas Jensen, forecasting the future values is the weak point of plm package. There are no readily available functions even to get fitted values. So I do not expect that pglm will have them. If you chose to estimate model via pglm, you will have to code the prediction yourself. $\endgroup$
    – mpiktas
    Jan 11, 2011 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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