# Obtaining impulse response for a variable outside the model

**URL:** https://forum.dynare.org/t/obtaining-impulse-response-for-a-variable-outside-the-model/4583
**Category:** Dynare help (legacy posts)
**Created:** [27 March 2015 11:03 UTC](https://forum.dynare.org/t/obtaining-impulse-response-for-a-variable-outside-the-model/4583 "2015-03-27T11:03:00Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![jrubin](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@jrubin](https://forum.dynare.org/u/jrubin)
#### Post date: [27 March 2015 11:03 UTC](https://forum.dynare.org/t/obtaining-impulse-response-for-a-variable-outside-the-model/4583/1 "2015-03-27T11:03:00Z")

</div>

I’m working with a simple RBC model specified specified in levels so that Dynare linearizes it.  
I already know the solutions for capital (K) and labour (L).  
The output (Y) equation is not specified in the set of model equations as Y was substituted out.

How can I obtain the impulse response of Y without adding it to the model equations since I don’t need the first order approximation to Y as I already know K and L?

Any suggestion will be much appreciated!

---

<div class="post-metadata">

### Author: ![Daniel\_Bendel](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@Daniel\_Bendel](https://forum.dynare.org/u/Daniel_Bendel)
#### Post date: [27 March 2015 11:20 UTC](https://forum.dynare.org/t/obtaining-impulse-response-for-a-variable-outside-the-model/4583/2 "2015-03-27T11:20:25Z")

</div>

I would do the following:

Y is computed by using the production function Y= K^(1-alpha)\*L^(alpha).

From your model you get the irf for K and L and the corresponding steady state values save in oo\_.steady\_state().  
Then just use these values to calculate the irf for Y:

Y\_irf = (K\_eps\_YOURSHOCK + oo\_.steady\_state(HERE THE NUMBER WHERE DYNARE HAS SAVED THE SS FOR K)._ones(size(K\_eps\_YOURSHOCK)))^(1-alpha)_ (L\_eps\_YOURSHOCK + oo\_.steady\_state(HERE THE NUMBER WHERE DYNARE HAS SAVED THE SS FOR L).\*ones(size(L\_eps\_YOURSHOCK)))^(alpha)

---

<div class="post-metadata">

### Author: ![jrubin](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@jrubin](https://forum.dynare.org/u/jrubin)
#### Post date: [27 March 2015 11:47 UTC](https://forum.dynare.org/t/obtaining-impulse-response-for-a-variable-outside-the-model/4583/3 "2015-03-27T11:47:00Z")

</div>

Thanks for this helpful suggestion!

---

<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 March 2015 13:47 UTC](https://forum.dynare.org/t/obtaining-impulse-response-for-a-variable-outside-the-model/4583/4 "2015-03-27T13:47:39Z")

</div>

Be careful about your definition of variables. If they are in logs, you cannot use the output formula for levels.

---

<div class="post-metadata">

### Author: ![jrubin](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@jrubin](https://forum.dynare.org/u/jrubin)
#### Post date: [27 March 2015 16:56 UTC](https://forum.dynare.org/t/obtaining-impulse-response-for-a-variable-outside-the-model/4583/5 "2015-03-27T16:56:00Z")

</div>

Thanks. Yes, the model I have is linearized (not log-linearized).

---

<div class="post-metadata">

### Author: ![jrubin](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@jrubin](https://forum.dynare.org/u/jrubin)
#### Post date: [28 March 2015 11:13 UTC](https://forum.dynare.org/t/obtaining-impulse-response-for-a-variable-outside-the-model/4583/6 "2015-03-28T11:13:28Z")

</div>

Hello Daniel and Johannes:

1. Seems there is an error in the expression: should coefficients be .^(1-alpha) and .^(alpha)?
2. Is the product of the two terms involving K and L conformable to give Y\_irf of dimension size(K\_eps\_YOURSHOCK) x 1?

Y\_irf = (K\_eps\_YOURSHOCK + oo\_.steady\_state(HERE THE NUMBER WHERE DYNARE HAS SAVED THE SS FOR K)._ones(size(K\_eps\_YOURSHOCK)))^(1-alpha)_ (L\_eps\_YOURSHOCK + oo\_.steady\_state(HERE THE NUMBER WHERE DYNARE HAS SAVED THE SS FOR L).\*ones(size(L\_eps\_YOURSHOCK)))^(alpha)

1. If Y=AK^(1-alpha)\*L^(alpha), where A is the AR(1) shock, then one need to multiply the expression above with (A\_eps\_YOURSHOCK +oo\_.steady\_state(HERE THE NUMBER WHERE DYNARE HAS SAVED THE SS FOR A))?

Thanks, again!!

---

<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: [28 March 2015 11:47 UTC](https://forum.dynare.org/t/obtaining-impulse-response-for-a-variable-outside-the-model/4583/7 "2015-03-28T11:47:32Z")

</div>

Please provide the file to replicate the issue.

---

<div class="post-metadata">

### Author: ![jrubin](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@jrubin](https://forum.dynare.org/u/jrubin)
#### Post date: [28 March 2015 12:31 UTC](https://forum.dynare.org/t/obtaining-impulse-response-for-a-variable-outside-the-model/4583/8 "2015-03-28T12:31:51Z")

</div>

Please see the attached file.  
Lines 166 is the output expression.  
My attempt based on the above suggestion is in lines 170-176.

Thanks, once again!  
[test\_jr.mod](https://forum.dynare.org/uploads/default/original/2X/5/5948a9e862b528d7f763df4c3eb37d546fe12489.mod) (5.15 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: [29 March 2015 09:23 UTC](https://forum.dynare.org/t/obtaining-impulse-response-for-a-variable-outside-the-model/4583/9 "2015-03-29T09:23:35Z")

</div>

Your code should most probably be

`//Constructing the irf for Output and M for the A1 (technology) shock:
Y1_irf_A1 = (K_t0_eps_A1 + oo_.steady_state(strmatch('K_t0',M_.endo_names,'exact'))).^(1-alpha);
Y2_irf_A1 = (U_t0_eps_A1 + oo_.steady_state(strmatch('U_t0',M_.endo_names,'exact'))).^(1-alpha);
Y3_irf_A1 = A1_t0_eps_A1 + oo_.steady_state(strmatch('A1_t0',M_.endo_names,'exact'));
Y4_irf_A1 = (1-d0)-(d2*(X_t0_eps_A1 + oo_.steady_state(strmatch('X_t0',M_.endo_names,'exact')))+d1*(X_t0_eps_A1 + oo_.steady_state(strmatch('A1_t0',M_.endo_names,'exact')))); 
Y_irf_A1 = Y1_irf_A1.*Y2_irf_A1.*Y3_irf_A1.*Y4_irf_A1;
M_irf_A1 = 1 -(mu_t0_eps_A1 + oo_.steady_state(strmatch('mu_t0',M_.endo_names,'exact'))).*Y_irf_A1.^(1-gamma);
`

---

<div class="post-metadata">

### Author: ![jrubin](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@jrubin](https://forum.dynare.org/u/jrubin)
#### Post date: [29 March 2015 14:19 UTC](https://forum.dynare.org/t/obtaining-impulse-response-for-a-variable-outside-the-model/4583/10 "2015-03-29T14:19:50Z")

</div>

Thanks Johannes, much appreciated!
