# Problem with estimating on empirical data

**URL:** <https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899>\
**Category:** ML/Bayesian estimation\
**Created:** [8 November 2020 15:30 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899 "2020-11-08T15:30:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![helenaholm](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/e47774/32.png) [@helenaholm](https://forum.dynare.org/u/helenaholm)\
**Post date:** [8 November 2020 15:30 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/1 "2020-11-08T15:30:34Z")

</div>

Hi,

I’m having some troubles with estimating a baseline version of the RBC-model i Dynare on empirical data (i.e. “baseline\_data” file).  
Can someone please help me why Dynare failure to calculate the estimated model?

Thanks for taking your time.

/Helena  
[romer\_estimation.mod](https://forum.dynare.org/uploads/short-url/do13XXCgxdg5k6Mm8n8nbh9FaFa.mod) (1.2 KB)  
[Baseline\_data.xlsx](https://forum.dynare.org/uploads/short-url/l3jflJ6HgjfNRmEZO0uEXuFUwSe.xlsx) (12.1 KB)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [8 November 2020 16:31 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/2 "2020-11-08T16:31:11Z")

</div>

Before moving to estimation, make sure you can simulate the model. For example, I am pretty sure the timing of capital in

```auto
c = w*lab+(r+1-cdelta)*k - k(-1);

```

is wrong.

---

<div class="post-metadata">

**Author:** ![helenaholm](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/e47774/32.png) [@helenaholm](https://forum.dynare.org/u/helenaholm)\
**Post date:** [8 November 2020 17:32 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/3 "2020-11-08T17:32:41Z")

</div>

I can simulate the model with no problems 🙂

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [8 November 2020 18:37 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/4 "2020-11-08T18:37:06Z")

</div>

How? `model_diagnostics` complains about `k` not being present at time `t`.

---

<div class="post-metadata">

**Author:** ![helenaholm](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/e47774/32.png) [@helenaholm](https://forum.dynare.org/u/helenaholm)\
**Post date:** [8 November 2020 19:08 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/5 "2020-11-08T19:08:59Z")

</div>

The estimation is based on these simulations [rbc\_romer.mod](https://forum.dynare.org/uploads/short-url/vNvBg9kfOk74bEcI3tb8aV9CV9K.mod) (1.0 KB)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [8 November 2020 19:20 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/6 "2020-11-08T19:20:57Z")

</div>

How about [rbc\_romer.mod](https://forum.dynare.org/uploads/short-url/nIclIj9nJuLb2mrvwLUE7CiHm0o.mod) (1.0 KB) ?  
Your model has output going down after a positive TFP shock…

---

<div class="post-metadata">

**Author:** ![helenaholm](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/e47774/32.png) [@helenaholm](https://forum.dynare.org/u/helenaholm)\
**Post date:** [8 November 2020 19:42 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/7 "2020-11-08T19:42:48Z")

</div>

Thanks for your input - the results changes especially the impulse response functions. Hence i still have implications with estimation on empirical data

 ![Skærmbillede 2020-11-08 kl. 20.40.37](https://forum.dynare.org/uploads/default/original/2X/e/e7a0cc1085bdf867222eceb90e754c624e40467f.png)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [9 November 2020 07:56 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/8 "2020-11-09T07:56:09Z")

</div>

Do you still have the `steady_state_model`-block in your mod-file?

---

<div class="post-metadata">

**Author:** ![helenaholm](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/e47774/32.png) [@helenaholm](https://forum.dynare.org/u/helenaholm)\
**Post date:** [9 November 2020 08:12 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/9 "2020-11-09T08:12:13Z")

</div>

Above i estimated the model with the “steady” command and no “steady\_state\_model-blok”. Hence I tried again with the steady\_state\_model-blok where i obtain this

_Error using print\_info (line 32)_  
_The steadystate file did not compute the steady state_

[romer\_estimation.mod](https://forum.dynare.org/uploads/short-url/sJtLA3NLcUM36rDRXJRg6pqtlpt.mod) (1.6 KB)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [9 November 2020 08:21 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/10 "2020-11-09T08:21:39Z")

</div>

Use [romer\_estimation.mod](https://forum.dynare.org/uploads/short-url/jNQXaFRBRlCmQ9DxnS6SscDV3Eg.mod) (1.6 KB)  
`steady` will not work without proper initial values. Now your data treatment looks wrong. See [Pfeifer(2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models”](https://drive.google.com/file/d/1r89OU5OE3CBa6tOlj6l3hNVWEaRH5Anv/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![helenaholm](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/e47774/32.png) [@helenaholm](https://forum.dynare.org/u/helenaholm)\
**Post date:** [9 November 2020 09:25 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/11 "2020-11-09T09:25:53Z")

</div>

As I have 8 observable variables should I then declare 8 shocks?  
[romer\_estimation\_new.mod](https://forum.dynare.org/uploads/short-url/e8xu57OduPV3fkRLe0EbGvcoTHF.mod) (1.6 KB)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [9 November 2020 09:49 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/12 "2020-11-09T09:49:07Z")

</div>

If you really want 8 observables, you need at least 8 shocks. You may still get a problem with stochastic singularity if you don’t have some measurement error. All of that is detailed in the guide linked above.

---

<div class="post-metadata">

**Author:** ![helenaholm](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/e47774/32.png) [@helenaholm](https://forum.dynare.org/u/helenaholm)\
**Post date:** [9 November 2020 11:46 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/13 "2020-11-09T11:46:27Z")

</div>

Yes that was also my thoughts - thank for providing me feedback, I really appreciate your help.  
I have now declared 2 observable variables and 2 shocks where some of the estimation process succeed but I estimate a negative matrix \<0 .

“Error using chol  
Matrix must be positive definite.”

How is it possible to correct for this? I tried to look at your guide but with no success.  
[romer\_estim\_old.mod](https://forum.dynare.org/uploads/short-url/cEM84XBx7LtKYwvsqGqfyXOLPwf.mod) (1.6 KB)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [9 November 2020 12:53 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/14 "2020-11-09T12:53:28Z")

</div>

The data file is missing.

---

<div class="post-metadata">

**Author:** ![helenaholm](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/e47774/32.png) [@helenaholm](https://forum.dynare.org/u/helenaholm)\
**Post date:** [12 November 2020 08:38 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/15 "2020-11-12T08:38:31Z")

</div>

sorry for the many questions but i don’t understand how the data file can be missing when i have declared the data file in the estimation-block and the program are able to estimate part of the code?

Thanks for taking your time to help me!

[romer\_estim\_old.mod](https://forum.dynare.org/uploads/short-url/rgfmrEHILlCHHsSqpjfWooW4bhv.mod) (1.6 KB)

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [12 November 2020 08:50 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/16 "2020-11-12T08:50:32Z")

</div>

What error message do you get? Note that programming languages are case-sensitive. Your Excel-file starts with a capital letter.

---

<div class="post-metadata">

**Author:** ![helenaholm](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/e47774/32.png) [@helenaholm](https://forum.dynare.org/u/helenaholm)\
**Post date:** [12 November 2020 09:12 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/17 "2020-11-12T09:12:51Z")

</div>

_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 (line 315)_
- In dynare\_estimation (line 105)\*
- In romer\_estim\_old.driver (line 247)\*
- In dynare (line 293) \*

_MODE CHECK_

_Fval obtained by the minimization routine (minus the posterior/likelihood)): 13.409097_  
_Warning: Matrix is singular, close to singular or badly scaled. Results may be_  
\*inaccurate. RCOND = NaN. \*  
_\> In dynare\_estimation\_1 (line 338)_

- In dynare\_estimation (line 105)\*
- In romer\_estim\_old.driver (line 247)\*
- In dynare (line 293)\*

_Log data density [Laplace approximation] is NaN._

_Error using chol_  
_Matrix must be positive definite._

_Error in posterior\_sampler\_initialization (line 84)_  
_d = chol(vv);_

_Error in posterior\_sampler (line 60)_

- posterior\_sampler\_initialization(TargetFun, xparam1, vv,\*
- mh\_bounds,dataset\_,dataset\_info,options\_,M\_,estim\_params\_,bayestopt\_,oo\_);\*

_Error in dynare\_estimation\_1 (line 465)_

- 

```
       posterior_sampler(objective_function,posterior_sampler_options.proposal_distribution,xparam1,posterior_sampler_options,bounds,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,oo_);*

```

_Error in dynare\_estimation (line 105)_

- dynare\_estimation\_1(var\_list,dname);\*

_Error in romer\_estim\_old.driver (line 247)_  
_oo\_recursive\_=dynare\_estimation(var\_list\_);_

_Error in dynare (line 293)_  
_evalin(‘base’,[fname ‘.driver’]) ;_

I’m trying to estimate the model with more than one observable variables (y\_obs and c\_obs) - when i estimate with only y\_obs i receive no error messages so i think it could be in the definition of the additional shock variable/equation where it goes wrong.

Thanks!

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [12 November 2020 09:50 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/18 "2020-11-12T09:50:16Z")

</div>

Please provide the most recent mod-file and data-file

---

<div class="post-metadata">

**Author:** ![helenaholm](https://forum.dynare.org/letter_avatar_proxy/v4/letter/h/e47774/32.png) [@helenaholm](https://forum.dynare.org/u/helenaholm)\
**Post date:** [12 November 2020 10:20 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/19 "2020-11-12T10:20:54Z")

</div>

[romer\_estim\_old.mod](https://forum.dynare.org/uploads/short-url/s5unVz8fV9j6APgyx1J3lAnH2R0.mod) (1.6 KB)

[baseline\_romer.m](https://forum.dynare.org/uploads/short-url/uKdxH0JVuz9LFMOSdTfo9VwVent.m) (1.4 KB)

Thanks

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [12 November 2020 11:00 UTC](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899/20 "2020-11-12T11:00:48Z")

</div>

I am not sure what you are doing.

1. The uploaded file does not run, because there is a log missing in

```auto
log(cA) = rhov*(cA(-1))+epsv;

```

1. The parameter `rhov` is clearly not identified as you are neither observing `cA` nor is `cA` affecting any other part of the model.

[Next page](https://forum.dynare.org/t/problem-with-estimating-on-empirical-data/16899.md?page=2)
