[R] plm problem: Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent

Daniel Folkinshteyn dfolkins at gmail.com
Tue Aug 19 00:49:20 CEST 2008


Hi,

I am having a problem with a fixed-effects regression using the "plm" 
package. A regression of this form runs just fine:

plm(y ~ x*z, data=datasubset, model="within")

but when i try to add a lag in there, and run it on the same dataset, 
like this:

plm(y ~ x*z + lag(x,-1)*z, data=datasubset, model="within")

it fails with this error:

Error in dimnames(x) <- dn :
   length of 'dimnames' [2] not equal to array extent

I am not sure how to dig in further to figure out what exactly is wrong, 
and I'd appreciate any pointers.

I tested it with a simple test dataframe and an even simpler model, and 
the same result obtains. Here's the code to reproduce:

library(plm)
a = data.frame(id = rep(1:20, 5), time = rep(1:5, each=20), y = 
rnorm(100), x = rnorm(100))
plm(x ~ y, data=a, model="within") # this runs fine
plm(x ~ y + lag(y), data=a, model="within") #this errors out

Am i just not using plm correctly here? according to page 9 of the 
vignette, it should accept a formula of this type...

Any help appreciated!

Thanks,
Daniel



More information about the R-help mailing list