# Uncertainty shock implementations

**URL:** <https://forum.dynare.org/t/uncertainty-shock-implementations/19857>\
**Category:** Stochastic simulations\
**Created:** [23 February 2022 04:22 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857 "2022-02-23T04:22:02Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zak](https://forum.dynare.org/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@Zak](https://forum.dynare.org/u/Zak)\
**Post date:** [23 February 2022 04:22 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/1 "2022-02-23T04:22:03Z")

</div>

I am new to uncertainty in Dynare and would appreciate any contribution to improve my understanding. I am trying to simulate crude oil price uncertainty shocks and got the following spec:

```auto
log(POstar)=(1-rhoPOstar)*log(POstarss)+rhoPOstar*log(POstar(-1))+sigOstar*epsPOstar;

log(sigOstar)=(1-rhosOstar)*log(sigOstarss)+rhosOstar*log(sigOstar(-1))+epssOstar;

var epsPOstar; stderr 0.01;
var epssOstar; stderr 0.1;

```

Simul order 3

1. I see authors (including the seminal Basu\_Bundick\_2017) using a scale parameter and set stderr to 1. What’s wrong if I proceed as above. I can increase the value as much as I want and see the results. I guess dynare 5 made that possible?
2. The IRFs show the shocks to both crude oil price (epsPOstar) and uncertainty (epssOstar). To simulate a shock in absence of uncertainty I drop the related variables and parameters from the eq. is there any better way to do it?
3. How can I proceed to simulate only crude oil price uncertainty (i.e turning epsPOstar off)? Thanks.

---

<div class="post-metadata">

**Author:** ![Zak](https://forum.dynare.org/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@Zak](https://forum.dynare.org/u/Zak)\
**Post date:** [24 February 2022 16:43 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/2 "2022-02-24T16:43:11Z")

</div>

any clue @punnoosejacob @jpfeifer ?

---

<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:** [25 February 2022 08:07 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/3 "2022-02-25T08:07:00Z")

</div>

1. I am not sure I understand the question. For `sigOstar*epsPOstar`, `sigOstarss` only gives you the standard deviation if `epsPOstar` has standard deviation 1. As a sidenote, see point 1 of

> [@Shock to standard deviation](https://forum.dynare.org/t/shock-to-standard-deviation/16857/7):
>
> Mostly yes. But You are using a log-log-specification, whose moments do not exist. [See Andreasen (2010)](https://doi.org/10.1016/j.econlet.2010.03.007) I would recommend against GIRFs. See [https://github.com/JohannesPfeifer/DSGE\_mod/blob/master/Basu\_Bundick\_2017/Basu\_Bundick\_2017.mod](https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Basu_Bundick_2017/Basu_Bundick_2017.mod) for an alternative.

1. To shut off uncertainty, you can simply set its standard deviation to 0.
2. What do you mean with “turning epsPOstar off”? You usually just want to keep it to 0 on average in GIRFs as in [DSGE\_mod/Basu\_Bundick\_2017/Basu\_Bundick\_2017.mod at master · JohannesPfeifer/DSGE\_mod · GitHub](https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Basu_Bundick_2017/Basu_Bundick_2017.mod)

---

<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:** [27 February 2022 08:40 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/5 "2022-02-27T08:40:07Z")

</div>

Your code is too complex to quickly check. Did you try whether it’s a matter of parameterization?

---

<div class="post-metadata">

**Author:** ![Zak](https://forum.dynare.org/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@Zak](https://forum.dynare.org/u/Zak)\
**Post date:** [27 February 2022 19:42 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/6 "2022-02-27T19:42:28Z")

</div>

The counter intuitive IRFs show up when I use your code.  
as you can see in the attached, I used the exact same two files as above, but did the follwing two minor changes  
1-  
var epsPOstar; stderr 0.1;  
var epssOstar; stderr 0.1;

epssOstar is the uncertainty

2- I dropped all your code and kept only stock simul.  
See the second IRF (epssOstar).  
(please run the m file first). There is something I’m not getting right. Thanks.

[Model5\_external\_ext3\_N.mod](https://forum.dynare.org/uploads/short-url/gcQAbyqZzZeUmxImpkOy0YvuMYr.mod) (9.4 KB)  
[Model5\_external\_ext3.m](https://forum.dynare.org/uploads/short-url/qjkI6TDu6gtNjiL1EfxGObiLuIr.m) (4.8 KB)

---

<div class="post-metadata">

**Author:** ![Zak](https://forum.dynare.org/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@Zak](https://forum.dynare.org/u/Zak)\
**Post date:** [1 March 2022 16:25 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/7 "2022-03-01T16:25:39Z")

</div>

@jpfeifer given that difference, do you think the issue comes from my handling of your code ?(the parameters checks were not helpful).  
You said `sigOstarss` only gives you the standard deviation if `epsPOstar` has standard deviation 1. In my version (see early attached) I set stdvs to 0.1, and but I still get IRFs that make sens to me (i.e the uncertainty shock is contractionary).

---

<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:** [2 March 2022 08:12 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/8 "2022-03-02T08:12:40Z")

</div>

1. What do you mean with

> [@Zak](#):
>
> There is something I’m not getting right

1. My code implemented GIRFs at the stochastic steady state. `stoch_simul` will result in GIRFs sampling from the ergodic distribution. That is a conceptual difference.
2. Regarding the standard deviations. As long as the implementation is consistent, it should not make a difference. But my hunch is that the different code versions imply very different volatilities and therefore IRFs.

---

<div class="post-metadata">

**Author:** ![Zak](https://forum.dynare.org/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@Zak](https://forum.dynare.org/u/Zak)\
**Post date:** [2 March 2022 15:01 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/9 "2022-03-02T15:01:14Z")

</div>

Thanks @jpfeifer. When I use your code the GIRF is quite opposite to mine in term of shock transmission. Which I do not understand. When using mine, the uncertainty shock is contractionary as expected. Y,C,…Welfare are negatively affected. But with yours, it’s completely opposite (as you could see, uncertainty shock is expansionary and transmit positively to Y,C,…Welfare). I don’t get this difference. I want to use your code, but the GIRFs are hard to interpret.

---

<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:** [3 March 2022 12:17 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/10 "2022-03-03T12:17:03Z")

</div>

Where does the difference come from? GIRFs considered at a different point? Or different shock size specifications?

---

<div class="post-metadata">

**Author:** ![Zak](https://forum.dynare.org/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@Zak](https://forum.dynare.org/u/Zak)\
**Post date:** [4 March 2022 02:51 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/11 "2022-03-04T02:51:27Z")

</div>

Thanks so much for always being there. I will take a close look.

---

<div class="post-metadata">

**Author:** ![Zak](https://forum.dynare.org/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@Zak](https://forum.dynare.org/u/Zak)\
**Post date:** [12 March 2022 23:00 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/12 "2022-03-12T23:00:40Z")

</div>

Hi @jpfeifer a question regarding the model estimation. When the estimation runs neatly, with no error, no issues. But only with a head _ **"You did not declare endogenous variables after the estimation/calib\_smoother command."** _ do you think there is still some issues to address ? I read throughout the forum; people getting similar error usually have error messages and their estimation interrupted.

As you found code complex I do not find useful to attach it again. But below are the key parts and the attached data (only 1 variable). Thanks

Var Infl\_obs ;  
Model Infl\_obs=Infl;  
steady\_state\_model Infl\_obs=Infl;  
varobs Infl\_obs;  
estimated\_params;  
…

estimated\_params\_init(use\_calibration);  
end;

estimation(datafile = est\_data, xls\_sheet=est\_data,xls\_range=A1:A129, mh\_replic=2000,diffuse\_filter);

stoch\_simul(order = 1, pruning, irf=25) …;

[est\_data.xls](https://forum.dynare.org/uploads/short-url/esvIWdEZlroLy10iCwAHXajABqp.xls) (30.5 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:** [13 March 2022 08:19 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/13 "2022-03-13T08:19:47Z")

</div>

The

> [@Zak](#):
>
> You did not declare endogenous variables after the estimation/calib\_smoother command.

is a warning shown by Dynare if there are more than 20 variables, because in that case, smoother computations can take a long time. Dynare will then ask you for a selection. But that does not indicate any problems with actual computations.

---

<div class="post-metadata">

**Author:** ![Zak](https://forum.dynare.org/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@Zak](https://forum.dynare.org/u/Zak)\
**Post date:** [15 March 2022 21:47 UTC](https://forum.dynare.org/t/uncertainty-shock-implementations/19857/14 "2022-03-15T21:47:13Z")

</div>

Thanks a lot ! a couple of concerns  
1- I placed stoch\_simul right below the estimation. From what I read in the forum this will use the updated parameters to plot the IRF. Does it also apply to order 2 (welfare analysis) and order 3 ( uncertainty, using the undemeaned data as you suggested) . I noticed that when I try welfare analysis I get very high values for welfare gain ( \>100%). This maybe comes from the fact that all shocks are turned on.Turning some of them off will not run as the number of shocks becomes \< number observed variables.

2- Is there any way to run the estimation once, as it is time consuming, and use the updated parameters next time I do some policy scenarios (tweaking one non-estimated parameter) ? My initial thought was to

- First run estimation
- Then pull the posteriors
- Change the parameters in the mod file
- And close estimation. (% estimation (…))  
That way, I will move faster with the policy scenarios, welfare analysis and uncertainty, using the parameters - which deflect the observed data.
