⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bvarf_d.m

📁 计量工具箱
💻 M
字号:
% PURPOSE: An example of using bvarf(), %          to produce bvar-model forecasts                                                 %          (Minnesota prior)                    %---------------------------------------------------% USAGE: bvarf_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,5dates = cal(1982,1,12);y = test;vnames =  ['  il',           '  in',               '  ky',               '  mi',               '  oh',               '  pa',               '  tn',               '  wv'];         nlag = 6;  % number of lags in var-modelbegf = ical(1995,6,dates); % beginning forecast periodnfor = 12; % number of forecast periodsendf = cal(dates,begf+nfor-1); % end of forecast periodtight = 0.1;decay = 0.1;weight = 0.5; % symmetric weights% this is an example of using 1st-order contiguity% of the states as weights as in LeSage and Pan (1995)% `Using Spatial Contiguity as Bayesian Prior Information % in Regional Forecasting Models'' International Regional % Science Review, Volume 18, no. 1, pp. 33-53, 1995.w = [1.0  1.0  1.0  0.1  0.1  0.1  0.1  0.1      1.0  1.0  1.0  1.0  1.0  0.1  0.1  0.1      1.0  1.0  1.0  0.1  1.0  0.1  1.0  1.0      0.1  1.0  0.1  1.0  1.0  0.1  0.1  0.1      0.1  1.0  1.0  1.0  1.0  1.0  0.1  1.0      0.1  0.1  0.1  0.1  1.0  1.0  0.1  1.0      0.1  0.1  1.0  0.1  0.1  0.1  1.0  0.1      0.1  0.1  1.0  0.1  1.0  1.0  0.1  1.0];% no data transformation examplefcasts = bvarf(y,nlag,nfor,begf,tight,weight,decay);actual = y(begf:begf+nfor-1,:);fprintf(1,'actual mining employment \n');for i=1:nforfprintf(1,'%12s ',tsdate(1982,1,12,begf+i-1));for j=1:neqs;fprintf(1,'%8.2f ',actual(i,j));end;fprintf(1,'\n');end;fprintf(1,'BVAR 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));for j=1:neqs;fprintf(1,'%8.2f ',fcasts(i,j));end;fprintf(1,'\n');end;% seasonal differences data transformation examplefreq = 12; % set frequency of the data to monthlyfcasts = bvarf(y,nlag,nfor,begf,tight,weight,decay,[],freq);fprintf(1,'BVAR 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));for j=1:neqs;fprintf(1,'%8.2f ',fcasts(i,j));end;fprintf(1,'\n');end;% 1st differences data transformation examplefcasts = bvarf(y,nlag,nfor,begf,tight,weight,decay,[],1);fprintf(1,'BVAR 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));for j=1:neqs;fprintf(1,'%8.2f ',fcasts(i,j));end;fprintf(1,'\n');end;% growth-rates data transformation examplecstruc = cal(1982,1,12); % set up calendar structurefcasts = bvarf(y,nlag,nfor,begf,tight,weight,decay,[],cstruc);fprintf(1,'BVAR 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));for j=1:neqs;fprintf(1,'%8.2f ',fcasts(i,j));end;fprintf(1,'\n');end;% future forecastbegf = nobs+1;% 1st differences data transformation examplefcasts = bvarf(y,nlag,nfor,begf,tight,weight,decay,[],1);fprintf(1,'BVAR model with 1st differenced data estimated \n');fprintf(1,'FUTURE forecast of mining employment \n');for i=1:nforfprintf(1,'%12s ',tsdate(1982,1,12,begf+i-1));for j=1:neqs;fprintf(1,'%8.2f ',fcasts(i,j));end;fprintf(1,'\n');end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -