# permTestPaired: Permutation test for paired data. In CarletonStats: Functions for Statistics Classes at Carleton College

## Description

Permutation test for paired data.

## Usage

 1 2 permTestPaired(x, y, fun = mean, B = 9999, alternative = "two.sided", plot.hist = TRUE, legend.loc = "topright", plot.qq = FALSE) 

## Arguments

 x a numeric vector. y a numeric vector. fun statistic of interest. B the number of resamples. alternative the alternative hypothesis. Options are "two.sided", "less" and "greater". plot.hist a logical value. If TRUE, create a histogram displaying the permutation distribution of the statistic. legend.loc a logical value. If TRUE, include a legend on the histogram. plot.qq a logical value. If TRUE, include a quantile-normal plot of the permuation distribution.

## Details

For two paired numeric variables with n rows, randomly select k of the n rows (k also is randm) and switch the entries (a, b) \to (b, a) and then compute the statistic on the difference of the two variables.

Observations with missing values are removed.

## Value

Returns invisibly a vector of the replicates of the test statistic (ex. mean of the difference of the resampled variables).

Laura Chihara

## References

Tim Hesterberg's website: http://www.timhesterberg.net/bootstrap

## Examples

 1 2 3 4 5 #Does vanilla ice cream have fewer calories than chocolate ice cream, on average? #H0: mean amount of sugar is the same #HA: mean amount of sugar is less in vanilla ice cream permTestPaired(Icecream$VanillaSugar, Icecream$ChocSugar, alternative = "less") 

CarletonStats documentation built on May 29, 2017, 11:20 p.m.