A nonstationary model for output gap with a const in drift

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

initval

block, which gives just the starting values for the steady state finding. Rather, you need to provide a “steady state” via the

steady_state_model

block and make sure that the correctness of the “steady state” is not checked via the nocheck option. The diffuse filter is needed because of the initial conditions when you use a unit root process. I tried

%  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