This function computes the t-test on the inputs R times and samples the pooled data (i.e. x and y together) without replacement. The function calculates the p-value by

permutation_test(x, y, R, use_sample = TRUE, ...)

Arguments

x

a numeric vector

y

a numeric vector

R

number of resamples. Must be between 99 and 999.

use_sample

logical. Use the sample() function? If FALSE, this function will use the runif() function to draw random samples.

...

optional (named) parameters

  • alternative: a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter. See ?t.test() for more information

  • var.equal: a logical variable indicating whether to treat the two variances as being equal. If TRUE then the pooled variance is used to estimate the variance otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used. See ?t.test() for more information.

  • tolerance: defines the error tolerance bounds around the proportion of indices. Smaller tolerance means smaller bounds and more resampling to get the 'right' proportion

Value

List containing

  • data: list containing input parameters

  • results: result of the permutation test. Contains indices for each run, p-values, options passed to the t-tests

See also

Rizzo, Maria L. "Statistical Computing with R". Chapman and Hall/CRC, 2007. pp. 183-188