Please see question for the background.

Following the advice of @kwak and @Andy W, I have decided to use the package plm in R to fit my model. Here an excerpt of the data df (the numbers are made up, not real data!):

    reg year          ur         mur cl
1    1 2001 0.000698717 0.012483361  1
2    2 2001 0.008283762 0.011899896  1
3    3 2001 0.001863817 0.012393738  1
4    4 2001 0.005344206 0.012126016  1
5    5 2001 0.007475083 0.011962102  1
6    6 2001 0.002785111 0.012322869  1

where reg is the region indicator, year is the year of measurement, ur is the unemployment rate, mur is the average unemployment rate in the neighboring regions (given by cl) excluding the current region (see @kwak suggestion). Below is the code that I used in R

fm <- pgmm(log(ur)~lag(log(ur),1)+log(mur)|lag(log(ur),2:40),data=df)

I have several question regarding this model:

  • I guess I should choose effect="individual" to avoid having time dependent intercepts (?). But doing so the code is crashing (Error in names(coefficients) <- c(namesX, namest))!
  • Which model should I choose, onestep or twosteps?
  • How do I decide on the numbers of instruments (40 is just a guess)?

Assuming that I have fitted this model successfully, how do I simulate from it?


  • $\begingroup$ I haven't used this package extensively myself. I think individual effect is indeed what you want. Two step will yield smaller standard errors (see the paper i linked to in my original answer). The number of instruments should be smaller than the number of years-1 you have. Try 2:9 (i think you have 9 years per region). You could also start by using the gretl implementation (which is simpler to use) and come back to R whence you have mastered the model a bit. $\endgroup$
    – user603
    Commented Oct 21, 2010 at 14:33
  • $\begingroup$ @kwak but the model specification is correct, isn't it? Btw, why the numbers of instruments should be smaller than years-1? If you look the example of plm vignette with EmplUK data set (p.23) they use 2:99 (I don't really understand why)? I came across the following formula for number of instruments (T-1)*(T-2)/2+(T-3)...I'll have a look at gretl, thx! $\endgroup$
    – teucer
    Commented Oct 21, 2010 at 15:08

1 Answer 1


It is a known bug in plm package, when effect="individual" the pgmm crashes. The bug is fixed in plm version 1.2-7.

As for simulation, you need to calculate estimates of individual effects, since they are not estimated in GMM. At the current moment, the plm does not have the functions for predicting GMM model. I have created and put them here, but I do not advise to use them if you are not familiar with R. I have submitted these functions (forecast.pgmm and predict.pgmm) to plm maintainers, but they did not include them yet in plm package.

  • 1
    $\begingroup$ I found a potential bug in fitted.pgmm and left an "issue" in github... $\endgroup$
    – teucer
    Commented Feb 4, 2011 at 8:33

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.