之前写过一个arima模型代码
你看看
data jiangxi_popula;
input year renkou;
label renkou="人口数" year="年份";
cards;
1978 3182.82
1979 3228.98
1980 3270.2
1981 3303.92
1982 3348.35
1983 3394.5
1984 3457.89
1985 3509.8
1986 3575.76
1987 3632.31
1988 3683.88
1989 3746.22
1990 3810.64
1991 3864.64
1992 3913.09
1993 3966.04
1994 4015.45
1995 4062.54
1996 4105.46
1997 4150.33
1998 4191.21
1999 4231.17
2000 4148.54
2001 4185.77
2002 4222.43
2003 4254.23
2004 4283.57
2005 4311.24
2006 4339.13
2007 4368.41
2008 4400.10
2009 4432.16
2010 4462.25
2011 4488.44
2012 4503.93
2013 4522.15
;
run;
data jiangxi_popula_model;
set jiangxi_popula;
where year le 2009;
run;
proc gplot data=jiangxi_popula_model;
/*title "江西人口历年数据";*/
plot renkou*year;
symbol i=spline v=start c=red;
run;
/*检查其平稳性检验不通过 差分*/
proc arima data=jiangxi_popula_model;
identify var=renkou stationarity=(adf=1);
run;
data jiangxi_popula_dif2;
set jiangxi_popula_model;
z=renkou;
difz=dif(z);
difz2=dif(difz);
label z="人口数据" difz="人口数据一阶差分" difz2="人口数据二阶差分";
run;
/*检查其平稳性*/
proc gplot data=jiangxi_popula_dif2;
plot z*year;
plot difz*year;
plot difz2*year;
symbol i=spline v=star ci=red cv=bib;
run;
proc arima data=jiangxi_popula_dif2;
identify var=difz stationarity=(adf=1);
run;
/*人口数据二阶差分的白噪声检验 若检验通过则建立模型
建立模型例子如下 以下是差分后假设数据通过白噪声检验的建模步骤*/
proc arima data=jiangxi_popula_dif2;
identify var=difz2 stationarity=(adf=1);
run;
/*bic定阶 模型最优识别*/
proc arima data=jiangxi_popula_dif2;
identify var=difz2 minic perror=(8:11);
run;
/*预测五年的数据*/
proc arima data=jiangxi_popula_dif2;
identify var=z(2) nlag=4;
estimate q=1;
forecast lead=9 out=outvalue id=year;
run;
data forexport;
set outvalue;
fortotal=forecast;
label z="人口";
put fortotal;
run;
/*图形*/
proc gplot data=forexport;
plot z*year fortotal*year/overlay;
symbol1 i=spline v=star c=red;
symbol2 i=spline v=circle c=green ;
run;
data xx1(keep=year active active_model per );
set xx;
active_model=1000*model;
err=abs(active-active_model);
per=err/active;
format per percent8.2;
run;
data outvalue_1(keep=year z FORECAST RESIDUAL per);
set outvalue;
where RESIDUAL ne .;
RESIDUAL=abs(RESIDUAL);
per=RESIDUAL/z;
format per percent8.2;
run;


雷达卡








京公网安备 11010802022788号







