# Comparing IRFs from VAR fitted on simulated and real data

**URL:** <https://forum.dynare.org/t/comparing-irfs-from-var-fitted-on-simulated-and-real-data/21892>\
**Category:** ML/Bayesian estimation\
**Created:** [4 February 2023 18:46 UTC](https://forum.dynare.org/t/comparing-irfs-from-var-fitted-on-simulated-and-real-data/21892 "2023-02-04T18:46:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dam](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/f04885/32.png) [@Dam](https://forum.dynare.org/u/Dam)\
**Post date:** [4 February 2023 18:46 UTC](https://forum.dynare.org/t/comparing-irfs-from-var-fitted-on-simulated-and-real-data/21892/1 "2023-02-04T18:46:49Z")

</div>

Hi,

I want to compare IRFs from a VAR fitted on model-generated data with IRFs from a real-data VAR (in the spirit of Sims-Cogley-Nason approach). I am using the _NK-baseline_ in the Dynare ‘example’ folder. My question is: How should I transform real data to be sure that I estimate the same VAR on simulated data and real ones?

As far as I understand, the _NK-baseline_ is not log-linearized and is entered in stationary form. So the output is represented by stationary variables in levels (Am I Correct?). Suppose that I then fit a VAR on yd, c, PI and R from the model.

Next, I take FRED data on real output (per worker) , consumption, inflation and the Fed Fund. To make the resulting IRFs comparable with those of the model-VAR, Should I (i) detrend the real variables (actually just Y and C) e.g. by first-diff or one-sided HP and then (ii) run the VAR?  
Moreover, should I take logged variable to solve scaling issues?

Or, alternatively, Can I use _stoch\_simul(loglinear)_ and then use a VAR in log-levels for real data (after having detrended them)?

Is what I propose correct?

Many 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:** [5 February 2023 21:45 UTC](https://forum.dynare.org/t/comparing-irfs-from-var-fitted-on-simulated-and-real-data/21892/2 "2023-02-05T21:45:11Z")

</div>

It’s probably easiest to define growth rates in the model (the log difference of the stationary variables plus the trend growth) and then match that to growth rates in the data for the purpose of estimation. In that case, you will estimate the auxiliary VAR on the same data concept: growth rates of nonstationary variables.

---

<div class="post-metadata">

**Author:** ![Dam](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/f04885/32.png) [@Dam](https://forum.dynare.org/u/Dam)\
**Post date:** [6 February 2023 10:02 UTC](https://forum.dynare.org/t/comparing-irfs-from-var-fitted-on-simulated-and-real-data/21892/3 "2023-02-06T10:02:06Z")

</div>

Thank for the answer!

I didn’t get it completely. I simulate the model and take, say, yd, c and PI. To define growth rates I do log(diff(yd). How do I add trend growth then?

Second, if data are nonstationary but not cointegrated, estimating a VAR using growth rates is fine. But if there is cointegration (e.g. between C and Y) estimating a VAR in levels (or a VECM) would be better. Is there any alternative than to fit a VAR in growth rates of nonstationary variables?

Thank you 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:** [7 February 2023 16:57 UTC](https://forum.dynare.org/t/comparing-irfs-from-var-fitted-on-simulated-and-real-data/21892/4 "2023-02-07T16:57:26Z")

</div>

Have a look at Pfeifer(2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models” [sites.google.com/site/pfeiferecon/Pfeifer\_2013\_Observation\_Equations.pdf](https://sites.google.com/site/pfeiferecon/Pfeifer_2013_Observation_Equations.pdf)  
at the part with models with explicitly specified trends. You need to add the trend growth factor `mu_z` back to most variables’ growth rates.

Your model implies cointegration. You could also run a VECM or a VAR in levels. For that, you could simply cumulate the growth rates from the model to obtain levels. You should be able to start at arbitrary initial levels.

---

<div class="post-metadata">

**Author:** ![Dam](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/f04885/32.png) [@Dam](https://forum.dynare.org/u/Dam)\
**Post date:** [9 February 2023 11:33 UTC](https://forum.dynare.org/t/comparing-irfs-from-var-fitted-on-simulated-and-real-data/21892/6 "2023-02-09T11:33:19Z")

</div>

Ok now it’s very clear.

Just one last point: when you say “cumulate growth rates” to obtain levels, you mean something like:

 ![image](https://forum.dynare.org/uploads/default/original/2X/5/5cac3fdd7e4fd80db2fd019ac015f75131980cbd.png)

where theta\_j is the growth rate of the stationary variable.

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 February 2023 18:23 UTC](https://forum.dynare.org/t/comparing-irfs-from-var-fitted-on-simulated-and-real-data/21892/7 "2023-02-12T18:23:31Z")

</div>

Yes, but given that everything is in logs, it will become additive.
