您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 管理学资料 > 王燕时间序列分析第四章SAS程序
第三章20题datayx_320;inputx@@;t=intnx('quarter','1jul1971'd,_n_-1);formattyyq4;cards;63.267.955.849.550.255.449.945.348.161.755.253.149.559.930.630.433.842.135.828.432.944.145.536.639.549.848.82937.334.247.637.339.247.643.94951.260.86748.965.465.467.662.555.149.657.347.345.544.54847.949.148.859.451.651.460.960.956.858.662.16460.364.67179.459.983.475.480.255.958.565.269.559.121.562.5170-47.462.26033.135.343.442.758.434.4;procgplotdata=yx_320;plotx*t=1;symbol1c=redi=joinv=circle;run;procarimadata=yx_320;identifyvar=xnlag=12;run;identifyvar=xnlag=12minicp=(0:6)q=(0:6);run;estimatep=1q=3;run;estimatep=1q=2noint;run;forecastlead=5id=tout=yx_320;run;procgplotdata=yx_320;plotx*t=1forecast*t=2l95*t=3u95*t=3/overlay;symbol1c=balcki=nonev=star;symbol2c=redi=joinv=none;symbol3c=bluei=joinv=nonel=32;run;(1)时序图:x-1000100200t40005000600070008000900010000110001200013000通过时序图可以判断,此时间序列平稳。检验结果显示,在各阶延迟下,LB检验统计量的P值都很小,均小于0.05。因而可以认为此时间序列为非纯随机数列。通过ACF图和PACF图可以判断为ARMA模型。(2)由此分析结果可知,相对最优模型为ARMA(1,3)。以此结果作为参考,进行下一步的模型参数估计。由分析结果可知,θ2,φ1不显著,故再次估计未知参数的结果。通过多次估计调整,将模型调整为ARMA(1.2),并去掉常数项,进行估计,得到如下结果:可以看出3个参数均显著,P值均远小于0.01。延迟各阶的LB统计量的P值均大于α=0.01,因而认为该拟合模型显著成立。从而可以得到拟合模型的形式;Xt=εt-1.01775εt-1+0.35655εt-2(3)x-1000100200t40005000600070008000900010000110001200013000第四章5题datayx_45;inputx@@;t=1949+_n_-1;cards;5416755196563005748258796602666146562828646536599467207662076585967295691727049972538745427636878534806718299285229871778921190859924209371794974962599754298705100072101654103008104357105851107507109300111026112704114333115823117171118517119850121121122389123626124761125786126743127627128453129227129988130756131448132129132802;procgplotdata=yx_45;plotx*t=1;symbolc=orangei=nonev=circle;run;procautoregdata=yx_45;modelx=t;outputout=yx_45p=xcap;procgplotdata=yx_45;plotx*t=2xcap*t=3/overlay;symbol2c=bluei=nonev=circle;symbol3c=redi=joinv=none;run;procforecastdata=yx_45method=stepartrend=2lead=5out=outoutfulloutest=est;idt;varx;run;绘制出此时间序列的时序图,直观判断为一次线性模型,即xt=a+btx5000060000700008000090000100000110000120000130000140000t19401950196019701980199020002010由分析结果可知,模型的R2=0.9931很高,结合模型的拟合效果图,可以判断模型拟合较好。参数估计值对应的P值都很小(均小于0.0001),远小于α=0.05,因而认为显著。可得到拟合的模型:Xt=-2770828+1449tx5000060000700008000090000100000110000120000130000140000t19401950196019701980199020002010预测结果:第四章6题(将第一个数据视为t=1期)datayx_46;inputx@@;t=1+_n_-1;t2=t**2;cards;73675376377577578379481382382682983183083885487288290391993792796297599510011013102110281027104810701095111311431154117311781183120512081209122312381245125812781294131413231336135513771416143014551480151415451589163416691715176018121809182818711892194619832013204520482097214021712208227223112349236224422479252825712634268427902890296430853159323733583489358836243719382139344028412942054349446345984725482749395067523154085492565358285965;procgplotdata=yx_46;plotx*t=1;symbol1c=purplei=nonev=circle;run;procreg;modelx=tt2;outputout=yx_46p=xcap;procgplotdata=yx_46;plotx*t=2xcap*t=3/overlay;symbol2c=bluei=nonev=star;symbol2c=redi=joinv=none;run;通过此时间序列的时序图直观判断为二次线性回归模型,即xt=a+bt+ct2。x0100020003000400050006000t0102030405060708090100110120由分析结果可知,模型的𝑅̅2=0.9814很高,结合模型的拟合效果图,可以判断模型拟合较好。参数估计值对应的P值都很小(均小于0.0001),远小于α=0.05,因而认为显著。可得到拟合的模型:Xt=1116.85954-23.826t+0.52728t2x0100020003000400050006000t0102030405060708090100110120第四章7题datayx_47;inputx@@;t=intnx('month','1jan1962'd,_n_-1);formattyear4.;cards;589561640656727697640599568577553582600566653673742716660617583587565598628618688705770736678639604611594634658622709722782756702653615621602635677635736755811798735697661667645688713667762784837817767722681687660698717696775796858826783740701706677711734690785805871845801764725723690734750707807824886859819783740747711751;procgplotdata=yx_47;plotx*t=1;symbol1c=coralv=stari=join;run;procx11data=yx_47;monthlydate=t;varx;outputout=outb1=xd10=seasond11=adjustd12=trendd13=irr;dataout;setout;estimate=trend*season/100;procgplotdata=out;plotx*t=2estimate*t=3/overlay;plotseason*t=3adjust*t=3trend*t=3;symbol2c=redi=joinv=star;symbol3c=greeni=joinv=nonew=2l=3;run;x500600700800900t1962196219631963196419641965196519661966196719671968196819691969197019701971绘制出此时间序列的时序图,直观判断为非线性模型,通过时序图可以判断,奶牛的产奶量随月份的变化而变化,每12个月呈现为一个周期,并整体呈现上升趋势。我们可以认为产奶量的变化主要受三个因素的影响,一个是长期趋势,一个是季节效应,另一个是随机波动。而且周期的振幅并未随着产奶量的增加而加大,因为认为季节与趋势之间没有相互关系,因而可以尝试加法模型,即xt=Tt+St+It。用SAS处理后,结果不显著,因而改用乘法模型,即xt=TtStIt。经SAS处理后,乘法模型显著,处理结果如下:123456789101112196258956164065672769764059956857755358219636005666536737427166606175835875655981964628618688705770736678639604611594634196565862270972278275670265361562160263519666776357367558117987356976616676456881967713667762784837817767722681687660698196871769677579685882678374070170667771119697346907858058718458017647257236907341970750707807824886859819783740747711751月平均758.25720.25819.375840910.5881.25823.125776.75734.75740.75712.125753.875总平均789.25季节指数0.9607220.9125751.0381691.0643021.1536271.1165661.042920.9841620.9309470.9385490.9022810.955179季节指数图通过季节指数图可以看出,5月份的季节指数最大,说明5月份奶牛的产奶量最高,11月份的季节指数最小,说明11月份的奶牛产奶量最小,8月份的奶牛产奶量最接近于年平均奶牛产奶量。消除季节影响后得到如下序列Xt/St1234567891011121962
本文标题:王燕时间序列分析第四章SAS程序
链接地址:https://www.777doc.com/doc-4893250 .html