Add capacities for rolling window estimation
parent
154980ec8c
commit
f80f0f9258
|
@ -4788,13 +4788,25 @@ the file after @code{first_obs}
|
|||
Runs a recursive estimation and forecast for samples of size ranging
|
||||
of @var{INTEGER1} to @var{INTEGER2}. Option @code{forecast} must
|
||||
also be specified. The forecasts are stored in the
|
||||
@code{RecursiveForecast} field of the results structure (@pxref{RecursiveForecast}). The respective results structures @code{oo_} are saved in @code{oo_recursive_} (@pxref{oo_recursive_}).
|
||||
@code{RecursiveForecast} field of the results structure (@pxref{RecursiveForecast}).
|
||||
The respective results structures @code{oo_} are saved in @code{oo_recursive_} (@pxref{oo_recursive_})
|
||||
and are indexed with the respective sample length.
|
||||
|
||||
@item first_obs = @var{INTEGER}
|
||||
@anchor{first_obs}
|
||||
The number of the first observation to be used. In case of estimating a DSGE-VAR,
|
||||
@code{first_obs} needs to be larger than the number of lags. Default: @code{1}
|
||||
|
||||
@item first_obs = [@var{INTEGER1}:@var{INTEGER2}]
|
||||
@anchor{first_obs1}
|
||||
Runs a rolling window estimation and forecast for samples of fixed size @code{nobs} starting with the
|
||||
first observation ranging from @var{INTEGER1} to @var{INTEGER2}. Option @code{forecast}
|
||||
must also be specified. This option is incompatible with requesting recursive forecasts using an
|
||||
expanding window (@pxref{nobs1,,nobs}). The respective results structures @code{oo_}
|
||||
are saved in @code{oo_recursive_} (@pxref{oo_recursive_}) and are indexed with the respective
|
||||
first observation of the rolling window.
|
||||
|
||||
|
||||
@item prefilter = @var{INTEGER}
|
||||
@anchor{prefilter}
|
||||
A value of @code{1} means that the estimation procedure will demean
|
||||
|
|
|
@ -52,7 +52,15 @@ else
|
|||
nobs = [];
|
||||
end
|
||||
|
||||
first_obs = sort(options_.first_obs);
|
||||
|
||||
nnobs = length(nobs);
|
||||
nfirstobs = length(first_obs);
|
||||
|
||||
if nnobs~=1 && nfirstobs~=1
|
||||
error('You cannot simultaneously do rolling window and recursive estimation')
|
||||
end
|
||||
|
||||
horizon = options_.forecast;
|
||||
|
||||
if nargin<2 || ~exist(dname) || isempty(dname)
|
||||
|
@ -73,10 +81,15 @@ if options_.logged_steady_state
|
|||
end
|
||||
|
||||
|
||||
if nnobs > 1
|
||||
for i=1:nnobs
|
||||
options_.nobs = nobs(i);
|
||||
M_.dname = [dname '_' int2str(nobs(i))];
|
||||
if nnobs>1 || nfirstobs > 1
|
||||
for i=1:max(nnobs,nfirstobs)
|
||||
if nnobs>1
|
||||
options_.nobs = nobs(i);
|
||||
M_.dname = [dname '_' int2str(nobs(i))];
|
||||
elseif nfirstobs>1;
|
||||
options_.first_obs=first_obs(i);
|
||||
M_.dname = [dname '_' int2str(first_obs(i))];
|
||||
end
|
||||
dynare_estimation_1(var_list,M_.dname);
|
||||
if isequal(i,1)
|
||||
options_.mode_file = [M_.fname '_mode'];
|
||||
|
@ -86,7 +99,11 @@ if nnobs > 1
|
|||
dynare_estimation_1(var_list,M_.dname);
|
||||
end
|
||||
end
|
||||
oo_recursive_{nobs(i)} = oo_;
|
||||
if nnobs>1
|
||||
oo_recursive_{nobs(i)} = oo_;
|
||||
elseif nfirstobs>1;
|
||||
oo_recursive_{first_obs(i)} = oo_;
|
||||
end
|
||||
end
|
||||
else
|
||||
dynare_estimation_1(var_list,dname);
|
||||
|
|
|
@ -214,6 +214,7 @@ MODFILES = \
|
|||
stochastic_purely_forward/stochastic_purely_forward.mod \
|
||||
stochastic_purely_forward/stochastic_purely_forward_with_static.mod \
|
||||
forecast/Hansen_exo_det_forecast.mod \
|
||||
forecast/ls2003_rolling_window_forecast.mod \
|
||||
gradient/fs2000_numgrad_13.mod \
|
||||
gradient/fs2000_numgrad_15.mod \
|
||||
gradient/fs2000_numgrad_2.mod \
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
var y y_s R pie dq pie_s de A y_obs pie_obs R_obs;
|
||||
varexo e_R e_q e_ys e_pies e_A;
|
||||
|
||||
parameters psi1 psi2 psi3 rho_R tau alpha rr k rho_q rho_A rho_ys rho_pies;
|
||||
|
||||
psi1 = 1.54;
|
||||
psi2 = 0.25;
|
||||
psi3 = 0.25;
|
||||
rho_R = 0.5;
|
||||
alpha = 0.3;
|
||||
rr = 2.51;
|
||||
k = 0.5;
|
||||
tau = 0.5;
|
||||
rho_q = 0.4;
|
||||
rho_A = 0.2;
|
||||
rho_ys = 0.9;
|
||||
rho_pies = 0.7;
|
||||
|
||||
|
||||
model(linear);
|
||||
y = y(+1) - (tau +alpha*(2-alpha)*(1-tau))*(R-pie(+1))-alpha*(tau +alpha*(2-alpha)*(1-tau))*dq(+1) + alpha*(2-alpha)*((1-tau)/tau)*(y_s-y_s(+1))-A(+1);
|
||||
pie = exp(-rr/400)*pie(+1)+alpha*exp(-rr/400)*dq(+1)-alpha*dq+(k/(tau+alpha*(2-alpha)*(1-tau)))*y+alpha*(2-alpha)*(1-tau)/(tau*(tau+alpha*(2-alpha)*(1-tau)))*y_s;
|
||||
pie = de+(1-alpha)*dq+pie_s;
|
||||
R = rho_R*R(-1)+(1-rho_R)*(psi1*pie+psi2*(y+alpha*(2-alpha)*((1-tau)/tau)*y_s)+psi3*de)+e_R;
|
||||
dq = rho_q*dq(-1)+e_q;
|
||||
y_s = rho_ys*y_s(-1)+e_ys;
|
||||
pie_s = rho_pies*pie_s(-1)+e_pies;
|
||||
A = rho_A*A(-1)+e_A;
|
||||
y_obs = y-y(-1)+A;
|
||||
pie_obs = 4*pie;
|
||||
R_obs = 4*R;
|
||||
end;
|
||||
|
||||
shocks;
|
||||
var e_R = 1.25^2;
|
||||
var e_q = 2.5^2;
|
||||
var e_A = 1.89;
|
||||
var e_ys = 1.89;
|
||||
var e_pies = 1.89;
|
||||
end;
|
||||
|
||||
varobs y_obs R_obs pie_obs dq de;
|
||||
|
||||
estimated_params;
|
||||
psi1 , gamma_pdf,1.5,0.5;
|
||||
psi2 , gamma_pdf,0.25,0.125;
|
||||
psi3 , gamma_pdf,0.25,0.125;
|
||||
rho_R ,beta_pdf,0.5,0.2;
|
||||
alpha ,beta_pdf,0.3,0.1;
|
||||
rr ,gamma_pdf,2.5,1;
|
||||
k , gamma_pdf,0.5,0.25;
|
||||
tau ,gamma_pdf,0.5,0.2;
|
||||
rho_q ,beta_pdf,0.4,0.2;
|
||||
rho_A ,beta_pdf,0.5,0.2;
|
||||
rho_ys ,beta_pdf,0.8,0.1;
|
||||
rho_pies,beta_pdf,0.7,0.15;
|
||||
stderr e_R,inv_gamma_pdf,1.2533,0.6551;
|
||||
stderr e_q,inv_gamma_pdf,2.5066,1.3103;
|
||||
stderr e_A,inv_gamma_pdf,1.2533,0.6551;
|
||||
stderr e_ys,inv_gamma_pdf,1.2533,0.6551;
|
||||
stderr e_pies,inv_gamma_pdf,1.88,0.9827;
|
||||
end;
|
||||
options_.plot_priors=0;
|
||||
estimation(silent_optimizer,datafile='../recursive/data_ca1',first_obs=[8 11],nobs=[76],mh_nblocks=1,prefilter=1,mh_jscale=0.5,mh_replic=2000,forecast=8) y_obs R_obs pie_obs dq de;
|
Loading…
Reference in New Issue