# Cross-correlation between two variables

Hi everyone,
I have a question about cross-correlation function and its application. In many papers, the cross-correlation between two simulated variables is positive at different lags (Y_t X_t+tau, tau=(-5:5)) for example. I joined a cross-correlation between two times series with negative value for lags between -5 and 1 and positive after.
Ignoring the significance of the cross-correlation, how can I interpret in economic terms the lags -5 which is negative and lag 5 which is positive ?
corr.pdf (26.1 KB)

It is the temporal correlation between Y today and X at a lead or lag. If the correlation at \tau=5 is positive, it means that whenever X is high, five periods later Y tends to be high as well. This is typically interpreted as X leading Y. If the correlation at \tau=-5 is negative, then if Y is high today, X tends to be low five periods later.

It’s more clear in my head.
Best,

Hi,
is it possible to obtain the cross-correlations at different lags between two variables directly from the Dynare output after running the stoch_simul command? Or do I need to run a simulation first? How can I then obtain the cross-correlations?
I hope I didn’t cross-post… but I couldn’t find this information anywhere in the forum.
Thanks!

See the manual on oo_.autocorr. You can get this as theoretical moments.

Thank you!

Hi,
I’m running a two country-model and I’m trying to get information on cross-country correlations of certain variables.
I tried it two different ways:

1. “Theoretical Correlations”:

I ran the .mod file which contains
stoch_simul(order = 1, nograph, noprint);

Then I calculate the correlation between output in the two countries as:
iY1=inx(‘Y1’,vardecl);
iY2=inx(‘Y2’,vardecl);
a1_corr_Y=oo_.var(iY1,iY2)/(oo_.var(iY1)^0.5*oo_.var(iY2)^0.5);

1. “Simulated Correlations”

I run a .mod file which contains the commands
stoch_simul(order=2,periods=1,simul_replic=1000,drop=0,nograph,noprint);
simulated_series=get_simul_replications(M_,options_);

Then I calculate the correlations as follows

sim_ser=squeeze(simulated_series);
covY1Y2 = cov(sim_ser(iY1,:),sim_ser(iY2,:));
covY1Y2 = covY1Y2(2,1);
a2_corr_Y=covY1Y2/(std(sim_ser(iY1,:))*std(sim_ser(iY2,:)));

I get completely different results. Am I overseeing something? Or did I make a mistake somewhere, otherwise the correlations would be similar?

1. Why do you not rely on Dynare’s output? The contemporaneous_correlation options should provide it. You can also check whether the simulated and theoretical moments are close.