calculating correlation problem in "practicing dynare"

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

calculating correlation problem in "practicing dynare"

Postby dynarethinker » Wed Feb 25, 2015 8:28 am

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?
dynarethinker
 
Posts: 7
Joined: Wed Feb 25, 2015 8:19 am

Re: calculating correlation problem in "practicing dynare"

Postby jpfeifer » Wed Feb 25, 2015 9:47 am

Please provide more information to be able to replicate the issue.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: calculating correlation problem in "practicing dynare"

Postby dynarethinker » Wed Feb 25, 2015 7:38 pm

Thank you for your quick reply.

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.
Attachments
practicing.mod
(776 Bytes) Downloaded 43 times
dynarethinker
 
Posts: 7
Joined: Wed Feb 25, 2015 8:19 am

Re: calculating correlation problem in "practicing dynare"

Postby jpfeifer » Thu Feb 26, 2015 6:17 am

You specified the hp_filter option. Dynare then computes data from HP-filtered simulations, but the simulated data is not filtered.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: calculating correlation problem in "practicing dynare"

Postby dynarethinker » Thu Feb 26, 2015 7:53 am

Thank you for your answer. I appreciate it. I made mistakes in my code.

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%.

Could you please explain about this?
Please let me know if my understanding is wrong.
Attachments
ch2slides-num-1.pdf
(139.53 KiB) Downloaded 58 times
dynarethinker
 
Posts: 7
Joined: Wed Feb 25, 2015 8:19 am

Re: calculating correlation problem in "practicing dynare"

Postby jpfeifer » Thu Feb 26, 2015 8:07 pm

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 Pfeifer (2013): "A Guide to Specifying Observation Equations for the Estimation of DSGE Models" at https://sites.google.com/site/pfeiferecon/Pfeifer_2013_Observation_Equations.pdf
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: calculating correlation problem in "practicing dynare"

Postby dynarethinker » Fri Feb 27, 2015 1:33 am

Thank you for your reply.

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

in your model,
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.

In your code,
---------------------------------------
ir=rho+phi1*infl+phi2*y+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?
Attachments
MATLAB.pdf
(9.82 KiB) Downloaded 77 times
dynarethinker
 
Posts: 7
Joined: Wed Feb 25, 2015 8:19 am

Re: calculating correlation problem in "practicing dynare"

Postby jpfeifer » Fri Feb 27, 2015 7:22 am

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: calculating correlation problem in "practicing dynare"

Postby dynarethinker » Sat Feb 28, 2015 3:41 am

Thank you for your quick reply, and I understand what you say in your reply and in your paper.

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.
dynarethinker
 
Posts: 7
Joined: Wed Feb 25, 2015 8:19 am

Re: calculating correlation problem in "practicing dynare"

Postby jpfeifer » Sat Feb 28, 2015 4:54 pm

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: calculating correlation problem in "practicing dynare"

Postby dynarethinker » Sun Mar 01, 2015 7:30 pm

Thank you for your reply.

It took time for me to understand what you said and wrote in your paper.
Therefore, after the shock part, linearized equation is rescaled (X100) due to the 100X shocks. Is my understanding correct?
Thank you.
dynarethinker
 
Posts: 7
Joined: Wed Feb 25, 2015 8:19 am

Re: calculating correlation problem in "practicing dynare"

Postby jpfeifer » Sun Mar 01, 2015 8:33 pm

Yes, exactly.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: calculating correlation problem in "practicing dynare"

Postby dynarethinker » Mon Mar 02, 2015 4:09 am

Thank you for your kind explanations. I appreciate it.
dynarethinker
 
Posts: 7
Joined: Wed Feb 25, 2015 8:19 am


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 10 guests