A nonstationary model for output gap with a const in drift

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.

A nonstationary model for output gap with a const in drift

Postby gin » Thu Jan 26, 2017 10:18 am

Dear all,

I want to estimate a gap-model in levels with a stochastic trend that includes a constant in the drift, particularly:

Code: Select all
% trend
mmu   = mmu(-1)  +  bbeta(-1)   + e_lev;
% drift
bbeta      =     rrho*bbeta(-1) + (1-rrho)*bbeta_const    + e_slp;
% cycle
 car      =   pphi1*car(-1) + pphi2*car(-2)   + e_cyc;
% measurement
ym1      =    mmu(-1)  +   car(-1)   + e_irr;
trend =  mmu(-1);
cycle = car(-1);


Note that I have no problem with the version where the drift is a random walk without a drift, i.e., rrho=1. However, I want to have more control over the trend growth rate and thus work with the version where 0<=rrho<1. I have this version in Eviews up and running. But I could not get Dynare run it. I use diffuse_filter option and tried steady(nocheck) with various initial values but Dynare spits errors about computing the initial likelihood and/or steady states.

The code attached.
Attachments
gap_model.zip
(88.43 KiB) Downloaded 56 times
-------------------------
gin
http://gin.mozello.com
gin
 
Posts: 47
Joined: Wed Feb 27, 2013 3:10 pm
Location: Riga, Latvia

Re: A nonstationary model for output gap with a const in dri

Postby jpfeifer » Fri Jan 27, 2017 8:47 am

The problem is that Dynare tries to approximate around the steady state, which does not exist if there is a drift. But as the model is already linear, the approximation point does not really matter. For that reason, you cannot use an
Code: Select all
initval

block, which gives just the starting values for the steady state finding. Rather, you need to provide a "steady state" via the
Code: Select all
steady_state_model
block and make sure that the correctness of the "steady state" is not checked via the
Code: Select all
nocheck
option. The diffuse filter is needed because of the initial conditions when you use a unit root process. I tried
Code: Select all
%  gin2017

%----------------------------------------------------------------
% 1. Model variables and parameters
%----------------------------------------------------------------

var      bbeta      
      mmu      
      car
      ym1
        trend
        cycle;

varexo      e_irr      
      e_lev      
      e_slp      
      e_cyc      
        ;

parameters   
        rrho   
        bbeta_const
      pphi1
        pphi2   
        sig_e_irr sig_e_lev sig_e_slp sig_e_cyc
        ;


%----------------------------------------------------------------
% 2. Calibration
%----------------------------------------------------------------

rrho      = 0;
bbeta_const= 0.0075;
pphi1      = 1.100;
pphi2      = -0.300;

% std of shocks
sig_e_irr=  0.003;
sig_e_lev=  .23; %.5;
sig_e_slp=  0; % 5
sig_e_cyc=   1; % normalize

%----------------------------------------------------------------
% 3. Model
%----------------------------------------------------------------

model(linear);


%%%%% STOCHASTIC TREND AND SLOPE %%%%%

mmu   = mmu(-1)  +  bbeta(-1)   + e_lev/1000 ;
bbeta      =     rrho*bbeta(-1) + (1-rrho)*bbeta_const    + e_slp/100;
car      =   pphi1*car(-1) + pphi2*car(-2)   + e_cyc;

%%%%% MEASUREMENT EQUATION %%%%%

ym1      =    mmu(-1)  +   car(-1)   + e_irr;
trend =  mmu(-1);
cycle = car(-1);
end;


steady_state_model;
mmu = 7.8;
ym1=7.8;
bbeta = bbeta_const;
car = 0;
trend = 7.8;
cycle=0;
end;

steady(nocheck);
 

%  initval;
%  mmu = 7.75;
% // bbeta = 0;
% car = 0.03;
%  end;



%check;
 
shocks;

var e_irr = sig_e_irr^2;
var e_lev = sig_e_lev^2;
var e_slp=sig_e_slp^2;
var e_cyc=sig_e_cyc^2;

end;


%----------------------------------------------------------------
% 4. Estimated parameters and data
%----------------------------------------------------------------
%%%%% PARAMETERS %%%%%
estimated_params;
    rrho, .9359,   beta_pdf,       0.85, 0.075;
     pphi1,   .2,   beta_pdf,       0.2, 0.075;
     pphi2,   .2,   beta_pdf,       0.2, 0.075;

%%%%% INNOVATIONS %%%%%

 stderr   e_irr, .38,     inv_gamma_pdf,  0.5, inf;
 stderr   e_lev,   .5,   inv_gamma_pdf,  0.5, inf;
 stderr   e_slp,   .5,   inv_gamma_pdf,  0.5, inf;
 stderr   e_cyc,   .5,   inv_gamma_pdf,  .5, inf;
end;

%
% Observed variables
%

varobs ym1;      

%----------------------------------------------------------------
% 5. Bayesian estimation and forecasting
%----------------------------------------------------------------
options_.console_mode=1; %(default: 0)

estimation   (datafile = lv_gdp_data, graph_format = pdf,
      nodiagnostic, diffuse_filter,
        mh_drop=.5,  mh_jscale=0.2,
        mh_replic = 0,
        mh_nblocks = 2, filtered_vars, smoother,
      mode_compute = 4, plot_priors = 1,
      forecast = 0
      ) trend cycle;

%----------------------------------------------------------------
% 6. Reporting
%----------------------------------------------------------------

verbatim;

lv_gdp_data;
% if laplace only
% smoothed
eval([ 'trend_    = oo_.SmoothedVariables.trend'   ';' ]);
eval([ 'cycle_    = oo_.SmoothedVariables.cycle'   ';' ]);
eval([ 'irreg_    = oo_.SmoothedShocks.e_irr' ';' ]);

% %filtered
% eval([ 'trend_f    = oo_.FilteredVariables.trend'   ';' ]);
% eval([ 'cycle_f    = oo_.FilteredVariables.cycle'   ';' ]);
% trend_f(trend_f==0)=nan;
% cycle_f(cycle_f==0)=nan;

figure(1)
plot(ym1,'black')
hold on;
plot(trend_,'red')
hold off;
figure(2)
plot(cycle_)

end;

and it seems to work OK
------------
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: A nonstationary model for output gap with a const in dri

Postby gin » Fri Jan 27, 2017 6:02 pm

Danke, again.
-------------------------
gin
http://gin.mozello.com
gin
 
Posts: 47
Joined: Wed Feb 27, 2013 3:10 pm
Location: Riga, Latvia

Re: A nonstationary model for output gap with a const in dri

Postby gin » Thu Feb 02, 2017 10:35 am

In this case (a linear, nonstationary gap-model), what would be the easiest way to initialize the Kalman filter at specific starting values of endogenous variables different from their steady states? I think of a gap-process whose ss is zero but it can be far from the ss at the first observation. It seems adding the
Code: Select all
initval;
block after the
Code: Select all
steady_state_model;
block has no effect. The code attached.

Code: Select all
var               
      ym1
        trend
        cycle;

varexo            
      e_tr            
      e_cyc         
        ;

parameters      
        drift
      phi
        sig_e_tr
        sig_e_cyc
        ;

drift = 3/4; % 3 percent per year
phi      = 0.7;
% std of shocks
sig_e_tr=  .5;
sig_e_cyc=   1;


model(linear);
% trend
trend       =    trend(-1)  + drift + e_tr;
% cycle
 cycle      =   phi*cycle(-1) + e_cyc;
% measurement eq-n
100*ym1      =    trend  +   cycle;
end;

steady_state_model;
 trend = 778.9; %775.9; %778.9;
 cycle = 0; %3; % 0;
 ym1 = 7.7890;
end;

steady(nocheck);

initval;
trend = 775.9;
cycle = 3;
ym1 = 7.7890;
end;

shocks;
var e_tr = sig_e_tr^2;
var e_cyc=sig_e_cyc^2;
end;


% estimated_params;

%    phi,   .7,   beta_pdf,       0.7, 0.075;

% stderr   e_tr,   .5,   inv_gamma_pdf,  0.5, inf;
% stderr   e_cyc,   1,   inv_gamma_pdf,  1, inf;

% end;

varobs ym1;      

options_.console_mode=1; %(default: 0)

estimation   (datafile = lv_gdp_data, nodisplay, graph_format = pdf,
      nodiagnostic, diffuse_filter,
%         kalman_algo = 1,
%         lik_init=2,
        mh_drop=.5,  mh_jscale=0.2,
        mh_replic = 0,
        mh_nblocks = 2, filtered_vars, smoother,
      mode_compute = 0, plot_priors = 1,
      forecast = 0
      ) trend cycle;
Attachments
gap_model.zip
(88.06 KiB) Downloaded 40 times
-------------------------
gin
http://gin.mozello.com
gin
 
Posts: 47
Joined: Wed Feb 27, 2013 3:10 pm
Location: Riga, Latvia

Re: A nonstationary model for output gap with a const in dri

Postby jpfeifer » Fri Feb 03, 2017 9:54 am

With the diffuse_filter the diffuse initialization should take care of the fact that you can be far away from the steady state as the forecast error in the first period does not enter the likelihood. You can see this when you change the steady state value for ym1. This will change the deviation of the data from the steady state in the first period, but will not affect the likelihood.
------------
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: A nonstationary model for output gap with a const in dri

Postby gin » Tue Feb 07, 2017 4:22 pm

The one-side filtered gap (oo_.FilteredVariables.cycle) indicates that Dynare initializes the gap at zero, whereas I want another specific initial point for the gap (e.g. a 3%) while having its steady state at zero.

Changing steady states for the trending variables does not help. E.g. if
Code: Select all
steady_state_model;
 trend = 775.9; 
 cycle = 0; 
 ym1 =  7.7890;
end;

then the initial point of the trend is 3% lower than the observable, but it also stays about 3% lower over the whole sample, meaning that the implied filtered gap (the observed variable minus the filtered trend) is shifted upwards over the whole sample.

If the steady states for both the trend and ym1 are lowered by 3%:
Code: Select all
steady_state_model;
 trend = 775.9; 
 cycle = 0; 
 ym1 =  7.7590;
end;

then the first observation of the implied filtered gap (the observed variable minus the filtered trend) is 3 but it vanishes to zero already in the second observation.

Also, in both cases the initial observation of the directly filtered gap (oo_.FilteredVariables.cycle) is zero and its filtered values differ by a lot from the implied filtered gap (the observed variable minus the filtered trend) over the whole sample, which to me is weird, as I expect both the directly and indirectly filtered gaps to coincide.
-------------------------
gin
http://gin.mozello.com
gin
 
Posts: 47
Joined: Wed Feb 27, 2013 3:10 pm
Location: Riga, Latvia

Re: A nonstationary model for output gap with a const in dri

Postby jpfeifer » Tue Feb 07, 2017 9:27 pm

Are you sure you want to look at filtered variables, i.e. E_t(y_t+1)? The decomposition you have in mind seems to rely on updated variables E_t(y_t). [I know the naming is less than ideal.]
------------
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: A nonstationary model for output gap with a const in dri

Postby gin » Wed Feb 08, 2017 8:38 am

Pardon, updated variables. So, please ignore the last point - the two are the same.

But otherwise the issue remains - the updated gap starts at zero unless its steady state is nonzero. However, a practitioner often knows where the gap should be at the start of the sample and thus wants to direct the Kalman filter by setting initial values. So, is there a way to initialize the gap at a specific value other than its zero steady state? I wouldn't bother if it wasn't so easy to achieve in Eviews.
-------------------------
gin
http://gin.mozello.com
gin
 
Posts: 47
Joined: Wed Feb 27, 2013 3:10 pm
Location: Riga, Latvia

Re: A nonstationary model for output gap with a const in dri

Postby jpfeifer » Fri Feb 10, 2017 9:30 am

Dear Ginters,
I am working on it and will keep you updated.
------------
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