# R plm strange error when using pgmm

I have a data.frame that looks like this:

> head(mydata)
model scenario iso3c year     feelecpc    gdppc      popdens    t
EDGE  history   AFG  2002   0.0001057354 1052.958 3.404137e-05 2002
EDGE  history   AFG  2003   0.0001373833 1096.756 3.544170e-05 2003
EDGE  history   AFG  2004   0.0001289229 1066.685 3.682548e-05 2004
EDGE  history   AFG  2005   0.0001245555 1145.717 3.811670e-05 2005
...
>


feelecpc is electricity demand, gdppc is GDP per capita and popdens is population density. The last column is a copy of the year column and is only used to include a time trend instead of year dummies.

The data.frame is converted into a pdata.frame:

pdata <- pdata.frame(mydata, index=c("iso3c", "year"))


If I now estimate the following model:

gmm1 <- pgmm(log(feelecpc) ~ lag(log(feelecpc), 1) + log(gdppc) + I(log(gdppc)^2) + log(popdens) + I(log(popdens)^2), gmm.inst = ~lag(log(feelecpc), 2:99), data=pdata)


I get an error:

Error in solve.default(crossprod(WX, t(crossprod(WX, A1)))) :
system is computationally singular: reciprocal condition number = 0
In pgmm(log(feelecpc) ~ lag(log(feelecpc), 1) + log(gdppc) + I(log(gdppc)^2) +  :
the second-step matrix is singular, a general inverse is used


If I leave out the second order polynomial of popdens, only the warning is reported (by the way: Do I have to worry about this one?):

gmm2 <- pgmm(log(feelecpc) ~ lag(log(feelecpc), 1) + log(gdppc) + I(log(gdppc)^2) + log(popdens), gmm.inst = ~lag(log(feelecpc), 2:99), data=pdata)


Also, the error does not occur when I estimate a model similar to gmm1, but include year dummies:

gmm3 <- pgmm(log(feelecpc) ~ lag(log(feelecpc), 1) + log(gdppc) + I(log(gdppc)^2) + log(popdens) + I(log(popdens)^2), gmm.inst = ~lag(log(feelecpc), 2:99), data=pdata, effect="twoways")


I suppose this points to some problem with my data?! Can somehelp help?

• I've had similar problems. Plm is bad at auto-dropping colinear variables. Maybe check to make sure that you don't inadvertently generate such problems when the data is differenced. – generic_user Sep 22 '14 at 11:30