Lead and Lag

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.

Lead and Lag

Postby econphd » Fri Mar 25, 2016 2:54 pm

Hi All,

You might find this questions quite easy but I need a help about finding the ' Correlations of variables with lead and lagged Y ' . For example: fprintf('%20s \t %3.2f\n','rho(y,w)',correlations(4))----This gives Contemporaneous correlation between wage and output.

How I can find the 2 leads and lags for these variables?

// HP-filter the non-stationary time series;

[ytrend,ycyclical]=sample_hp_filter([ly_nonstationary lcons_nonstationary lh_nonstationary linv_nonstationary lw_nonstationary ly_h_nonstationary],100);

//compute standard deviations
standard_devs=std(ycyclical);

//compute relative standard deviations
relative_standard_devs=standard_devs./standard_devs(1);

//compute autocorrelations
autocorrelations(1,1)=corr(ycyclical(2:end,1),ycyclical(1:end-1,1));

//compute correlations
correlations=corr(ycyclical(:,1),ycyclical(:,2:end));

//Display everything
fprintf('\n Table 1 - Moments\n');
fprintf('%20s \t %3.2f\n','sigma(y)',standard_devs(1,1));
fprintf('%20s \t %3.2f\n','sigma(c)/sigma(y)',relative_standard_devs(2));
fprintf('%20s \t %3.2f\n','sigma(h)/sigma(y)',relative_standard_devs(3));
fprintf('%20s \t %3.2f\n','sigma(i)/sigma(y)',relative_standard_devs(4));
fprintf('%20s \t %3.2f\n','sigma(w)/sigma(y)',relative_standard_devs(5));
fprintf('%20s \t %3.2f\n','sigma(y_h)/sigma(y)',relative_standard_devs(6));
fprintf('%20s \t %3.2f\n','rho(y)',autocorrelations(1,1));
fprintf('%20s \t %3.2f\n','rho(y,c)',correlations(1));
fprintf('%20s \t %3.2f\n','rho(y,h)',correlations(2));
fprintf('%20s \t %3.2f\n','rho(y,i)',correlations(3));
fprintf('%20s \t %3.2f\n','rho(y,w)',correlations(4));
fprintf('%20s \t %3.2f\n','rho(y,y_h)',correlations(5));

Thanks in advance.
econphd
 
Posts: 31
Joined: Fri Mar 25, 2016 2:39 pm

Re: Lead and Lag

Postby jpfeifer » Sat Mar 26, 2016 6:20 am

By shifting the variables:
Code: Select all
correlations=corr(ycyclical(2:end,1),ycyclical(1:end-1,2:end));

will provide the correlation between y_t and x_{t-1}
------------
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


Return to Dynare contributions and examples

Who is online

Users browsing this forum: No registered users and 4 guests