# Calculating correlation problem in "practicing dynare"

Hi,

I am replicaating “Practicing dynare” by F. Barillas et al, and calcualted correlations of simulated variables. But the results are little bit weird because the differences between matlab results and excel results are very big. Mean is similar, but variance and correlation matrix results are very different.

Is there anyone who has similar problem with me and know the answer?

I attached the file.

And I calculate the variance and correlation simulated data in “oo_endo_simul” using excel, and I compare those value with dynare results.

VARIABLE c k lab z i
c 1.0000 0.2143 0.9344 0.9573 0.9458
k 0.2143 1.0000 -0.1461 -0.0757 -0.1142
lab 0.9344 -0.1461 1.0000 0.9972 0.9985
z 0.9573 -0.0757 0.9972 1.0000 0.9984
i 0.9458 -0.1142 0.9985 0.9984 1.0000

But in excel

correlation between c and k 0.95389421
correlation between c and labor 0.422859729

So, I am confused what is wrong with simulation data.

Thank you.
practicing.mod (776 Bytes)

You specified the hp_filter option. Dynare then computes data from HP-filtered simulations, but the simulated data is not filtered.

I have one more question in your gali(2008) code.

Money demand function is :
m_growth_ann=4*(y-y(-1)-eta*(i-i(-1))+pi);

and the value of eta=4, but

if I log linearize based on money in utility function in the Dr. Gali’s slide, page 16

the coefficient becomes -1/v *[exp(-i)/(1-exp(-i)]i_t so it is close to positive 99.

Also, in his book, eta=1/(vi), then this is close to 99.

So I am confused why the value of eta is different with loglinearized value. In the book, Dr. Gali explained that it is the value of OLS estimate, but there is bid difference between loglinearized value and assigend value(=4).
And
eps_nu = 0.25^2, you said this is 1 standard deviation shock of 25 basis points, i.e. 1 percentage point annualized,
but the steady state of interest rate is about 0.12, therefore increasing 0.25 is actually 25%.

Please let me know if my understanding is wrong.
ch2slides-num-1.pdf (140 KB)

My model of Gali (2008), Chapter 2 posits an ad-hoc money demand function as on page 5 of the slides you posted. You are in contrast looking at the model with money in the utility function, which gives rise to a different money demand function. As Gali provides no parameter values in Chapter 2, I used the ones of Chapter 3. The final eta should nevertheless be the same and be around 4 as it represents the interest elasticity of money demand.

Regarding your second question: the model is linear and thus scale-invariant. See “Remark 10 (Scaling With a Factor 100)” in See “Remark 10 (Scaling With a Factor 100)” in Pfeifer (2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models”

But I am still confused, and hard to understand in your paper.

every equations are expressed in log linearized level, therefore logc_t-logc_{t-1} is written as c-c(-1).

This means that, if c=3.2 abd c(-1)=3.1, then the difference between two values (3.2-3.1=0.1) is 10% change.

## ir=rho+phi1infl+phi2y+v; v=rhov*v(-1)+ev; var ev; stderr 0.25;

so if v=0.25, then in my opinion, this means 25%.

Also, I am confusing that the unit of output graph( I attached the output graph), in the graph, output gap decrease -0.2, then does this mean -0.2 percent?
I am confusing that there is no transformation code in dynare, which changes the unit from log level to 100* log. Could you tell me where it is.

Could you please tell me what I miss?
MATLAB.pdf (9.82 KB)

You are missing the linearity. The linear model solution is a linear VAR in the states. By using a standard deviation of 1 as 1 percent, I have effectively multiplied the whole equation by 100. If this bothers you, just do it as you suggest. It will give exactly the same IRFs, but they are smaller by a factor of 100.

But one thing I have difficulty to understand is that " By using a standard deviation of 1 as 1 percent, I have effectively multiplied the whole equation by 100". What does this sentence mean? Could you please explain this more specifically?

I was not able to find the part where you multiply 100 in your code in linear case.

Thank you.

This is a matter of interpretation. Nothing needs to be done in the code. Due to linearity, the IRF to a shock of size of 1 is the same as an IRF to a shock size of 0.01 that is multiplied by 100.