Documentation of lagged_correlation


Global Index (short | long) | Local contents | Local Index (short | long)


Help text

  Load PCS:

Cross-Reference Information

This script calls

Listing of script lagged_correlation


clear

%cd /home/disk/hayes2/dvimont/csiro/matlab_data/Heat_Content
%load LP10_detrend_L1-7_yr101-1000.mat
%pcs = -1*pcs;

tim = 101:1000;
lags = -30:30; nlag = length(lags);

lims = [180 270 -6 6];
ct = getnc('temp', lims, 1, tim);
ct = squeeze(mean(mean(ct, 2), 3));

lims1 = [160 180 30 37.5];
lims2 = [170 190 45 52.5];

tx1 = getnc('taux', lims1, 1, tim);
tx2 = getnc('taux', lims2, 1, tim);
txind = squeeze(mean(mean((tx1 - tx2), 2), 3));

tx = detrend(txind); pcs = detrend(ct);
[b1, a1] = butter(9, 2/9);
[b2, a2] = butter(9, 2/15);
tx = filtfilt(b1, a1, tx)-filtfilt(b2, a2, tx);
pcs = filtfilt(b1, a1, pcs)-filtfilt(b2, a2, pcs);

clear ac r;
for i = 1:nlag;
  ac(i) = corr(pcs(:,1), pcs(:,1), lags(i));
  r(i) = corr(tx, pcs(:,1), lags(i));
end

figure(1); figure_orient;
subplot(3,1,1);
  bar(lags, ac);
  xlabel('Lag in Years');
  title(['Autocorrelation function for the CT index']);
  axis([-15 15 -1.1 1.1]);
  set(gca, 'YTick', -1:.2:1, 'XTick', -20:2:20);
  grid on
  ylabel('Correlation Coefficient')

r_exp = r((nlag+1)/2).*ac;

fishz = 0.5 * log((1+r)./(1-r));
fishmu = 0.5 * log((1+r_exp)./(1-r_exp));

dof = dof_corr(tx, pcs(:,1));
dof = (dof/2) - 3;

sigz = 1 ./ sqrt(dof);

subplot(3,1,3);
  bar(lags, fishz);
  hold on;
    plot(lags, fishmu, '-k', ...
         lags, fishmu+1.96*sigz, '--k', ...
         lags, fishmu-1.96*sigz, '--k');
  hold off
    axis([-15 15 -.6 .6]);
    set(gca, 'YTick', -2:.2:2, 'XTick', -20:2:20);
    grid on

title('Fisher''s Z-Statistic for < CT, NPTX >, with 95% Confidence Intervals');
xlabel('Lag in years (negative lag implies NPTX leads CT)');
ylabel('Correlation Coefficient')

%  Now do the same for the WSTP

tx = getheat([125 150 7.5 17.5], 4:7, tim);
tx = squeeze(mean(mean(tx, 2), 3));

[b, a] = butter(6, 2/10);
tx = filtfilt(b, a, detrend(tx));
pcs = filtfilt(b, a, detrend(pcs));

clear ac r;
for i = 1:nlag;
  ac(i) = corr(pcs(:,1), pcs(:,1), lags(i));
  r(i) = corr(tx, pcs(:,1), lags(i));
end

r_exp = r((nlag+1)/2).*ac;

fishz = 0.5 * log((1+r)./(1-r));
fishmu = 0.5 * log((1+r_exp)./(1-r_exp));

dof = dof_corr(tx, pcs(:,1));
dof = (dof/2) - 3;

sigz = 1 ./ sqrt(dof);

subplot(3,1,2);
  bar(lags, fishz);
  hold on;
    plot(lags, fishmu, '-k', ...
         lags, fishmu+1.96*sigz, '--k', ...
         lags, fishmu-1.96*sigz, '--k');
  hold off
    axis([-15 15 -1.2 .6]);
    set(gca, 'YTick', -2:.2:2, 'XTick', -20:2:20);
    grid on

title('Fisher''s Z-Statistic for < CT, WSTP >, with 95% Confidence Intervals');
xlabel('Lag in years (negative lag implies WSTP leads CT)');
ylabel('Correlation Coefficient')

colormap([.65 .65 .65]);


lims = [135 200 35 52.5]
[tx, ty] = getnc('taux', 'tauy', lims, 1, tim);
[lat, lon] = getll('taux', lims);

rtx = regress_eof(tx, pcs, lags);
rty = regress_eof(ty, pcs, lags);

clear curlt;
for i = 1:length(lags);
  tx = squeeze(rtx(i,:,:)); ty = squeeze(rty(i,:,:));
  [curlt(i,:,:), lat2, lon2] = sph_curl1(tx, ty, lat, lon, 0);
end