# Efficient quantity

**URL:** <https://forum.dynare.org/t/efficient-quantity/10493>\
**Category:** General DSGE Modeling\
**Created:** [1 August 2017 14:26 UTC](https://forum.dynare.org/t/efficient-quantity/10493 "2017-08-01T14:26:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![923115005](https://forum.dynare.org/letter_avatar_proxy/v4/letter/9/73ab20/32.png) [@923115005](https://forum.dynare.org/u/923115005)\
**Post date:** [1 August 2017 14:26 UTC](https://forum.dynare.org/t/efficient-quantity/10493/1 "2017-08-01T14:26:45Z")

</div>

Dear all  
I am new user dynare, and I want to estimate the efficient amount of decision variable, therefore how to write the appropriate code in dynare

---

<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:** [1 August 2017 14:35 UTC](https://forum.dynare.org/t/efficient-quantity/10493/2 "2017-08-01T14:35:37Z")

</div>

You need to provide a lot more detail. What exactly are you trying to do?

---

<div class="post-metadata">

**Author:** ![923115005](https://forum.dynare.org/letter_avatar_proxy/v4/letter/9/73ab20/32.png) [@923115005](https://forum.dynare.org/u/923115005)\
**Post date:** [1 August 2017 15:36 UTC](https://forum.dynare.org/t/efficient-quantity/10493/3 "2017-08-01T15:36:03Z")

</div>

Dear professor  
thanks a lot for your reply  
I run a DSGE model for Iran and I want to estimate potential output by using estimated parameters, the potential output is the level of output in an environment without nominal rigidities in goods and labor markets and  
without shocks to price and wage markups.  
in fact how to write the code in dynare  
best regard

---

<div class="post-metadata">

**Author:** ![stepan-a](https://forum.dynare.org/user_avatar/forum.dynare.org/stepan-a/32/6652_2.png) [@stepan-a](https://forum.dynare.org/u/stepan-a)\
**Post date:** [1 August 2017 15:45 UTC](https://forum.dynare.org/t/efficient-quantity/10493/4 "2017-08-01T15:45:35Z")

</div>

You can do that with a lot of models. So first you have to choose one model, try to code it in Dynare, and then we can help you when you will have precise issues with your model. You can do that with a Smets and Wouters model for example, but I don’t know which feature you need in your model.

Best,  
Stéphane.

---

<div class="post-metadata">

**Author:** ![923115005](https://forum.dynare.org/letter_avatar_proxy/v4/letter/9/73ab20/32.png) [@923115005](https://forum.dynare.org/u/923115005)\
**Post date:** [1 August 2017 16:38 UTC](https://forum.dynare.org/t/efficient-quantity/10493/5 "2017-08-01T16:38:23Z")

</div>

tanke you so much  
dear stephan, i estimated the parameters but i do not know write a code in dynare for estimating the variables such consumption

---

<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:** [1 August 2017 17:17 UTC](https://forum.dynare.org/t/efficient-quantity/10493/6 "2017-08-01T17:17:15Z")

</div>

But if you have estimated your model already, all you need to do is run the Kalman smoother on the model.

---

<div class="post-metadata">

**Author:** ![923115005](https://forum.dynare.org/letter_avatar_proxy/v4/letter/9/73ab20/32.png) [@923115005](https://forum.dynare.org/u/923115005)\
**Post date:** [1 August 2017 18:49 UTC](https://forum.dynare.org/t/efficient-quantity/10493/7 "2017-08-01T18:49:28Z")

</div>

tanke you so much professor jpfeifer  
how do it in dynare? in fact how simulated potential output after estimated parameters?

---

<div class="post-metadata">

**Author:** ![stepan-a](https://forum.dynare.org/user_avatar/forum.dynare.org/stepan-a/32/6652_2.png) [@stepan-a](https://forum.dynare.org/u/stepan-a)\
**Post date:** [2 August 2017 05:30 UTC](https://forum.dynare.org/t/efficient-quantity/10493/8 "2017-08-02T05:30:05Z")

</div>

As said by Johannes, if you defined the output gap in your model, you just need to add the `smoother` option in the `estimation` command and the name of the output gap variable after the estimation command. Something like:

```auto
estimation(..., smoother, ...) OutputGap ;

```

See the estimation section in the [reference manual](http://www.dynare.org/manual/index_28.html).

Best,  
Stéphane.

---

<div class="post-metadata">

**Author:** ![923115005](https://forum.dynare.org/letter_avatar_proxy/v4/letter/9/73ab20/32.png) [@923115005](https://forum.dynare.org/u/923115005)\
**Post date:** [5 August 2017 19:47 UTC](https://forum.dynare.org/t/efficient-quantity/10493/9 "2017-08-05T19:47:22Z")

</div>

Dear stepan  
tanks a lot for your reply  
one of the my observed variables are “y”, can I predict “y” by using DSGE? and do predicted of “y” is different from observed “y”?

---

<div class="post-metadata">

**Author:** ![stepan-a](https://forum.dynare.org/user_avatar/forum.dynare.org/stepan-a/32/6652_2.png) [@stepan-a](https://forum.dynare.org/u/stepan-a)\
**Post date:** [5 August 2017 20:33 UTC](https://forum.dynare.org/t/efficient-quantity/10493/10 "2017-08-05T20:33:43Z")

</div>

Sure, it is possible to forecast with a DSGE model, and the forecast will be different from the actual realization of the variable.

- The `forecast` option of the `estimation` triggers the computation of the posterior predictive density of the observed variables after the end of the sample used in estimation.

- The `filtered_vars` or `filter_step_ahead` options of the `estimation` command trigger the computation of the posterior distribution of the one or k step ahead filtered variables, i.e. the expectation of the variables in t+k conditional on the information available at time t.

The first approach provide out of sample forecast, while the second one delivers in sample forecasts. You will find more details in the reference manual.

Best,  
Stéphane.

---

<div class="post-metadata">

**Author:** ![923115005](https://forum.dynare.org/letter_avatar_proxy/v4/letter/9/73ab20/32.png) [@923115005](https://forum.dynare.org/u/923115005)\
**Post date:** [7 August 2017 13:02 UTC](https://forum.dynare.org/t/efficient-quantity/10493/11 "2017-08-07T13:02:16Z")

</div>

Dear Stepan tanks a lot for your contribution  
I want to index the horizon axis to year over 1960-2010, and also my graphic at starting point indexed to a number such 100, How do this in dynare?

---

<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:** [7 August 2017 14:13 UTC](https://forum.dynare.org/t/efficient-quantity/10493/12 "2017-08-07T14:13:44Z")

</div>

Please see [Placing dates on the horizontal axis of shock decomposition](https://forum.dynare.org/t/placing-dates-on-the-horizontal-axis-of-shock-decomposition/6301/6)

---

<div class="post-metadata">

**Author:** ![stepan-a](https://forum.dynare.org/user_avatar/forum.dynare.org/stepan-a/32/6652_2.png) [@stepan-a](https://forum.dynare.org/u/stepan-a)\
**Post date:** [7 August 2017 14:39 UTC](https://forum.dynare.org/t/efficient-quantity/10493/13 "2017-08-07T14:39:45Z")

</div>

An example. If you computed the filtered variables (with `filtered_vars` option in the `estimation` command), then you can define a `dseries` object as follows:

```matlab
>> data = dseries(oo_.Filtered_Variables_1_step_ahead.Mean.y, '1980Q1', 'y');

```

where the string `'1980Q1'` is the initial period, and the last argument the name of the variable. Then you just have to use the overloaded `plot` function:

```auto
plot(data)

```

which will produce something like: [dseries-plot.pdf](https://forum.dynare.org/uploads/default/original/2X/e/e8a7f79e55d360ba3f78d6c2be24801ba121e791.pdf) (4.6 KB)

Best,  
Stéphane.

---

<div class="post-metadata">

**Author:** ![923115005](https://forum.dynare.org/letter_avatar_proxy/v4/letter/9/73ab20/32.png) [@923115005](https://forum.dynare.org/u/923115005)\
**Post date:** [10 August 2017 05:26 UTC](https://forum.dynare.org/t/efficient-quantity/10493/14 "2017-08-10T05:26:30Z")

</div>

tank a lot for all contribution  
Dear Stepan, I want to decompose consumption and production by shocks, how I can to do it?

---

<div class="post-metadata">

**Author:** ![stepan-a](https://forum.dynare.org/user_avatar/forum.dynare.org/stepan-a/32/6652_2.png) [@stepan-a](https://forum.dynare.org/u/stepan-a)\
**Post date:** [10 August 2017 05:48 UTC](https://forum.dynare.org/t/efficient-quantity/10493/15 "2017-08-10T05:48:28Z")

</div>

There is a command called `shock_decomposition` for that. See the reference manual [here](http://www.dynare.org/manual/index_30.html).

Best,  
Stéphane.

---

<div class="post-metadata">

**Author:** ![923115005](https://forum.dynare.org/letter_avatar_proxy/v4/letter/9/73ab20/32.png) [@923115005](https://forum.dynare.org/u/923115005)\
**Post date:** [11 August 2017 18:00 UTC](https://forum.dynare.org/t/efficient-quantity/10493/16 "2017-08-11T18:00:49Z")

</div>

Dear Stepan  
When I use the shock\_decomposition after estimation, I see negative contribution of various shocks for endogenous variable, However the contribution of various shock must be positive, therefore my question is why the contribution of shocks are negative? and what is the problem?  
best regard  
Goli

---

<div class="post-metadata">

**Author:** ![stepan-a](https://forum.dynare.org/user_avatar/forum.dynare.org/stepan-a/32/6652_2.png) [@stepan-a](https://forum.dynare.org/u/stepan-a)\
**Post date:** [11 August 2017 19:27 UTC](https://forum.dynare.org/t/efficient-quantity/10493/17 "2017-08-11T19:27:31Z")

</div>

Hi, you are doing a decomposition of the levels of time series (not of the volatility of the time series). A shock can contribute positively or negatively to the levels. Consider a supply shock (for instance a TFP shock). An increase in productivity will augment the production but lower inflation. There is no theoretical reason to have only positive contributions. Hence, a priori, there is no problem with your results if you are able to interpret them.

Best,  
Stéphane.

---

<div class="post-metadata">

**Author:** ![923115005](https://forum.dynare.org/letter_avatar_proxy/v4/letter/9/73ab20/32.png) [@923115005](https://forum.dynare.org/u/923115005)\
**Post date:** [13 August 2017 11:37 UTC](https://forum.dynare.org/t/efficient-quantity/10493/18 "2017-08-13T11:37:19Z")

</div>

Dear Stepan , tanks a lot for your time  
when I use variance decomposition command (moments\_varendo) in estimation, dynare reports the NaN for effects of shocks , what is the problem with my model?  
best  
Goli

---

<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 August 2017 11:57 UTC](https://forum.dynare.org/t/efficient-quantity/10493/19 "2017-08-13T11:57:49Z")

</div>

Please provide the files necessary to replicate the issue

---

<div class="post-metadata">

**Author:** ![923115005](https://forum.dynare.org/letter_avatar_proxy/v4/letter/9/73ab20/32.png) [@923115005](https://forum.dynare.org/u/923115005)\
**Post date:** [13 August 2017 12:30 UTC](https://forum.dynare.org/t/efficient-quantity/10493/20 "2017-08-13T12:30:36Z")

</div>

estimation(datafile=dataset,xls\_sheet=Sheet1,xls\_range = A1:G109,mh\_replic=12000, mh\_nblocks=8 ,mh\_drop=0.3,smoother, mh\_jscale=0.4, moments\_varendo, mode\_compute=6, mode\_check, lik\_init=2) y c i g o;  
shock\_decomposition;

[Next page](https://forum.dynare.org/t/efficient-quantity/10493.md?page=2)
