[R] plm package duplication problem

Achim Zeileis Achim.Zeileis at uibk.ac.at
Mon Mar 29 22:19:38 CEST 2010

On Mon, 29 Mar 2010, serdal wrote:

> hi,
> i am writing my master thesis and i am dealing with 146474 observations
> (panel data), i have just learned the R so i am a beginner!!
> i am trying to use the "plm" package and i have a duplication problem;
> i have written the following commands to read my data and create my model
>> dsn<-plm.data(ds, c("stno", "year"))  ds=name of my data, stno=individual
> effect, year=time effect
> this command works just fine, i can even get the summary of "dsn" with
>> summary(dsn) which works fine also, however my problem starts when i define
> my model and i cant find where do i make mistake!!
> i try to create my model with the following command
>> dsn.plm <- plm(lnQ~lnC+lnL+lnM+lnE,data=ds,
> random.method="walhus",effect="twoways",model="random")
> and than i get this error message
> duplicate couples (time-id)
> Error in pdim.default(index[[1]], index[[2]]) :

The error is rather explicit, I think: There is at least one time 
value (= year in your case) duplicated for at least one level of your id 
variable (= stno) which is not supported.

An artificial example replicating this is:

dat <- data.frame(y = rnorm(7), x = rnorm(7), stno = rep(1:2, c(3, 4)),
   year = c(2001:2003, 2001, 2001:2003))
pdat <- plm.data(dat, c("stno", "year"))
plm(y ~ x, data = pdat)

To find out which ID has duplicated times, you can do something like:

with(pdat, levels(stno)[tapply(year, stno,
   function(x) any(table(x) > 1))])


> so my question is; is there anyone who knows how to overcome with this
> error!
> for now i dont know if i have to give more info and which info! but if you
> think you can help me i am ready to send more info...
> thanks for sparing your time!
> 	[[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list