permTestPaired: Permutation test for paired data.

Description Usage Arguments Details Value Methods (by class) Author(s) References Examples

View source: R/permTestPaired.R

Description

Permutation test for paired data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
permTestPaired(x, ...)

## Default S3 method:
permTestPaired(x, y, B = 9999,
  alternative = "two.sided", plot.hist = TRUE,
  legend.loc = "topright", plot.qq = FALSE,
  x.name = deparse(substitute(x)), y.name = deparse(substitute(y)),
  ...)

## S3 method for class 'formula'
permTestPaired(formula, data, subset, ...)

Arguments

x

a numeric vector.

...

further arguments to be passed to or from methods.

y

a numeric vector.

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.

x.name

Label for x variable

y.name

Label for y variable

formula

a formula of the form y ~ x, where x, y are both numeric variables.

data

an optional data frame containing the variables in the formula. By default the variables are taken from environment(formula).

subset

an optional vector specifying a subset of observations to be used.

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 mean of the difference of the two variables (y-x).

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).

Methods (by class)

Author(s)

Laura Chihara

References

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

Examples

1
2
3
4
5
6
#Does chocolate ice cream have more calories than vanilla ice cream, on average?
#H0: mean number of calories is the same
#HA: mean number of calories is greater in chocolate ice cream

permTestPaired(Icecream$VanillaCalories, Icecream$ChocCalories, alternative = "less")
permTestPaired(ChocCalories ~ VanillaCalories, data = Icecream, alternative = "greater")

CarletonStats documentation built on Aug. 10, 2018, 1:14 a.m.