Usages of Permutation Tests R Functions

  1. Comparing Two Population Means
         res <- compare(x,y) # randomization test (two.sided)
         summary(res) # summary of results
         plot(res) # plot results (histogram and test results)
         plot(res, density=T) # histogram and kernel density curve
         res <- compare(x,y,method="permu") # permutation test
         res <- compare(x,y,method="boot") # bootstrap test
         res <- compare(x,y,alt="greater",method="permu") # right-tail test
         res <- compare(x,y,alt="g",method="p") # same as the above
         res <- compare(x,y,method="b",size=2000) # bootstrap size = 2000
        
  2. Comparing Two Population Variances
         res <- compare(x,y,comp="variance.ratio") # randomization test of variance ratio
         res <- compare(x,y,comp="v",alt="g",log=T) # test for log(variance ratio)
         res <- compare(x,y,comp="v",method="p",log=T) # permutation test for log(variance ratio)
        
  3. Comparing Two Population Proportions
         # Randomization test of two proportions with summary statistics:
         # sample 1: x=120 out of m=200,  sample 2: y=73 out of n=100
         # parameter of interest: p1 - p2
         res <- compare(120, 73, 200, 100, comp="prop.diff")
         res <- compare(120, 73, 200, 100, comp="p") # same as the above
    
         # Bootstrap test of two proportions with summary statistics:
         # sample 1: x=120 out of m=200,  sample 2: y=73 out of n=100
         # parameter of interest: p1 / p2
         res <- compare(120, 73, 200, 100, comp="ratio.prop",method="boot")
         res <- compare(120, 73, 200, 100, comp="r",method="b") # same as the above
    
         # Bootstrap test of two proportions with summary statistics:
         # sample 1: x=120 out of m=200,  sample 2: y=73 out of n=100
         # parameter of interest: log(p1 / p2)
         res <- compare(120, 73, 200, 100, comp="r",method="b",log=T)
        

Feb. 21, 2008