时间序列Stata操作 题4-7

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

《应用时间序列分析(第四版)》王燕编著中国人民大学出版社第四章习题71974年1月至1994年12月,某地胡椒价格数据如下:(21行*12列)1102115110931118128312501210113512501210126814021250121012681402242523262176212118501790170017002000202419001750159015261451142413731440145113761420138513211235212520871895184022702411265232944336438243264009485748654711464048104571425038502993310827292525196920251726157915081525150213741126120011931058111711881100104014971522155015751检验序列的平稳性(Stata语句).dropB-T.generaten=_n.renameAprice.tssetntimevariable:n,1to252delta:1unit.tslineprice=116811181085113511381135123513011085106011021151112712261217121514861534156715851717200220862059148615341567158517172002208620592000200018501640170019251850183017501775192520001975194018891881164916011625160916491640164016201424132911991179128513491265129913251261119912191250127413651424121513101319131912791481195621651874186318361894210521592131202933603686359334823615396343284309400040704200427844354772481249084877490248844833490349634804467937753357294623421994242024642763245721362272217521002068195519501768176616211692163417501620151512121198110710521069105010981150104310269809761000121012641150102811131154135017221616152514031538165018001933221926062563243300050004000300020001050100n150200250price{price}的时序图由时序图观测得price变化落差很大,该序列不平稳。再看看自相关图:...1.00-1.00-0.500.000.50(Stata语句)Autocorrelationsofprice.acprice=01020Lag3040Bartlett'sformulaforMA(q)95%confidencebands{price}的自相关图短期(延迟阶数为5期及5期以内)来看,自相关系数拖尾;长期来看,自相关系数缓慢地由正转负,一直是下降趋势。序列值之间长期相关,该序列非平稳序列。(Ps.平稳时间序列具有短期自相关性。)结合之前的时序图,发现该序列具有明显的长期趋势。考虑到price是月度数据,因此觉得该序列很有可能还...........存在季节效应。......2检验序列的方差齐性原序列具有长期趋势,所以需要平稳化。先对原序列做一阶差分:1000500-1000-50000(Stata语句).generateDp=D1.price.labelvariableDpfirstdifferenceofprice.tslineDp=firstdifferenceofprice50100n150200250{Dp}的时序图(一阶)差分后序列{Dp}的长期趋势不再明显,平稳化效果很好。再看看{Dp}的自相关图:0.40AutocorrelationsofDp-0.200.000.20(Stata语句).acDp=01020Lag3040Bartlett'sformulaforMA(q)95%confidencebands{Dp}的自相关图由图可见,短期(5期)内ρ̂衰减速度非常快,明显具有短期自相关性。ρ̂k便衰减直逼零值,k在延迟1期以后,除了当k=30时跳出过阴影范围,其余全都落在2倍标准误的范围内,围绕着零值做很小幅(约±0.1)的波动。因此,{Dp}是平稳的时间序列。平稳性检验通过,看白噪声检验。自相关图明显显示:ρ̂̂1≠0,ρ30≠0。因此,{Dp}非白噪声序列,有信息待提取。预处理完毕,开始识别模型:0.40AutocorrelationsofDp-0.200.000.20(Stata语句)01020Lag3040Bartlett'sformulaforMA(q)95%confidencebands{Dp}的自相关图=PartialautocorrelationsofDp-0.200.000.200.40.pacDp01020Lag304095%Confidencebands[se=1/sqrt(n)]{Dp}的偏自相关图(1)不考虑季节效应,先试ARIMA模型,再试疏系数模型。①ARIMA模型̂ⅰ认为ρ̂k和∅kk都拖尾,尝试ARMA(1,1)或者arimaDp,arima(1,0,1)Ps.同arimaprice,arima(1,1,1)结果̂ⅱ认为ρ̂k1阶截尾,∅kk拖尾,尝试MA(1)参数显著性检验通不过去掉截距项再试(Stata语句)arimaDp,noconstantarima(0,0,1)Ps.结果同arimaprice,noconstantarima(0,1,1)得到结果白噪声检验(Stata语句).predictehat1,residualCumulativeperiodogramforehat11.00截距项不显著对{Dp}构建MA(1)模型(无截距项)成功,对残差项进行白噪声检验CumulativePeriodogramWhite-NoiseTestPortmanteautestforwhitenoise---------------------------------------Portmanteau(Q)statistic=45.3466Probchi2(40)=0.2589Ps..wntestqehat1,lags(2).wntestqehat1,lags(6).wntestqehat1,lags(12)都通过了.wntestbehat1=.estatic0.000.000.200.400.600.80.wntestqehat10.100.200.30Frequency0.400.50Bartlett's(B)statistic=0.70ProbB=0.7145通过了白噪声检验,但这个检验的前提是同方差残差项是白噪声序列,计算AIC/BIC:=̂ⅱ认为ρ̂k拖尾,∅kk1阶截尾,尝试AR(1)去掉截距项再试(Stata语句).arimaDp,noconstantarima(1,0,0)白噪声检验(Stata语句).predictehat2,residual1.00截距项不显著对{Dp}构建AR(1)模型(无截距项)成功,对残差项进行白噪声检验.wntestqehat2Cumulativeperiodogramforehat2CumulativePeriodogramWhite-NoiseTestPortmanteautestforwhitenoise---------------------------------------Portmanteau(Q)statistic=40.3516Probchi2(40)=0.4547Ps.0.800.000.00.wntestqehat2,lags(2).wntestqehat2,lags(6).wntestqehat2,lags(12)都通过了.wntestbehat20.200.400.600.100.200.30Frequency0.400.50Bartlett's(B)statistic=0.67ProbB=0.7551=.estatic=②疏系数模型通过了白噪声检验,但这个检验的前提是同方差BIC方面,与MA(1)比,大了3点多;AIC方面仅小了0.5多一点。选择MA(1)̂因为前十二期(一年)内ρ̂1和∅11明显跳出了2倍标准误范围,所以确定ma(1),ar(1),与上面①ⅰ对{Dp}拟合ARMA(1,1)的情况一致,已经知道拟合不成了。(2)换季节模型,先试简单的加法模型,再试复杂的乘积模型。因为考虑了季节因子,这里是月度数据,所以要对一阶差分后序列进行12步差分。观察12步差分后序列的自相关系数和偏自相关系数的性质,尝试拟合季节模型。0.40(Stata语句)AutocorrelationsofS12Dp1期.generateS12Dp=S12.Dp.labelvariableS12Dp12stepsofthedifference.acS12Dp=-0.60-0.40-0.200.000.2012010期20Lag3040Bartlett'sformulaforMA(q)95%confidencebands{S12Dp}的自相关图1期0.40.pacS12DpPartialautocorrelationsofS12Dp13期=0.00-0.200.20-0.4024期36期012期10-0.6020Lag304095%Confidencebands[se=1/sqrt(n)]{S12Dp}的偏自相关图①加法季节模型̂ⅰρ̂k1阶12阶截尾∅kk拖尾,结合疏系数模型,对序列{S12Dp}拟合MA(1,12)模型̂ⅱρ̂k拖尾∅kk1阶12阶(13阶)截尾,结合疏系数模型,对序列{S12Dp}拟合AR(1,12)或AR(1,12,13)模型̂ⅲ综合考虑ρ̂,对序列{S12Dp}拟合k和∅kk几阶截尾的性质(哪几期延迟期数对应的相关系数特别明显)ARIMA((1,12)(1,12))模型ⅰ对序列{S12Dp}拟合MA(1,12)模型或者(Stata语句).arimaS12Dp,ma(1,12)=去掉截距项.arimaS12Dp,noconstantma(1,12)=.predictehat3,residual.wntestqehat3Portmanteautestforwhitenoise---------------------------------------Portmanteau(Q)statistic=62.1168Probchi2(40)=0.0141Q统计量的P值α,拒绝原假设,认为残差列非纯随机,序列{S12Dp}中还有信息未提取完毕,建模失败ⅱ对序列{S12Dp}拟合AR(1,12)或AR(1,12,13)模型.arimaS12Dp,noconstantar(1,12).predictehat4,residual(13missingvaluesgenerated).wntestqehat4Portmanteautestforwhitenoise---------------------------------------Portmanteau(Q)statistic=68.0750Probchi2(40)=0.0037失败.arimaS12Dp,ar(1,12,13)在wntestq时也失败了ⅲ对序列{S12Dp}拟合ARIMA((1,12)(1,12))

1 / 20
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功