I am having a problem setting up a panel data model.
Here is some sample data:
id <- c(1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2)
year <- c(1999,1999,1999,1999,2000,2000,2000,2000,1999,1999,1999,1999,2000,2000,2000,2000)
qtr <- c(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4)
y <- rnorm(16, mean=0, sd=1)
x <- rnorm(16, mean=0, sd=1)
data <- data.frame(id=id,year=year,qtr=qtr,y_q=paste(year,qtr,sep="_"),y=y,x=x)
I run the following regression using 'id' as the individual index and 'year' as the time index:
reg1 <- plm(y ~ x, data=data,index=c("id", "year"), model="within",effect="time")
Unfortunately, I get the following error:
> duplicate couples (time-id) Error in pdim.default(index[], index[]) :
So to get around that, I use the combined variable that is 'y_q':
reg1 <- plm(y ~ x, data=data,index=c("id", "y_q"), model="within",effect="time")
But here's my issue -- I only want to have year fixed effects and not year-quarter.
Is there another way to get around the earlier issue instead of making the tiem index 'y_q'?
Thanks ahead of time for any help! see also stackoverflow.com/questions/28789767/â€¦
以上就是R: plm -- year fixed effects -- year and quarter data的详细内容，更多请关注web前端其它相关文章！