文档详情

panel data models program and output面板数据模型程序输出.pdf

发布:2025-06-09约1.43万字共12页下载文档
文本预览下载声明

#PanelDataModelsinR

#Copyright2013byAniKatchova

#install.packages(plm)

library(plm)

mydata-read.csv(C:/Econometrics/Data/panel_wage.csv)

attach(mydata)

Y-cbind(lwage)

X-cbind(exp,exp2,wks,ed)

#Setdataaspaneldata

pdata-plm.data(mydata,index=c(id,t))

#Descriptivestatistics

summary(Y)

summary(X)

#PooledOLSestimator

pooling-plm(Y~X,data=pdata,model=pooling)

summary(pooling)

#Betweenestimator

between-plm(Y~X,data=pdata,model=between)

summary(between)

#Firstdifferencesestimator

firstdiff-plm(Y~X,data=pdata,model=fd)

summary(firstdiff)

#Fixedeffectsorwithinestimator

fixed-plm(Y~X,data=pdata,model=within)

summary(fixed)

#Randomeffectsestimator

random-plm(Y~X,data=pdata,model=random)

summary(random)

#LMtestforrandomeffectsversusOLS

plmtest(pooling)

#LMtestforfixedeffectsversusOLS

pFtest(fixed,pooling)

#Hausmantestforfixedversusrandomeffectsmodel

phtest(random,fixed)

#PanelDataModelsinR

#Copyright2013byAniKatchova

#install.packages(plm)

library(plm)

Loadingrequiredpackage:bdsmatrix

Attachingpackage:‘bdsmatrix’

Thefollowingobject(s)aremaskedfrom‘package:base’:

backsolve

Loadingrequiredpackage:nlme

Loadingrequiredpackage:Formula

Loadingrequiredpackage:MASS

Loadingrequiredpackage:sandwich

Loadingrequiredpackage:zoo

Attachingpackage:‘zoo’

Thefollowingobject(s)aremaskedfrom‘package:base’:

as.Date,as.Date.numeric

mydata-read.csv(C:/Econometrics/Data/panel_wage.csv)

attach(mydata)

Y-cbind(lwage)

X-cbind(exp,exp2,wks,ed)

#Setdataaspaneldata

pdata-plm.data(mydata,index=c(id,t))

#Descriptivestatistics

summary(Y)

lwage

Min.:4.605

1stQu.:6.395

显示全部
相似文档