#set document(title: "18.6 Rank Randomization Two Conditions", author: "OpenStax") #set page(width: 8.5in, height: auto, margin: 1in) #import "@preview/cetz:0.5.2" #set text(font: ("STIX Two Text", "Libertinus Serif", "New Computer Modern"), size: 10.5pt, lang: "en") #show math.equation: set text(font: ("STIX Two Math", "New Computer Modern Math")) #set par(justify: true, leading: 0.62em, spacing: 0.9em) #set enum(spacing: 1.1em) // room between list items so tall inline fractions don't collide #set list(spacing: 1.1em) #set table(stroke: 0.5pt + rgb("#c7ccd3")) #let BLUE = rgb("#183B6F") // brand navy — section bars + example/solution labels (white on navy 11.09:1) #let ORANGE = rgb("#A94509") // brand primary-700 — AA-safe deep orange for TEXT (5.93:1 on white; raw brand #F37021 is 2.94:1 and must never carry text) #let RED = rgb("#DC2626") // brand error-600 #let GREEN = rgb("#059669") // brand success-600 (decoration only; small green text uses green-text #007942) #show heading.where(level: 1): it => block(width: 100%, above: 0pt, below: 16pt, fill: gradient.linear(BLUE, rgb("#2C5AA0")), inset: (x: 14pt, y: 12pt), radius: 3pt, text(fill: white, weight: "bold", size: 19pt, it.body)) #show heading.where(level: 2): it => block(width: 100%, above: 18pt, below: 10pt, fill: BLUE, inset: (x: 10pt, y: 6pt), radius: 2pt, text(fill: white, weight: "bold", size: 12pt, it.body)) #show heading.where(level: 3): it => text(fill: ORANGE, weight: "bold", size: 12.5pt, it.body) #show heading.where(level: 4): it => text(fill: BLUE, weight: "bold", size: 10.5pt, it.body) #let examplebox(label, title, body) = block(width: 100%, breakable: true, fill: rgb("#EFF1F5"), stroke: 0.5pt + rgb("#CFDDF0"), radius: 4pt, inset: 10pt, above: 12pt, below: 12pt)[ #block(below: 6pt)[#box(fill: BLUE, inset: (x: 6pt, y: 2pt), radius: 2pt, text(fill: white, weight: "bold", size: 8.5pt, label)) #h(0.4em) #strong[#title]] #body] // rail = decorative left rule (raw brand token); labelcolor = AA-safe label text shade #let notebox(label, rail, labelcolor, tint, body) = block(width: 100%, breakable: true, fill: tint, stroke: (left: 3pt + rail), inset: (left: 10pt, rest: 8pt), radius: (right: 4pt), above: 11pt, below: 11pt)[ #text(fill: labelcolor, weight: "bold", size: 7.5pt, tracking: 0.5pt)[#upper(label)] #linebreak() #body] #let solutionbox(body) = block(above: 4pt, below: 8pt)[ #text(fill: BLUE, weight: "bold", size: 8.5pt)[Solution] #linebreak() #body] #let figph(msg) = block(width: 100%, height: 60pt, fill: rgb("#f6f7f9"), stroke: (paint: rgb("#c7ccd3"), dash: "dashed"), radius: 4pt, inset: 10pt)[ #align(center + horizon, text(fill: rgb("#889"), style: "italic", size: 9pt, msg))] // Standardize inlined figure sizes: measure the natural CeTZ canvas, then scale to a // consistent envelope (aspect-aware; see build_typst.py FIG_* constants). Unlike the // print preamble, dimensions are FLOORED: in an editor a user can trim a figure to a // degenerate 1-D shape (a bare line), and w/h or tw/w would then divide by zero. #let _STD_W = 3.5 #let _WIDE_W = 5.6 #let _MAX_H = 3.4 #let _ASPECT_WIDE = 2.2 #let _UPSCALE_MAX = 1.15 #let stdfig(body) = context { let m = measure(body) let w = calc.max(m.width / 1in, 0.01) let h = calc.max(m.height / 1in, 0.01) let tw = if w / h > _ASPECT_WIDE { _WIDE_W } else { _STD_W } let s = calc.min(tw / w, _MAX_H / h, _UPSCALE_MAX) align(center, box(scale(x: s * 100%, y: s * 100%, reflow: true, body))) } #show figure: set block(breakable: false) #set figure(gap: 8pt) #show figure.caption: set text(size: 8.5pt, fill: rgb("#555")) == 18.6#h(0.6em)Rank Randomization Two Conditions #notebox("Note", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ #emph[Prerequisites] Permutations and Combinations, Randomization Tests for Two Conditions #linebreak() #linebreak() ] #notebox("Note", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ #emph[Learning Objectives] + State the difference between a randomization test and a rank randomization test + Describe why rank randomization tests are more common + Be able to compute a Mann-Whitney U test ] The major problem with randomization tests is that they are very difficult to compute. Rank randomization tests are performed by first converting the scores to ranks and then computing a randomization test. The primary advantage of rank randomization tests is that there are tables that can be used to determine significance. The disadvantage is that some information is lost when the numbers are converted to ranks. Therefore, rank randomization tests are generally less powerful than randomization tests based on the original numbers. There are several names for rank randomization tests for differences in central tendency. The two most common are the Mann-Whitney U test and the Wilcoxon Rank Sum test. Consider the data shown in Table 1 that were used as an example in the section on randomization tests. Table 1. Fictitious data. #figure(table( columns: 2, align: left, inset: 6pt, table.header([Experimental], [Control]), [7 #linebreak() 8 #linebreak() 11 #linebreak() 30], [0 #linebreak() 2 #linebreak() 5 #linebreak() 9], )) A rank randomization test on these data begins by converting the numbers to ranks. Table 2. Fictitious data converted to ranks. Rank sum = 24. #figure(table( columns: 2, align: left, inset: 6pt, table.header([Experimental], [Control]), [4 #linebreak() 5 #linebreak() 7 #linebreak() 8], [1 #linebreak() 2 #linebreak() 3 #linebreak() 6], )) The probability value is determined by computing the proportion of the possible arrangements of these ranks that result in a difference between ranks as large or larger than those in the actual data (Table 2). Since the sum of the ranks (the numbers 1-8) is a constant (36 in this case), we can use the computational shortcut of finding the proportion of arrangements for which the sum of the ranks in the Experimental Group is as high or higher than the sum here (4 + 5 + 7 + 8 = 24). First, consider how many ways the 8 values could be divided into two sets of 4. We can apply the formula from the section on Permutations and Combinations for the number of combinations of n items taken r at a time (n = the total number of observations; r = the number of observations in the first group) and find that there are 70 ways. #math.equation(block: true, alt: "n C sub r equals the fraction n ! over open parenthesis n minus r close parenthesis ! r ! equals the fraction 8 ! over open parenthesis 8 minus 4 close parenthesis ! 4 ! equals 70")[$n C_(r) = frac(n !, ( n − r ) ! #h(0.167em) r !) = frac(8 !, ( 8 − 4 ) ! #h(0.167em) 4 !) = 70$] Of these 70 ways of dividing the data, how many result in a sum of ranks of 24 or more? Tables 3-5 show three rearrangements that would lead to a rank sum of 24 or larger. Table 3. Rearrangement of data converted to ranks. Rank sum = 26. #figure(table( columns: 2, align: left, inset: 6pt, table.header([Experimental], [Control]), [6 #linebreak() 5 #linebreak() 7 #linebreak() 8], [1 #linebreak() 2 #linebreak() 3 #linebreak() 4], )) Table 4. Rearrangement of data converted to ranks. Rank sum = 25. #figure(table( columns: 2, align: left, inset: 6pt, table.header([Experimental], [Control]), [4 #linebreak() 6 #linebreak() 7 #linebreak() 8], [1 #linebreak() 2 #linebreak() 3 #linebreak() 5], )) Table 5. Rearrangement of data converted to ranks. Rank sum = 24. #figure(table( columns: 2, align: left, inset: 6pt, table.header([Experimental], [Control]), [3 #linebreak() 6 #linebreak() 7 #linebreak() 8], [1 #linebreak() 2 #linebreak() 4 #linebreak() 5], )) Therefore, the actual data represent 1 arrangement with a rank sum of 24 or more and the 3 arrangements represent three others. Therefore, there are 4 arrangements with a rank sum of 24 or more. This makes the probability equal to 4/70 = 0.057. Since only one direction of difference is considered (Experimental larger than Control), this is a one-tailed probability. The two-tailed probability is (2)(0.057) = 0.114 since there are 8/70 ways to arrange the data so that the sum of the ranks is either (a) as large or larger or (b) as small or smaller than the sum found for the actual data. The beginning of this section stated that rank randomization tests were easier to compute than randomization tests because tables are available for rank randomization tests. Table 6 can be used to obtain the critical values for equal sample sizes of 4-10. Table for unequal sample sizes (in a new window). For the present data, both n#sub[1] and n#sub[2] = 4 so, as can be determined from the table, the rank sum for the Experimental Group must be at least 25 for the difference to be significant at the 0.05 level (one-tailed). Since the sum of ranks equals 24, the probability value is somewhat above 0.05. In fact, by counting the arrangements with the sum of ranks greater than or equal to 24, we found that the probability value is 0.057. Naturally a table can only give the critical value rather than the p value itself. However, with a larger sample size such as 10 subjects per group, it becomes very time-consuming to count all arrangements equaling or exceeding the rank sum of the data. Therefore, for practical reasons, the critical value sometimes suffices. Table 6. Critical values. #figure(table( columns: 8, align: left, inset: 6pt, table.header([n#sub[1]], [n#sub[2]], [0.20], [0.10], [0.05], [0.025], [0.01], [0.005]), [4], [4], [22], [23], [25 #linebreak()], [26 #linebreak()], [. #linebreak()], [. #linebreak()], [5], [5], [33], [35], [36], [38], [39], [40], [6], [6], [45], [48], [50], [52], [54], [55], [7], [7], [60], [64], [66], [69], [71], [73], [8], [8], [77], [81], [85], [87], [91], [93], [9], [9], [96], [101], [105], [109], [112], [115], [10], [10], [117], [123], [128], [132], [136], [139], )) For larger sample sizes than covered in the tables, you can use the following expression that is approximately normally distributed for moderate to large sample sizes. #math.equation(block: true, alt: "Z equals the fraction W sub a minus n sub a open parenthesis n sub a plus n sub b plus 1 close parenthesis / 2 over the square root of n sub a n sub b open parenthesis n sub a plus n sub b plus 1 close parenthesis / 12")[$Z = frac(W_(a) − n_(a) ( n_(a) + n_(b) + 1 ) / 2, sqrt(n_(a) n_(b) ( n_(a) + n_(b) + 1 ) / 12))$] where: #linebreak() W#sub[a] is the sum of the ranks for the first group #linebreak() n#sub[a] is the sample size for the first group #linebreak() n#sub[b] is the sample size for the second group #linebreak() Z is the test statistic #linebreak() The probability value can be determined from Z using the #link("https://onlinestatbook.com/2/calculators/normal_dist.html")[normal distribution calculator]. The data from the #link("https://onlinestatbook.com/2/case_studies/stereograms.html")[Stereograms Case Study] can be analyzed using this test. For these data, the sum of the ranks for Group 1 (W#sub[a]) is 1911, the sample size for Group 1 (n#sub[a]) is 43, and the sample size for Group 2 (n#sub[b]) is 35. Plugging these values into the formula results in a Z of 2.13, which has a two-tailed p of 0.033.