#1、读入数据csv格式
paneldata<-read.csv('d:/paneldata.csv',header=T)
#2、查看变量名称,列出1-20个样本
paneldata[1:20,]
#3、调用plm包
library(plm)
#4、面板模型回归
model.fixed <-plm(log(c)~log(q)+log(pf)+lf,data=paneldata,model="within" ,index=c("id","year"))
model.random <-plm(log(c)~log(q)+log(pf)+lf,data=paneldata,model="random" ,index=c("id","year"))
model.pooled <-plm(log(c)~log(q)+log(pf)+lf,data=paneldata,model="pooling",index=c("id","year"))
summary(model.fixed )
summary(model.random )
summary(model.pooled )
#5、hausman检验
phtest(model.fixed, model.random)