# Using bootstrp with matrices to bootstrap cross-correlations using xcorr?

4 Ansichten (letzte 30 Tage)
Maheen Siddiqui am 18 Sep. 2020
Beantwortet: Jeff Miller am 19 Sep. 2020
Hello,
I am using Matlab's
xcorr
function to calculate the cross-correlation between two time-series. In order to assess statistical significance, I need to perform bootstrapping and create random correlations between the two time-series to create a null distribution. So e.g. timeseries1 is size 16x11 (which is 16 time points and 11 subjects) and timeseries2 is also size 16x11. Here the subjects are matched pairs so, for example, timeseries1(:,1) is matched to timeseries2(:,1) - i.e. timeseries1 is one type of data from subject one and timeseries2(:,1) is a different type of data from subject one.
I need to scramble them such that I create new random correlations such as timeseries1(:,1) wit timeseries2(:,5) etc.
I was trying to use the `boostrp` function in Matlab as follows
scorr = @(timseries1,timeseries2)(xcorr(timseries1,timeseries2,'coeff'));
bootstat = bootstrp(1000,scorr,a,b);
However, I'm getting an error because bootstrap only accepts vectors and not matrices. In the documentation of the function, all the examples that are provided have data that is 1 value per subject so for example LSAT score from 15 subjects correlated with other test score from 15 subjects. But I have 16 samples per subject and I won't be able to do a cross-correlation if I reduce the time-series to one-time point.
Does anyone have any advice on how this can be done? I'm also happy to shift to R if this is easier to do in R...
Thanks!
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (1)

Jeff Miller am 19 Sep. 2020
Bootstrapping involves taking random resamples of the existing data to create datasets of the same size, but it is not exactly what that means in your situation.
For example, one possibility would be to take random resamples of the 11 subjects. For each sample of subjects i, use the existing 16 values of timeseries1(:,i) and timeseries2(:,i) and compute the xcorr on those data.
Another possibility would be to take random resamples of the 16 time points. For each sample of time points j, use the existing 11 values of timeseries1(j,:) and timeseries2(j,:) and compute the xcorr on those data.
Some more elaborate procedure would randomly take subsamples of subjects and time points. The bootstrp function doesn't handle situations with structured data like this, because in such situations there is no simple way to defined what it means to take a random resample.
My advice is to write your own random sampling function so that you can make sure the randomization works exactly as you intend. (In my experience, coding this function is not nearly as difficult as deciding exactly how the randomization should work in the particular case.) For each set of random data you construct, you can then call xcorr and keep track of the 1000 or so xcorr values that you get.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Correlation and Convolution finden Sie in Help Center und File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by