《面板数据的stata分析.pdf》由会员分享,可在线阅读,更多相关《面板数据的stata分析.pdf(24页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、Longitudinal/Panel Data AnalysisRaymond DuchUniversity of OxfordNueld C 22,20081/24Readings1Gellman,Andrew and Jennifer Hill.2007.Data Analysis UsingRegression and Multilevel/Hierarchical Models.CambridgeUniversity Press2Stata 10.0 Manual Longitudinal/Panel Data3Rabe-Hesketh,Sophia and Anders Skrond
2、al.2005.Multileveland Longitudinal Modeling Using Stata.Stata Press2/24What is longitudinal panel data?1Marriage of regression and time-series analysis2A broad cross-section of subjects observed over time3Individuals surveyed repeatedly over time(American NationalElection Study;U.S.Panel Study of In
3、come Dynamics)4Statistics compiled over time for a particular geo-politicalentity(Divorce Rates and welfare rates collected annually fromU.S.States)5Statistics compiled on hospital patients over time3/24Modeling Panel Data(Repeated)cross-sectional regression analysis generates thefollowing modelyit=
4、+xit+?it(1)yit=+x0itB+?it(2)1Heterogeneity or uniqueness of subjects captured in?it2The cross-sectional units(individuals,rms,cities)arerepresented by i3Repeated time units are represented by t4/24Varying Intercept Modelyit=j+xit+?it(3)GroupDGroupCGroupBGroupAYX5/24Varying Slope Modelyit=+jxit+?it(4
5、)GroupCGroupBGroupAGroupDYX6/24Varying Intercepts and Slopes Modelyit=j+jxit+?it(5)GroupCGroupBGroupAYGroupDX7/24Data Preparation in Stata:Australian Smoking Study1data is available athttp:/www.stat.columbia.edu/gelman/arm/2variables:newid(identies each unique respondent)sex(1=female)parsmk(1=parent
6、s smoke)wave(identies eachof 6 waves)smkreg(is respondent regular smoker)8/24.list+-+|newidsex_1_f_parsmkwavesmkreg|-|1.|11010|2.|11020|3.|11040|4.|11050|5.|11060|-|6.|20010|7.|20020|8.|20030|9.|20040|10.|20050|-|11.|20060|12.|31010|13.|31020|14.|31030|15.|31040|-|16.|31050|17.|31060|18.|41010|19.|4
7、1020|20.|41030|-|21.|41040|22.|41050|23.|41060|24.|50010|25.|50020|-|26.|50030|27.|50040|28.|50050|29.|50060|30.|60010|9/24Smoking by Sex over Panel Wavesgirlsboys050100150proportion smokers in population123456wave10/24Modeling the Smoking Longitudinal DataPr(yjt=1)=logit1(0+1psmokejt+2femalejt+(6)3
8、t+4femalejt t+j+?jt),t=1,.Tj,j=1,.,n.(7)j N(,2)(8)11/24Estimation with Gllamm in Stata.use e:Oxford08Department08Trinity_PanelDatagelmansmoke_pub.dta,clear.tsset newid wavepanel variable:newid(unbalanced)time variable:wave,1 to 6,but with gapsdelta:1 unit.gllamm smkreg parsmk wave,i(newid)link(logit
9、)family(binom)12/24Estimation with Gllamm in Statagllamm modellog likelihood=-2074.7563-smkreg|Coef.Std.Err.zP|z|95%Conf.Interval-+-parsmk|1.270422.19982376.360.000.87877461.662069wave|.4195264.036513211.490.000.3479619.4910909_cons|-7.24026.2742149-26.400.000-7.777711-6.702808-Variances and covaria
10、nces of random effects-*level 2(newid)var(1):13.679018(.88531601)-13/24Estimation with Gllamm in Stata:Incorporating Time Trend.gen male_time=wave*(1-sex_1_f).gen female_time=wave*sex_1_f.gen sex_time=wave*sex_1_f.gllamm smkreg parsmk wave sex_time,i(newid)link(logit)family(binom)14/24Estimation wit
11、h Gllamm in Stata:Incorporating Time Trend.gen male_time=wave*(1-sex_1_f).gen female_time=wave*sex_1_f.gen sex_time=wave*sex_1_f.gllamm smkreg parsmk wave sex_time,i(newid)link(logit)family(binom)15/24Estimation with Gllamm in Stata:Incorporating Time Trendnumber of level 1 units=8730number of level
12、 2 units=1760Condition Number=17.565231gllamm modellog likelihood=-2071.4531-smkreg|Coef.Std.Err.zP|z|95%Conf.Interval-+-parsmk|1.314832.22783615.770.000.86828121.761382wave|.3598051.04325298.320.000.275031.4445792sex_time|.10706.04248222.520.012.0237965.1903235_cons|-7.263204.2767673-26.240.000-7.8
13、05658-6.72075-Variances and covariances of random effects-*level 2(newid)var(1):13.797342(.90193295)-16/24Estimation with Gllamm in Stata:Incorporating Time Trend+-+|newidconstantreffm1inter_eb|-|1.|1-7.263204-1.1592099-8.422414|2.|1-7.263204-1.1592099-8.422414|3.|1-7.263204-1.1592099-8.422414|4.|1-
14、7.263204-1.1592099-8.422414|5.|1-7.263204-1.1592099-8.422414|+-+.list newid constant reffm1 inter_eb in 1090/1095+-+|newidconstantreffm1inter_eb|-|1090.|202-7.263204-.76498347-8.028188|1091.|203-7.2632047.1519595-.1112444|1092.|203-7.2632047.1519595-.1112444|1093.|203-7.2632047.1519595-.1112444|1094
15、.|203-7.2632047.1519595-.1112444|-|1095.|203-7.2632047.1519595-.1112444|+-+.list newid constant reffm1 inter_eb in 1160/1165+-+|newidconstantreffm1inter_eb|-|1160.|215-7.2632046.0917393-1.171465|1161.|215-7.2632046.0917393-1.171465|1162.|215-7.2632046.0917393-1.171465|1163.|215-7.2632046.0917393-1.1
16、71465|1164.|216-7.263204-1.4855779-8.748782|-|1165.|216-7.263204-1.4855779-8.748782|+-+17/24Data Preparation in Stata:Growth Curve Modeling1data is available with following command:net fromhttp:/www.stata- identier)weight(weight in Kg)age(agein years)gender(1 male;2 female)18/24.list+-+|idoccageweig
17、htbrthwtgender|-|1.|451.1368935.1714140boy|2.|452.65708410.864140boy|3.|4531.2183413.154140boy|4.|4541.4291613.24140boy|5.|4552.2724215.884140boy|-|6.|2581.191655.33155girl|7.|2582.6872019.743155girl|8.|25831.127999.983155girl|9.|25842.3052711.343155girl|10.|2871.1341554.823850boy|-|11.|2872.700899.
18、093850boy|12.|28731.1690611.13850boy|13.|28742.242316.83850boy|14.|4831.7474335.762875girl|15.|48321.018486.922875girl|-|16.|48332.245049.532875girl|17.|7251.1204654.43280girl|18.|72522.3052712.253280girl|19.|80011.1225210.893900boy|20.|80022.2614612.73900boy|19/24Observed growth trajectories for bo
19、ys and girls510152001230123boygirlWeight in KgAge in yearsGraphs by gender20/24Modeling the Growth Trajectory Datayjt=0+1agejt+2age2jt+j+?jt,(9)t=1,.Tj,j=1,.,n.(10)j N(,2)(11)21/24Estimation with xtmixed in Stata.gen age2=age2.xtmixed weight age age2|id:,mlePerforming EM optimization:Performing grad
20、ient-based optimization:Iteration 0:log likelihood=-276.83266Iteration 1:log likelihood=-276.83266Computing standard errors:Mixed-effects ML regressionNumber of obs=198Group variable:idNumber of groups=68Obs per group:min=1avg=2.9max=5Wald chi2(2)=2623.63Log likelihood=-276.83266Prob chi2=0.0000-wei
21、ght|Coef.Std.Err.zP|z|95%Conf.Interval-+-age|7.817918.289652926.990.0007.2502098.385627age2|-1.705599.1085984-15.710.000-1.918448-1.49275_cons|3.432859.181070218.960.0003.0779683.78775-Random-effects Parameters|EstimateStd.Err.95%Conf.Interval-+-id:Identity|sd(_cons)|.9182256.0973788.74589651.130369
22、-+-sd(Residual)|.7347063.0452564.6511507.8289837-LR test vs.linear regression:chibar2(01)=78.07 Prob=chibar2=0.0000.end of do-file22/24Incorporating Gender Dierences to the Growth Modelyjt=0+1agejt+2age2jt+3girljt+4girl agejt(12)j+?jt,t=1,.Tj,j=1,.,n.(13)j N(,2)(14)23/24Estimation with xtmixed in St
23、ata.xtmixed weight age age2 girl age_girl|id:,mleIteration 1:log likelihood=-270.7967Mixed-effects ML regressionNumber of obs=198Group variable:idNumber of groups=68Obs per group:min=1avg=2.9max=5Wald chi2(4)=2705.20Log likelihood=-270.7967Prob chi2=0.0000-weight|Coef.Std.Err.zP|z|95%Conf.Interval-+
24、-age|7.932362.293571727.020.0007.3569738.507752age2|-1.70546.1069802-15.940.000-1.915138-1.495783girl|-.4889737.2752022-1.780.076-1.02836.0504127age_girl|-.2289743.1377625-1.660.096-.4989839.0410353_cons|3.676974.221229116.620.0003.2433734.110575-Random-effects Parameters|EstimateStd.Err.95%Conf.Interval-+-id:Identity|sd(_cons)|.8470338.0921964.68430651.048457-+-sd(Residual)|.7261711.0446575.6437132.8191916-LR test vs.linear regression:chibar2(01)=69.16 Prob=chibar2=0.000024/24