Local linear trend estimation

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Local linear trend estimation

Postby Dynaresaur » Wed Nov 11, 2015 11:49 am

I’m trying to familiarise myself with estimating Unobserved Component models with Dynare. As an exercise I am trying to simulate and estimate simple models that would normally be used for output gap estimation. Below are 2 sample model blocks for models V1 and V2 respectively. V2 is a standard local linear trend (eg see Harvey and Jaeger 1993)

// 1. Model equations V1
Y = T + eps_1;
T = T(-1) + eps_2;
end;

// 1. Model equations V2
Y = T + eps_1;
T = T(-1) + 1*d(-1) + eps_2;
d = d(-1) + eps_3;
end;

The simulation all works fine. For estimation however, when I go from model V1 to model V2, the parameters (eps_1, eps_2 and eps_3) are successfully estimated, but I get the below error (note that this occurs on the last line of dynare.m).

Any thoughts what could be causing the problem after such a simple change to the model? Note also that if I change the coeffient on d(-1) in the T equation to 0.5 the error is no longer displayed.

Many thanks,
Dynaresaur

----------------------------

“Error using +
Matrix dimensions must agree.

Error in missing_DiffuseKalmanSmootherH1_Z (line 128)
a(:,:,t+1) = T*(a(:,:,t)+Kstar(:,:,t)*v(:,t));

Error in DsgeSmoother (line 164)
[alphahat,epsilonhat,etahat,ahat,P,aK,PK,decomp] = missing_DiffuseKalmanSmootherH1_Z(ST, ...

Error in dynare_estimation_1 (line 920)
[atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp] =
DsgeSmoother(xparam1,dataset_.info.ntobs,dataset_.data,dataset_.missing.aindex,dataset_.missing.state);

Error in dynare_estimation (line 70)
dynare_estimation_1(var_list,dname);

Error in UC_HP_filter_replic_v15a (line 116)
dynare_estimation(var_list_);

Error in dynare (line 120)
evalin('base',fname) ;”
Dynaresaur
 
Posts: 6
Joined: Mon Nov 09, 2015 11:04 am

Re: Local linear trend estimation

Postby jpfeifer » Wed Nov 11, 2015 4:03 pm

Please provide the mod-file.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Local linear trend estimation

Postby Dynaresaur » Mon Nov 16, 2015 12:09 pm

Dear Prof Pfeifer, Thanks for your response and apologies for my delayed reply.

I resolved the stated issue by re-writing the model as follows, where Dd = d - d(-1):

// 1. Model equations V2
Y = T + eps_1;
(T-T(-1))-(T(-1)-T(-2))= Dd(-1) + eps_2-eps_2(-1);
Dd = eps_3;

Am not sure why this works -- perhaps Dynare doesn't like having both I(1) and I(2) variables in the model?

Following on from this, I have augmented the model by modelling the cycle as an AR(2) (see code below). This creates a further problem: the estimates of the autoregressive parameters are quite far off from the paramter values used to generate the data (r1=0.2 and r2=0.1). The mode check plots suggest this relates to stability issues. Note that if I model the cycle as an AR(1) process, the estimation goes through fine.

Any thoughts that could shed light on what's happening here would be much appreciated.

Many thanks,
D


-------------------------------------------------------------------


// 0. Variable definitions
var T Y Dd C;
varexo eps_1 eps_2 eps_3;

parameters s1 s2 s3 r1 r2;
s1 = 0.1;
s2 = 0.1;
s3 = 0.1;
r1 = 0.2;
r2 = 0.1;

model;

// 1. Model equations
Y = T + C;
C = r1*C(-1) + r2*C(-2) + eps_1;
(T-T(-1))-(T(-1)-T(-2))= Dd(-1) + eps_2-eps_2(-1);
Dd = eps_3;
end;

// 2. Steady-state
steady_state_model;
T = 1;
Y = 1;
Dd=0;
C = 0;
end;


// 3.1 Simulation

shocks;
var eps_1;
stderr s1;
var eps_2;
stderr s2;
var eps_3;
stderr s3;
end;


stoch_simul(periods=2501, order=1, nograph);
save obs_data Y;
/*
*/

//3.2 ML Estimation

estimated_params;
stderr eps_1, 0.09, 0, 1;
stderr eps_2, 0.09, 0, 1;
stderr eps_3, 0.09, 0, 1;
r1, 0.1, 0, 0.99;
r2, 0.1, 0, 0.99;
end;

varobs Y;

/*
observation_trends;
Y (0);
end;
*/

estimation(datafile=obs_data, presample=1, first_obs=1, mode_compute=4, mode_check, diffuse_filter);
Dynaresaur
 
Posts: 6
Joined: Mon Nov 09, 2015 11:04 am

Re: Local linear trend estimation

Postby Dynaresaur » Mon Nov 16, 2015 5:55 pm

UPDATE

----------------------

I tried to resolve the above AR(2) instability issue using the nice approach laid out in this post: viewtopic.php?f=1&t=2470

This seems to work if I only estimate the AR coefficients. However, when I attempt to estimate the variances in addition then estimates of the AR coefficents (calculated indirectly from the roots) are no longer close to the values used in the simulation.

Code is copied below. Any insight would be much appreciated.

-----------------------------------


var C Y T Dd;
varexo eps_1 eps_2 eps_3;

parameters root1 root2;

//rho1=1.5;
//rho2=-0.6;
root1=0.95; //root1=1.5/2+sqrt((1.5/2)^2+(-0.6))
root2=0.55; //root1=1.5/2-sqrt((1.5/2)^2+(-0.6))

model;
// parameter conversion
# rho1= (root1+root2);
# rho2= - root1*root2;

// model equation
Y = T + C;
C = rho1*C(-1)+rho2*C(-2)+ eps_1;
(T-T(-1))-(T(-1)-T(-2))= Dd(-1) + eps_2-eps_2(-1);
Dd = eps_3;
end;

// 2. Steady-state
steady_state_model;
T = 1;
Y = 1;
Dd=0;
C = 0;
end;


shocks;
var eps_1; stderr 0.1;
var eps_2; stderr 0.1;
var eps_3; stderr 0.1;
end;





stoch_simul(periods=2501, order=1);
save d_obs Y;


//3.2 ML Estimation

estimated_params;
stderr eps_1, 0.01, 0, 1;
stderr eps_2, 0.01, 0, 1;
//stderr eps_3, 0.01, 0, 1;
root1, 0.95, -0.9999, 0.9999;
root2, 0.55, -0.9999, 0.9999;
end;

varobs Y;

estimation(datafile=d_obs, presample=4, first_obs=1, mode_compute=4, mode_check, diffuse_filter); // simulated data (MLE)
Dynaresaur
 
Posts: 6
Joined: Mon Nov 09, 2015 11:04 am

Re: Local linear trend estimation

Postby Dynaresaur » Tue Nov 17, 2015 11:44 am

Since the second issue I have encountered is different from the one mentioned in the original post I have reposted it here viewtopic.php?f=1&t=2470&p=22146#p22146 so that all the material related to AR(2) stability problems is in one place.
Dynaresaur
 
Posts: 6
Joined: Mon Nov 09, 2015 11:04 am

Re: Local linear trend estimation

Postby jpfeifer » Tue Nov 17, 2015 1:46 pm

There is an identification issue as outlined in my response to the linked post above.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Local linear trend estimation

Postby jpfeifer » Wed Nov 18, 2015 10:23 am

Could you please try the original model with the unstable version of Dynare and see whether you get the same crash. If yes, please provide me with the mod-file that crashes.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Local linear trend estimation

Postby Danman » Thu Apr 14, 2016 11:19 am

With regards to the first message in this chain, isn't the problem in line 128 where the matrix "a" is referred to as though it is three dimensional whereas it was originally defined as a two dimensional (mm, smpl+1) matrix?
Danman
 
Posts: 3
Joined: Thu Apr 14, 2016 11:15 am

Re: Local linear trend estimation

Postby jpfeifer » Thu Apr 14, 2016 11:49 am

------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 9 guests