- data p;
- format year1 yymmdd10.;
- input
- year1 :yymmdd10.
- / k_likelihood;
- cards;
- 2002/11/10
- 3.05796189
- 2003/11/10
- 2.83128728
- 2004/11/10
- 2.56487122
- 2005/11/10
- 1.87106964
- 2006/11/10
- 2.13975211
- 2007/11/10
- 0.8112924
- 2008/11/10
- 0.02282331
- 2009/11/10
- -0.1704331
- 2010/11/10
- -0.4598498
- 2011/11/10
- -0.7117507
- 2012/11/10
- -1.6526958
- 2013/11/10
- -2.0288599
- 2014/11/10
- -2.4791082
- 2015/11/10
- -2.6726061
- 2016/11/10
- -3.1237542
- ;
- run;
- proc template;
- define statgraph Ets.Arima.Graphics.ForecastPlot;
- dynamic title ConfidenceLabel integerTime variable PlotAct lead horizon
- printall _byline_ _bytitle_ _byfootnote_;
- BeginGraph;
- EntryTitle TITLE / pad=(bottom=5) TEXTATTRS=(size=10);/*改title字体大小*/
- Layout Overlay / YAXISOPTS=(display=all TICKVALUEATTRS=(size=10) LABELATTRS=(size=10) Label=
- "Forecast") XAxisOpts=(display=all TICKVALUEATTRS=(size=10) LABELATTRS=(size=10) linearopts=
- (Integer=INTEGERTIME));/*改tickvalue、label字体大小*/
- BandPlot limitlower=LOWERCL limitupper=UPPERCL x=TIME / display=(
- fill) fillattrs=GRAPHCONFIDENCE datatransparency=0.5 name=
- "Conf" LegendLabel=CONFIDENCELABEL;
- if (PLOTACT > 0)
- ScatterPlot x=TIME y=ACTUAL / markerattrs=GRAPHDATADEFAULT name
- ="Actual" legendlabel="Actual";
- endif;
- if (PRINTALL)
- if (LEAD > 0)
- ReferenceLine x=HORIZON / lineattrs=GRAPHREFERENCE (pattern=
- dash) name="Vline" legendlabel=
- "Start of multi-step forecasts";
- endif;
- endif;
- SeriesPlot x=TIME y=FORECAST / primary=true lineattrs=GRAPHFIT (
- Thickness=1px) name="Predicted" legendlabel="Predicted";
- DiscreteLegend "Actual" "Predicted" "Conf" "Vline" / valueATTRS=(size=10);/*改legend字体大小*/
- EndLayout;
- if (_BYTITLE_)
- entrytitle _BYLINE_ / textattrs=GRAPHVALUETEXT;
- else
- if (_BYFOOTNOTE_)
- entryfootnote halign=left _BYLINE_;
- endif;
- endif;
- EndGraph;
- end;
- run;
- proc arima data=p plots(only)=(forecast(forecast));
- /*预测,残差p>0.05,模型的价值已提取完毕*/
- identify var=k_likelihood(1);/*进行一阶差分,nlag=6*/
- estimate p=0 q=0 method=ml;
- forecast lead=10 id=year1 interval=year out=f1;
- run;
- quit;