0

I am trying to run very simple fixed effect model on a small data set. Sample data set is rather small. I loaded the data via a csv file and then ran plm command. But i am running into an error and i am not able to figure out reason. My csv file looks like this:

country,year,y,x1
A,2000,6.0,7.8
A,2001,4.6,0.6
A,2002,9.4,2.1

Following is the set of commands i ran on console:

>test<-read.table("test.csv",sep=",",header=TRUE)
head(test)
fixed <- plm(y ~ x1,data=test,index=c("country","year"),model="within")
series country is constant and has been removed
Error in pdata.frame(data, index) : variable country does not exist

I am using this as a reference to understand how to work with fixed and random effect model in R. When i followed the instruction mentioned in this ppt and ran plm() using there data set, i was able to get correct results. Thanks!

Thorst
  • 1,590
  • 1
  • 21
  • 35
harshul gandhi
  • 73
  • 1
  • 10

1 Answers1

0

I added one more country to my sample data set and it seems to work..so now the data looks like this:

<br>country,year,y,x1
<br>A,2000,6.0,7.8
<br>A,2001,4.6,0.6
<br>A,2002,9.4,2.1
<br>B,2000,5.0,7.2
<br>B,2001,5.6,0.9
<br>B,2002,8.1,3.4
harshul gandhi
  • 73
  • 1
  • 10