📄 arf_d.m
字号:
% PURPOSE: An example of using arf(), % to produce ar-model forecasts %---------------------------------------------------% USAGE: arf_d%---------------------------------------------------load test.dat; % a test data set containing % monthly mining employment for % il,in,ky,mi,oh,pa,tn,wv% data covers 1982,1 to 1996,5vnames = strvcat('il'); y = test(:,1); % illinois employment[nobs junk] = size(y);nfor = 12; % number of forecast periodsnlag = 6; % number of lags in var-modelbegf = nobs-nfor+1; % beginning forecast period% no data transformation examplefcasts = arf(y,nlag,nfor,begf);actual = y(begf:begf+nfor-1,1);fprintf(1,'actual mining employment \n');for i=1:nforfprintf(1,'%12s ',tsdate(1982,1,12,begf+i-1));fprintf(1,'%8.2f ',actual(i,1));fprintf(1,'\n');end;fprintf(1,'AR model in levels estimated \n');fprintf(1,'forecast of mining employment \n');for i=1:nforfprintf(1,'%12s ',tsdate(1982,1,12,begf+i-1));fprintf(1,'%8.2f ',fcasts(i,1));fprintf(1,'\n');end;% seasonal differences data transformation examplefreq = 12; % set frequency of the data to monthlyfcasts = arf(y,nlag,nfor,begf,freq);fprintf(1,'AR model with seasonally differenced data estimated \n');fprintf(1,'forecast of mining employment \n');for i=1:nforfprintf(1,'%12s ',tsdate(1982,1,12,begf+i-1));fprintf(1,'%8.2f ',fcasts(i,1));fprintf(1,'\n');end;% 1st differences data transformation examplefcasts = arf(y,nlag,nfor,begf,1);fprintf(1,'AR model with 1st differenced data estimated \n');fprintf(1,'forecast of mining employment \n');for i=1:nforfprintf(1,'%12s ',tsdate(1982,1,12,begf+i-1));fprintf(1,'%8.2f ',fcasts(i,1));fprintf(1,'\n');end;% growth-rates data transformation examplecstruc = cal(1982,1,12); % set up calendar structurefcasts = arf(y,nlag,nfor,begf,cstruc);fprintf(1,'AR model with growth-rates data estimated \n');fprintf(1,'forecast of mining employment \n');for i=1:nforfprintf(1,'%12s ',tsdate(1982,1,12,begf+i-1));fprintf(1,'%8.2f ',fcasts(i,1));fprintf(1,'\n');end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -