Page 1 of 1

bayesian estimation

PostPosted: Sun Apr 22, 2012 9:59 pm
by lizzie3108
dear dynare users,

I am writing you again because I have got stuck into the estimation part of my code.
When I have made the simulation everything was working correctly but now I wan to estimate the parameter using the bayesian estimation so that I have especified my priors (hope correctly) but there is still a problem. I am not so used to dynare so if someone know how to solve this problem please let me know.
the code is from Ireland paper, I would appreciate if someone also could recommend literature in order to know how to solve this kind of problems in dynare.

PS: does it make any differences if my data is in log instead of levels? should i change it:
Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.

Starting Dynare (version 4.2.5).
Starting preprocessing of the model file ...
Substitution of endo lags >= 2: added 1 auxiliary variables and equations.
Found 9 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.


STEADY-STATE RESULTS:

y 0
m 0
mu 0
r 0
pi 0
a 0
e 0
z 0

EIGENVALUES:
Modulus Real Imaginary

0 -0 0
0 0 0
0 -0 0
1.535e-016 1.535e-016 0
0.4463 0.4463 0
0.9579 0.9579 0
0.9853 0.9853 0
0.9903 0.9903 0
1 1 0
1.112 1.112 0
Inf -Inf 0
Inf Inf 0


There are 3 eigenvalue(s) larger than 1 in modulus
for 3 forward-looking variable(s)

The rank condition is verified.


You did not declare endogenous variables after the estimation command.
Prior distribution for parameter gamma1 has two modes!
Loading 212 observations from data.mat

Initial value of the log posterior (or likelihood): -153894242145.5625
-----------------
-----------------
f at the beginning of new iteration, 153894242145.5625300000
Predicted improvement: 182855488371520500000.000000000
lambda = 1; f = 19635108854339768.0000000
lambda = 0.33333; f = 2181815477334420.5000000
lambda = 0.11111; f = 242560710427690.7500000
lambda = 0.037037; f = 27087976136008.8750000
lambda = 0.012346; f = 3146567076992.1211000
lambda = 0.0041152; f = 486412468972.8919700
lambda = 0.0013717; f = 190840386113.1143800
lambda = 0.00045725; f = 157999260694.6661100
lambda = 0.00015242; f = 154350319133.1253400
lambda = 5.0805e-005; f = 153944905306.4571200
lambda = 1.6935e-005; f = 153899867367.2542700
lambda = 5.645e-006; f = 153894865832.2999600
lambda = 1.8817e-006; f = 153894310999.6981500
lambda = 6.2723e-007; f = 153894249649.4660300
lambda = 2.0908e-007; f = 153894242932.0518200
lambda = 6.9692e-008; f = 153894242218.7652000
lambda = 2.3231e-008; f = 153894242150.5420500
lambda = 7.7435e-009; f = 153894242145.9956400
lambda = 2.5812e-009; f = 153894242145.6011700

lambda =

-6.2723e-007

lambda = -6.2723e-007; f = 153894248496.6124000
lambda = -2.0908e-007; f = 153894242785.8013600
lambda = -6.9692e-008; f = 153894242198.3217800
lambda = -2.3231e-008; f = 153894242148.5001200
lambda = -7.7435e-009; f = 153894242145.7825600
lambda = -2.5812e-009; f = 153894242145.5670500
Norm of dx 1.9124e+008
----
Improvement on iteration 1 = 0.000000000
improvement < crit termination
smallest step still improving too slow, reversed gradient
Objective function at mode: 153894242145.562530
Objective function at mode: 153894242145.562530

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 436
In dynare_estimation at 62
In bayes at 226
In dynare at 120

RESULTS FROM POSTERIOR MAXIMIZATION
parameters
prior mean mode s.d. t-stat prior pstdev

omega1 0.250 0.2500 0.0000 0.0000 beta 0.0250
omega2 0.125 0.1250 0.0000 0.0000 gamm 0.0250
gamma1 0.573 0.5726 0.0000 0.0000 beta 0.3400
gamma2 0.040 0.0400 0.0000 0.0000 beta 0.0090
rho_pi 0.400 0.4000 0.0000 10387.2179 gamm 0.1000
rho_r 0.400 0.4000 0.0000 0.0000 gamm 0.1000
rho_y 0.400 0.4000 0.0000 0.0000 gamm 0.1000
rho_mu 0.400 0.4000 0.0000 10680.0843 gamm 0.1000
rho_a 0.000 0.0000 0.0000 0.0000 norm 0.2500
rho_e 0.000 0.0000 0.0000 0.0000 norm 0.2500
rho_z 0.000 0.0000 0.0000 0.0000 norm 0.2500
sig_r 0.010 0.0100 0.0000 0.0000 invg Inf
sig_a 0.010 0.0100 0.0000 0.0000 invg Inf
sig_e 0.010 0.0100 0.0000 0.0000 invg Inf
sig_z 0.010 0.0100 0.0000 0.0000 invg Inf

Log data density [Laplace approximation] is -153894242300.167080.

??? Error using ==> chol
Matrix must be positive definite.

Error in ==> metropolis_hastings_initialization at 52
d = chol(vv);

Error in ==> random_walk_metropolis_hastings at 58
[ ix2, ilogpo2, ModelName, MhDirectoryName, fblck, fline, npar, nblck, nruns, NewFile, MAX_nruns, d
] = ...

Error in ==> dynare_estimation_1 at 871
feval(options_.posterior_sampling_method,'DsgeLikelihood',options_.proposal_distribution,xparam1,invhess,bounds,gend,data,...

Error in ==> dynare_estimation at 62
dynare_estimation_1(var_list,varargin{:});

Error in ==> bayes at 226
dynare_estimation(var_list_);

Error in ==> dynare at 120
evalin('base',fname) ;

Re: bayesian estimation

PostPosted: Sun Apr 22, 2012 10:01 pm
by lizzie3108
I wasn't able of uploading the data.mat file so i am uploading the xls file. I don't know why is not possible. Anyway when I run dynare i use data.mat file.

Re: bayesian estimation

PostPosted: Mon Apr 23, 2012 7:14 am
by jpfeifer
There are dozens of posts in the forum regarding this issue. Use mode_compute=6 in the estimation options.

Re: bayesian estimation

PostPosted: Mon Apr 23, 2012 1:17 pm
by lizzie3108
yes I know that there is dozen of that post, the problem is that I have already tried to use mode_compute=6 and it is not working neither.

Re: bayesian estimation

PostPosted: Tue Jan 15, 2013 5:12 pm
by selima
hello I hope that you find the problem because I have approximately the same problem

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.3.1).
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

You did not declare endogenous variables after the estimation/calib_smoother command.
??? Error using ==> read_variables at 58
Can't find datafile: y.{m,mat,xls,xlsx}

Error in ==> initialize_dataset at 31
rawdata = read_variables(datafile,varobs,[],xls.sheet,xls.range);

Error in ==> dynare_estimation_init at 347
dataset_ = initialize_dataset(options_.datafile,options_.varobs,options_.first_obs,options_.nobs,transformation,options_.prefilter,xls);

Error in ==> dynare_estimation_1 at 59
[dataset_,xparam1, M_, options_, oo_, estim_params_,bayestopt_] = dynare_estimation_init(var_list_, dname, [], M_, options_, oo_, estim_params_, bayestopt_);

Error in ==> dynare_estimation at 70

Re: bayesian estimation

PostPosted: Tue Jan 15, 2013 8:20 pm
by jpfeifer