> set.seed(1234) # Set random number generator seed to reproduce samples > (t <- max(opp_id)) # t = number of opponents ("treatments") [1] 7 > (N <- length(runs)) # N = total number of games [1] 78 > (ybar_all <- mean(runs)) # ybar_all = overall sample mean number of runs per game [1] 6.358974 > teamrange [,1] [,2] [1,] 1 12 [2,] 12 23 [3,] 23 34 [4,] 34 45 [5,] 45 56 [6,] 56 67 [7,] 67 78 > ybar [1] 7.500000 5.416667 4.750000 8.000000 7.166667 6.416667 4.916667 > sumsq_obs [1] 113.5855 randgrp [1,] 1 9 [2,] 2 48 [3,] 3 47 [4,] 4 76 [5,] 5 64 [6,] 6 75 [7,] 7 1 [8,] 8 17 [9,] 9 73 [10,] 10 36 [11,] 11 77 [12,] 12 37 [13,] 13 19 [14,] 14 61 [15,] 15 66 [16,] 16 53 [17,] 17 18 [18,] 18 71 [19,] 19 12 [20,] 20 14 [21,] 21 74 [22,] 22 62 [23,] 23 78 [24,] 24 3 [25,] 25 60 [26,] 26 43 [27,] 27 28 [28,] 28 70 [29,] 29 42 [30,] 30 55 [31,] 31 22 [32,] 32 13 [33,] 33 15 [34,] 34 23 [35,] 35 8 [36,] 36 33 [37,] 37 56 [38,] 38 11 [39,] 39 40 [40,] 40 32 [41,] 41 68 [42,] 42 24 [43,] 43 54 [44,] 44 38 [45,] 45 69 [46,] 46 65 [47,] 47 35 [48,] 48 16 [49,] 49 44 [50,] 50 45 [51,] 51 49 [52,] 52 50 [53,] 53 58 [54,] 54 51 [55,] 55 4 [56,] 56 34 [57,] 57 41 [58,] 58 31 [59,] 59 67 [60,] 60 63 [61,] 61 21 [62,] 62 72 [63,] 63 6 [64,] 64 26 [65,] 65 20 [66,] 66 10 [67,] 67 59 [68,] 68 57 [69,] 69 46 [70,] 70 39 [71,] 71 25 [72,] 72 7 [73,] 73 30 [74,] 74 29 [75,] 75 27 [76,] 76 2 [77,] 77 5 [78,] 78 52 > > summary(sumsq_rand) # Give the summary of the sum of squares Min. 1st Qu. Median Mean 3rd Qu. Max. 1.14 48.47 73.53 80.99 105.50 415.60 > > ### Compute the p-value for the observed sum of squares > ### Count the number of permutation samples with sum of squares >= observed > ### Add 1 to include the observed sample in numerator and denominator > > (p_rand <- (sum(sumsq_rand >= sumsq_obs)+1)/(num_samp+1)) [1] 0.20502