[R] (Fisher) Randomization Test for Matched Pairs: Permutation Data Setup Based on Signs

Ghandalf moolag- at hotmail.com
Fri Mar 9 06:49:20 CET 2012


Hi,

I am currently attempting to write a small program for a randomization test
(based on rank/combination) for matched pairs. If you will please allow me
to introduce you to some background information regarding the test prior to
my question at hand, or you may skip down to the bold portion for my issue. 

There are two sample sizes; the data, as I am sure you guessed, is matched
into pairs and each pair's difference is denoted by Di. 

The test statistic =*T* = Sum(Di) (only for those Di > 0). 

The issue I am having is based on the method required to use in R to setup
the data into the proper structure. I am to consider the absolute value of
Di, without regard to their sign. There are 2^n ways of assigning + or -
signs to the set of absolute differences obtained, where n = the number of
Dis. That is, we can assign + signs to all n of the |Di|, or we might assign
+ to |D1| but - signs to |D2| to |Dn|, and so forth.

 So, for example, if I have *D1=-16, D2=-4, D3=-7, D4=-3, D5=-5, D6=+1, and
D7=-10 and n=7. *
I need to consider the 2^7 ways of assigning signs that result in the lowest
sum of the "positive" absolute difference. To exemplify further, we have
*
-16, -4, -7, -3, -5, -1, -10            T = 0
-16, -4, -7, -3, -5, +1, -10           T = 1
-16, -4, -7, +3, -5, -1, -10           T = 3
-16, -4, -7, +3, -5, +1, -10          T = 4 *
... and so on. 

So, if you are willing to help me, I am having trouble on setting up my data
as illustrated above./ How do I create (a code for) the 2^n lines of data
required with all the possible combinations of + and - in order to calculate
the positive values in each line (the test statistic, T)?/ I have tried to
use combn(d=data set, n=7) with a data set, d, consisting of both the
positive and negative sign of the respective value, to no avail.

I apologize if this is lengthy, I was not sure how to ask the aforementioned
question without incorrectly portraying my thoughts. If any clarification is
required then I will by more than willing to oblige with any further
explanation. I have searched for possible solutions, but alas, came out
empty handed. 

Thank you.

--
View this message in context: http://r.789695.n4.nabble.com/Fisher-Randomization-Test-for-Matched-Pairs-Permutation-Data-Setup-Based-on-Signs-tp4458606p4458606.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list