On Thu, Mar 08, 2012 at 09:49:20PM -0800, Ghandalf wrote: > 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.
Hi. The minimum sum of "positive" absolute differencies is always zero and is achieved for every sign combination, which assigns -1 to all nonzero abs(Di) and any sign to zero abs(Di). In particular, the combination rep(-1, times=7) is a solution. I am not sure, whether this is, what you are asking for. Can you give more detail? Petr Savicky. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.