[FieldTrip] Some Questions on the resample design
Chao Wang
chaowang0704 at gmail.com
Tue May 7 14:08:57 CEST 2013
I'm sorry to make a mistake just now. The previous message sent didn't
fullfill my meaning.
I carefully inspected the code in the function *resampledesign* but I was
quite confused by the codes in the bootstrap section (For paired design,
the design matrix should be like this, design(1,:)=[1:N 1:N], design(2,1:N)=1
and design(2,N+1:2*N)=2 and N is for example the subject number; and
cfg.uvar=2):
91 Nvar = size(design,1); % number of factors or regressors
92 Nrepl = size(design,2); % number of replications
...
...
248 units = design(cfg.uvar,:);
249 for k = 1:length(unique(units))
250 sel = find(units==k);
251 indx(:,k) = sel;
252 Nrep(k) = length(sel);
253 end
254 resample = zeros(cfg.numrandomization, Nrepl);
...
...
274 tmp = zeros(cfg.numrandomization*10, Nrepl/Nrep(1));
275 for i=1:cfg.numrandomization*10
276 tmp(i,:) = *sort*(randsample(1:Nrepl/Nrep(1), Nrepl/Nrep(1)));
277 end
278 tmp = unique(tmp, 'rows');
279 fprintf('found %d unique rows in bootstrap matrix of %d bootstraps',
size(tmp,1), cfg.numrandomization*10);
...
...
292 for i=1:cfg.numrandomization
293 for k=1:size(indx,1)
294 resample(i,indx(k,:)) = indx(k,tmp(i,:));
295 end
296 end
My question was on the code in 276 line. These code was to generate a
number of rand numbers (about cfg.numrandomization lines) in the range of 1
to Nrepl/Nrep(1), in which Nrepl is the number of replications in the
design and Nrep is the number of repetition (Nrep(:)=2 for paired design).
If the function '*sort*' is used, then every row of matrix tmp is the same,
which will be 1,2,..., Nrepl/Nrep(1). And this will lead the 278 line to
the result: temp=1:Nrepl/Nrep(1) (because of the function unique). This
result is by no means what we want, I think. What we do want is several
rows numbers with same range but with distinct orders. Only in this way,
can we guarantee that each resample is not the same.
On Tue, May 7, 2013 at 2:35 PM, Chao Wang <chaowang0704 at gmail.com> wrote:
> I
> have been using field-trip. Recently, I tried to use it for statistic test
> by non-parametric method, e.g. bootstrap and permutation. As usual, the two
> method involve resample original data with or without replacement. I
> carefully inspected the code in the function *resampledesign* but I was
> quite confused by the method in the bootstrap section:
>
> 254resample = zeros(cfg.numrandomization, Nrepl);
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20130507/28b2f8eb/attachment-0002.html>
More information about the fieldtrip
mailing list