# [R] multiple paired t-tests without loops

Matthew Finkbeiner matthew.finkbeiner at maccs.mq.edu.au
Sat Apr 24 12:49:07 CEST 2010

```I am new to R and I suspect my problem is easily solved, but I haven't
been able to figure it out without using loops.  I am trying to
implement Blair & Karniski's (1993) permutation test.  I've included a
sample data frame below.  This data frame represents the conditional
means (C1, C2) for 3 subjects in 2 consecutive samples of a continuous
data set (e.g. ERP waveform).  Each sample includes all possible
permuations of the subject means (2^N), which is 8 in this case.

The problem: I need to run a paired t-test on each SampleXPermutation
set and save the maximum t-value obtained for each sample.  The real
data set has 16 subjects (2^16 permutations) and 500 samples, which
leads to more than 32 million t-tests.  I have a loop version of the
program working, but it would take a few weeks to complete the job and I
was hoping that someone could tell me how to do it faster?

thank you kindly,

Matthew Finkbeiner

--------------------------------

"Sample"	"C1"	"C2"	"PermN"
1	5	8	perm1
1	4	3	perm1
1	6	4	perm1
2	2	6	perm1
2	3	1	perm1
2	7	4	perm1
1	8	5	perm2
1	3	4	perm2
1	6	4	perm2
2	6	2	perm2
2	1	3	perm2
2	7	4	perm2
1	5	8	perm3
1	3	4	perm3
1	6	4	perm3
2	2	6	perm3
2	1	3	perm3
2	7	4	perm3
1	8	5	perm4
1	4	3	perm4
1	4	6	perm4
2	6	2	perm4
2	3	1	perm4
2	4	7	perm4
1	5	8	perm5
1	4	3	perm5
1	4	6	perm5
2	2	6	perm5
2	3	1	perm5
2	4	7	perm5
1	8	5	perm6
1	3	4	perm6
1	4	6	perm6
2	6	2	perm6
2	1	3	perm6
2	4	7	perm6
1	5	8	perm7
1	3	4	perm7
1	4	6	perm7
2	2	6	perm7
2	1	3	perm7
2	4	7	perm7
1	8	5	perm8
1	4	3	perm8
1	6	4	perm8
2	6	2	perm8
2	3	1	perm8
2	7	4	perm8

--
Dr. Matthew Finkbeiner
Senior Lecturer & ARC Australian Research Fellow
Macquarie Centre for Cognitive Science (MACCS)
Macquarie University, Sydney, NSW 2109

Phone: +61 2 9850-6718
Fax:   +61 2 9850-6059
Homepage: http://www.maccs.mq.edu.au/~mfinkbei
Lab Homepage: http://www.maccs.mq.edu.au/laboratories/action/

```