1
$\begingroup$

Is there any statistical test to determine that two sequence of numbers (e.g. numbers generated by uniform pseudorandom number generators) have a good cross-correlation (close to zero for all lags) with a desired significance level? (The ideal case in some applications is zero-cross correlation)

I've found some tests for randomness (like NIST and TestU01) but didn't find any test for cross-correlation or auto-correlation.

$\endgroup$
2
$\begingroup$

For auto-correlation, one can use the Box-Cox or variations (e.g. Ljung–Box) to test if any number of auto-correlations are jointly significant. The basis of these tests is that some weighted sum of square auto-correlations is roughly distributed Chi-Squared.

For joint tests of cross-correlations, you can a statistic (e.g. the mean/cum of the correlations), and just bootstrap to obtain standard errors/p-values to carry out the inference. The advantage of bootstrapping is that you don't need to derive the asymptotic distributions.

The following simple Matlab code illustrates what I am suggesting:

% Generate data: x and data are correlated at lag 1 and random lag
x               = randn(1000,1);
data            = x;
lagrand         = randi(1000,1);
lagnx           = lag(x,lagrand);
for ii = 1:99
   data        = [data,lag(x,ii)];
end   
y               = 0.5*x+0.5*lagnx + randn(1000,1);
% Cross-correlations, rolling average corr, cumulative corr
n               = 1:size(data,2);
corrs           = corr(y,data,'rows','pairwise');
avgcorr         = cumsum(corrs)./n;
cumcorr         = cumsum(corrs);
% Try to bootstrap the rolling average estimates 
bootsamples     = bootstrp(999,@(bootdata) 
cumsum(corr(y,bootdata,'rows','pairwise'))./(1:size(bootdata,2)),data);
StdErr          = nanstd(bootsamples);
% Try to bootstrap the cumulative sum estimates 
bootsamplescumsum       = bootstrp(999,@(bootdata) 
cumsum(corr(y,bootdata,'rows','pairwise')),data);
StdErrcumsum            = nanstd(bootsamplescumsum);

% Figure showing data,cross-correlations,avg,sum,errors
figure;
subplot(2,2,1);
plot(data)
hold on;
plot(y); 
legend('x','data');
hold off;
subplot(2,2,2);
bar(corrs);
hold on;
plot(avgcorr)
plot(cumcorr)
hold off;
legend('Cross-correlations','Rolling Average','Cumulative Sum');
subplot(2,2,3);
bar(corrs);
hold on;
plot(avgcorr) 
plot(avgcorr+2*StdErr,'-r');
plot(avgcorr-2*StdErr,'-r');
hold off;
legend('Cross-correlations','Rolling Average','95% Conf. Int.');
subplot(2,2,4);
bar(corrs);
hold on;
plot(cumcorr)
plot(cumcorr+2*StdErrcumsum,'-r');
plot(cumcorr-2*StdErrcumsum,'-r');
hold off;
legend('Cross-correlations','Cumulative Sum','95% Conf. Int.');
$\endgroup$
  • 1
    $\begingroup$ Welcome to CV, good answers attract more votes and acceptance and will provide a bit more context and explanation beyond simply stating a suggestion. Why are your suggestions good? What assumptions might be relevant? see stats.stackexchange.com/help/how-to-answer for advice on good answers $\endgroup$ – ReneBt Mar 13 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.