Computing autocorrelations

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.

Computing autocorrelations

Postby emartinezgar » Tue Nov 29, 2011 1:33 am

Hi,

I'm wondering how dynare computes autocorrelations and how to replicate the results with matlab formulas. I have been trying to replicate the autocorrelations from simulated data using the matlab function autocorr, but I still find a discrepancy with the dynare autocorrelations that I would like to understand. I'm using dynare version 4.2.2 with Matlab version 7.13.0.564. I have a rather simple linear model that I have calibrated. I simulate the model over 160 periods with the following command line:

set_dynare_seed(1); stoch_simul(periods=160,drop=0,order=1);

To compute the autocorrelations I use autocorr (http://www.mathworks.com/help/toolbox/e ... ocorr.html). For instance, for the first variable---which I call var1---I would write:

acfvar1=autocorr(oo_.endo_simul(1,options_.drop+1:end)',5)

and I would obtain:

acfvar1 =
0.9489 0.9026 0.8481 0.8029 0.7634

Now compare those numbers to the autocorrelation results that dynare provides for the same variable:

0.9436 0.8979 0.8446 0.8005 0.7612

with differences equal to:

-0.0053 -0.0047 -0.0035 -0.0024 -0.0022

These are not large discrepancies, but I'm not sure why they do occur and I'm concerned I am missing something important. Can anyone help me figure out why autocorr is giving me slightly different results and suggest how to correct for it in order to match the output that dynare reports?

Thanks so much!
emartinezgar
 
Posts: 4
Joined: Mon Sep 26, 2005 6:38 pm

Re: Computing autocorrelations

Postby SébastienVillemot » Wed Dec 21, 2011 4:20 pm

I guess Dynare is not using the same normalizing constant for the empirical autocorrelation: Dynare divides by N-ar where ar is the maximum number of lags.

You can see what Dynare does exactly by looking at the "disp_moments.m" file in the "matlab" subdir.

Best,
Sébastien Villemot
Economist at OFCE – Sciences Po
SébastienVillemot
 
Posts: 706
Joined: Fri Dec 07, 2007 2:29 pm
Location: Paris, France


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 10 guests