I Need Help On DSGE Estimation
Posted: Mon Jan 05, 2015 6:24 pm
Hello Everyone,
I am Dapomi from the University of Ibadan, Nigeria. I am currently working on 'The of the Interest on Business Cycle in Nigeria'. I am trying to use the DSGE Model using Dynare code on Matlab. However, I am currently try my hand the following code:
var y c k i l y_l w r z;
varexo e;
parameters beta psi delta alpha rho sigma epsilon;
alpha = 0.33;
beta = 0.99;
delta = 0.023;
psi = 1.75;
rho = 0.95;
sigma = (0.007/(1-alpha));
epsilon = 10;
model;
(1/c) = beta*(1/c(+1))*(1+r(+1)-delta);
psi*c/(1-l) = w;
c+i = y;
y = (k(-1)^alpha)*(exp(z)*l)^(1-alpha);
w = y*((epsilon-1)/epsilon)*(1-alpha)/l;
r = y*((epsilon-1)/epsilon)*alpha/k(-1);
i = k-(1-delta)*k(-1);
y_l = y/l;
z = rho*z(-1)+e;
end;
initval;
k = 9;
c = 0.76;
l = 0.3;
w = 2.07;
r = 0.03;
z = 0;
e = 0;
end;
steady;
check;
shocks;
var e = sigma^2;
end;
varobs y;
estimated_params;
beta, beta_pdf, 0.99, 0.02;
stderr e, inv_gamma_pdf, 0.01, inf;
end;
estimation(datafile=foreview,mode_compute=0,mode_file=dsgeNine_mode,mh_replic=2000,mh_nblocks=2,mh_drop=0.5,mh_jscale=0.2);
The excel data of the Nigerian GDP I am using for this model is attached with this topic/message.
However, after running the model the following is the result that I am getting with errors in it that I cannot interprete and unable to get my posterior mean:
Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.
Starting Dynare (version 4.4.3).
Starting preprocessing of the model file ...
Found 9 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
- order 2
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.
STEADY-STATE RESULTS:
y 0.892084
c 0.707986
k 8.00425
i 0.184098
l 0.302733
y_l 2.94677
w 1.7769
r 0.033101
z 0
EIGENVALUES:
Modulus Real Imaginary
0.9498 0.9498 0
0.95 0.95 0
1.071 1.071 0
Inf Inf 0
There are 2 eigenvalue(s) larger than 1 in modulus
for 2 forward-looking variable(s)
The rank condition is verified.
You did not declare endogenous variables after the estimation/calib_smoother command.
Loading 53 observations from foreview.xlsx
Initial value of the log posterior (or likelihood): -26085.2619
POSTERIOR KERNEL OPTIMIZATION PROBLEM!
(minus) the hessian matrix at the "mode" is not positive definite!
=> posterior variance of the estimated parameters are not positive.
You should try to change the initial values of the parameters using
the estimated_params_init block, or use another optimization routine.
Warning: The results below are most likely wrong!
> In dynare_estimation_1 at 694
In dynare_estimation at 89
In dsgeNine at 178
In dynare at 180
RESULTS FROM POSTERIOR ESTIMATION
parameters
prior mean mode s.d. prior pstdev
beta 0.990 1.0000 0.0000 beta 0.0200
standard deviation of shocks
prior mean mode s.d. prior pstdev
e 0.010 1.5659 0.0000 invg Inf
Log data density [Laplace approximation] is -26098.508064.
??? Error using ==> chol
Matrix must be positive definite.
Error in ==> metropolis_hastings_initialization at 68
d = chol(vv);
Error in ==> random_walk_metropolis_hastings at 62
[ ix2, ilogpo2, ModelName, MetropolisFolder, fblck, fline, npar, nblck, nruns, NewFile,
MAX_nruns, d ] = ...
Error in ==> dynare_estimation_1 at 782
feval(options_.posterior_sampling_method,objective_function,options_.proposal_distribution,xparam1,invhess,bounds,dataset_,options_,M_,estim_params_,bayestopt_,oo_);
Error in ==> dynare_estimation at 89
dynare_estimation_1(var_list,dname);
Error in ==> dsgeNine at 178
dynare_estimation(var_list_);
Error in ==> dynare at 180
evalin('base',fname) ;
I will be so glad if you could help on what to do. Besides, I am using Matlab2009. Thanks so much as I await your helpful responses.
NB: This is the data I used
y
514.83
505.40
515.26
547.71
562.66
577.59
541.21
446.16
430.97
523.36
639.40
713.63
720.39
740.91
802.67
740.26
784.23
806.83
737.50
764.19
773.86
654.23
635.90
587.13
544.86
582.59
581.86
562.79
602.42
629.12
663.33
677.39
679.78
677.54
661.49
661.32
672.75
673.86
669.56
660.18
678.59
682.25
675.56
726.45
783.07
804.15
831.79
862.14
889.43
925.79
972.55
1015.56
1052.34
Kind regards,
Dapomi.
I am Dapomi from the University of Ibadan, Nigeria. I am currently working on 'The of the Interest on Business Cycle in Nigeria'. I am trying to use the DSGE Model using Dynare code on Matlab. However, I am currently try my hand the following code:
var y c k i l y_l w r z;
varexo e;
parameters beta psi delta alpha rho sigma epsilon;
alpha = 0.33;
beta = 0.99;
delta = 0.023;
psi = 1.75;
rho = 0.95;
sigma = (0.007/(1-alpha));
epsilon = 10;
model;
(1/c) = beta*(1/c(+1))*(1+r(+1)-delta);
psi*c/(1-l) = w;
c+i = y;
y = (k(-1)^alpha)*(exp(z)*l)^(1-alpha);
w = y*((epsilon-1)/epsilon)*(1-alpha)/l;
r = y*((epsilon-1)/epsilon)*alpha/k(-1);
i = k-(1-delta)*k(-1);
y_l = y/l;
z = rho*z(-1)+e;
end;
initval;
k = 9;
c = 0.76;
l = 0.3;
w = 2.07;
r = 0.03;
z = 0;
e = 0;
end;
steady;
check;
shocks;
var e = sigma^2;
end;
varobs y;
estimated_params;
beta, beta_pdf, 0.99, 0.02;
stderr e, inv_gamma_pdf, 0.01, inf;
end;
estimation(datafile=foreview,mode_compute=0,mode_file=dsgeNine_mode,mh_replic=2000,mh_nblocks=2,mh_drop=0.5,mh_jscale=0.2);
The excel data of the Nigerian GDP I am using for this model is attached with this topic/message.
However, after running the model the following is the result that I am getting with errors in it that I cannot interprete and unable to get my posterior mean:
Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.
Starting Dynare (version 4.4.3).
Starting preprocessing of the model file ...
Found 9 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
- order 2
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.
STEADY-STATE RESULTS:
y 0.892084
c 0.707986
k 8.00425
i 0.184098
l 0.302733
y_l 2.94677
w 1.7769
r 0.033101
z 0
EIGENVALUES:
Modulus Real Imaginary
0.9498 0.9498 0
0.95 0.95 0
1.071 1.071 0
Inf Inf 0
There are 2 eigenvalue(s) larger than 1 in modulus
for 2 forward-looking variable(s)
The rank condition is verified.
You did not declare endogenous variables after the estimation/calib_smoother command.
Loading 53 observations from foreview.xlsx
Initial value of the log posterior (or likelihood): -26085.2619
POSTERIOR KERNEL OPTIMIZATION PROBLEM!
(minus) the hessian matrix at the "mode" is not positive definite!
=> posterior variance of the estimated parameters are not positive.
You should try to change the initial values of the parameters using
the estimated_params_init block, or use another optimization routine.
Warning: The results below are most likely wrong!
> In dynare_estimation_1 at 694
In dynare_estimation at 89
In dsgeNine at 178
In dynare at 180
RESULTS FROM POSTERIOR ESTIMATION
parameters
prior mean mode s.d. prior pstdev
beta 0.990 1.0000 0.0000 beta 0.0200
standard deviation of shocks
prior mean mode s.d. prior pstdev
e 0.010 1.5659 0.0000 invg Inf
Log data density [Laplace approximation] is -26098.508064.
??? Error using ==> chol
Matrix must be positive definite.
Error in ==> metropolis_hastings_initialization at 68
d = chol(vv);
Error in ==> random_walk_metropolis_hastings at 62
[ ix2, ilogpo2, ModelName, MetropolisFolder, fblck, fline, npar, nblck, nruns, NewFile,
MAX_nruns, d ] = ...
Error in ==> dynare_estimation_1 at 782
feval(options_.posterior_sampling_method,objective_function,options_.proposal_distribution,xparam1,invhess,bounds,dataset_,options_,M_,estim_params_,bayestopt_,oo_);
Error in ==> dynare_estimation at 89
dynare_estimation_1(var_list,dname);
Error in ==> dsgeNine at 178
dynare_estimation(var_list_);
Error in ==> dynare at 180
evalin('base',fname) ;
I will be so glad if you could help on what to do. Besides, I am using Matlab2009. Thanks so much as I await your helpful responses.
NB: This is the data I used
y
514.83
505.40
515.26
547.71
562.66
577.59
541.21
446.16
430.97
523.36
639.40
713.63
720.39
740.91
802.67
740.26
784.23
806.83
737.50
764.19
773.86
654.23
635.90
587.13
544.86
582.59
581.86
562.79
602.42
629.12
663.33
677.39
679.78
677.54
661.49
661.32
672.75
673.86
669.56
660.18
678.59
682.25
675.56
726.45
783.07
804.15
831.79
862.14
889.43
925.79
972.55
1015.56
1052.34
Kind regards,
Dapomi.