Page 1 of 1

Lead and Lag

PostPosted: Fri Mar 25, 2016 2:54 pm
by econphd
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.

Re: Lead and Lag

PostPosted: Sat Mar 26, 2016 6:20 am
by jpfeifer
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}