# Input Data (Bayesian estimation)

**URL:** <https://forum.dynare.org/t/input-data-bayesian-estimation/20469>\
**Category:** ML/Bayesian estimation\
**Created:** [1 June 2022 14:18 UTC](https://forum.dynare.org/t/input-data-bayesian-estimation/20469 "2022-06-01T14:18:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mih](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/b782af/32.png) [@Mih](https://forum.dynare.org/u/Mih)\
**Post date:** [1 June 2022 14:18 UTC](https://forum.dynare.org/t/input-data-bayesian-estimation/20469/1 "2022-06-01T14:18:46Z")

</div>

My question is related to Gali chapter 8 (implemented by prof. Pfeifer) and the accurate way to read data from a file.

On github, you mentioned that _all variables are in log-deviations from the steady state, but interest rate which is mean 0._

After reading the guide on observable variables, I proceeded the following way:

- GDP (real quarterly volumes) → log(gdp) → get cylical component using univariate-HP filter  
Read it from the file like: **y\_obs = yhat** or **y\_obs = y\_gap**

- Nominal interest rate (net annual percentages) → make it quarterly percentages ln(1 + rate/400) → get cyclical component using univariate-HP filter  
Read it from the file like: **i\_obs = i**

- Inflation Rate (net quarterly percentages) → get cyclical component using univariate-HP filter  
Read it from the file like: **pi\_obs = pi**

**Question 1:** You mentioned that interest rate is mean 0, not in log-deviations from steady state. HP-filter also demeans the data and the cyclical component is mean 0. Nonetheless, shouldn’t there be a difference between the way you match output gap and how you match inflation / interest rate given one is mean 0 and the others in log-deviations?

**Question 2** : Given that all variables (but the abovementioned ones) are in log-deviations, is it appropriate to just detrend variables (log consumption per capita, log NX per capita) using univariate HP filter and consider the cyclical component as log-deviation from steady state and read it like **c\_obs = c & c\_NX = NX** plus some shock to avoid stochastic singularity?

**Question 3** : Is it ok to just take the log difference of variables such as nominal exchange and read it like **er\_obs = er - er(-1) + eps\_er**. I don’t understand why this is appropriate…I saw a lot of posts where people read variables like this, but I did not really understand why - er in the model is log deviation from steady state while er\_obs is basically log difference of nominal rates → growth rate. How do these two match?

Thank you

---

<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 June 2022 08:01 UTC](https://forum.dynare.org/t/input-data-bayesian-estimation/20469/3 "2022-06-02T08:01:22Z")

</div>

1. I don’t understand the question. A log deviation from steady state is mean 0.
2. Yes, you can do that, because you simply take out your concept of a trend.
3. A log deviation from steady state is \hat x\_t= log(x\_t)-log(\bar x). Thus, the steady state part drops out in the difference:  
\hat x\_t-\hat x\_{t-1}= log(x\_t)-log(\bar x)-(log(x\_{t-})-log(\bar x))=log(x\_t)-(log(x\_{t-})
4. What do you mean with univariate HP-filter? The one-sided HP filter?

---

<div class="post-metadata">

**Author:** ![Mih](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/b782af/32.png) [@Mih](https://forum.dynare.org/u/Mih)\
**Post date:** [2 June 2022 09:25 UTC](https://forum.dynare.org/t/input-data-bayesian-estimation/20469/4 "2022-06-02T09:25:16Z")

</div>

1. On github, you mentioned nominal interest rate separately from the other variables (as being in mean 0 rather than log-levels). I thought I had to read it from a file in a different way: _interest rate and natural output are not in log-levels, but rather mean 0_  
I did not understand the meaning of that statement and I got confused a bit.

2. Ok, so basically, you can take the cyclical component of any variable and match it exactly to an existing variable if I understood correctly (obs\_variable = model\_variable + shock) where the observable variable is the cyclical component using a one-sided filter. Maybe I’ve missed in the guide, but is there a suggested way to tackle variables that can be negative such as NX and you cannot take the log of?

3. Ok - basically obs\_variable = model\_variable - model\_variable(-1) + shock, where I take the log difference of my observable

4. Yes, one-sided HP filter (hpfilter1s from eviews more precisely)

Thank you

---

<div class="post-metadata">

**Author:** ![Mih](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/b782af/32.png) [@Mih](https://forum.dynare.org/u/Mih)\
**Post date:** [2 June 2022 12:02 UTC](https://forum.dynare.org/t/input-data-bayesian-estimation/20469/5 "2022-06-02T12:02:11Z")

</div>

One follow-up question regarding your guide

If you take the log difference of your data (non-zero mean) and then demean it (now zero mean), do you match it like this?

XLS File:  
obs\_variable = log(obs\_variabile\_volume) - log(obs\_variable\_volume-1) =\> growth rates ~ 0.01 mean ~so around 1% mean which does not match the model variable which is mean 0

=\> I demean it like: log(obs\_variabile\_volume) - log(obs\_variable\_volume-1) - average(log(obs\_variabile\_volume) - log(obs\_variable\_volume-1))

Dynare:  
**obs\_variable = model\_variable - model\_variable(-1)**

Or how do you specify you demeaned the data in log differences eXplictly when you read from the file? My guess you **do not have to** , as you match demeaned log-differences which is 0 mean which is already the variable in the model.

---

<div class="post-metadata">

**Author:** ![Mih](https://forum.dynare.org/letter_avatar_proxy/v4/letter/m/b782af/32.png) [@Mih](https://forum.dynare.org/u/Mih)\
**Post date:** [3 June 2022 00:46 UTC](https://forum.dynare.org/t/input-data-bayesian-estimation/20469/6 "2022-06-03T00:46:43Z")

</div>

I think I solved it myself (hopefully).

If you use one-sided HP filter or you demean the data in log-difference is the same and in both situations, you can match data like:

obs\_variable = model\_variable + measurement\_error

P.S: The only thing is…what if the data in log differences is mean 0… demeaning it seems meaningless.

---

<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:** [6 June 2022 12:02 UTC](https://forum.dynare.org/t/input-data-bayesian-estimation/20469/7 "2022-06-06T12:02:01Z")

</div>

1. The statement is about the comparison to the book. Gali uses the log level of the interest rate, not the percentage deviation from steady state.
2. I don’t get where a shock will come from in your equation unless you assume measurement error. Regarding net exports, a typical way is to use the net export share as an observable instead of log net exports.
3. Yes, you would match demeaned first differences, where you use

> [@Mih](#):
>
> log(obs\_variabile\_volume) - log(obs\_variable\_volume-1) - average(log(obs\_variabile\_volume) - log(obs\_variable\_volume-1))
