Skip to contents

Execute a one-sample permutation test on two numeric vectors. One vector is kept constant while the other is "shuffled" by resampling. This approximates the null hypothesis — that there is no dependency or difference between the variables.

Usage

ptest(
  x,
  y,
  FUN,
  rk = FALSE,
  alternative = c("greater", "less", "two.sided"),
  num.s = 250,
  ...
)

Arguments

x

[numeric(1)]
A numeric vector.

y

[numeric(1)]
A numeric vector.

FUN

[function(1)]
The function to be applied.

rk

[logical(1)]
If TRUE, transform x and y numeric vectors with sample ranks.

alternative

[character(1)]
A character string specifying the alternative hypothesis. Must be one of "greater" (default), "less", or "two.sided". You can specify just the initial letter.

num.s

[numeric(1)]
The number of samples with replacement created from the y numeric vector.

...

Additional arguments.

Examples


x <- iris[[1]]
y <- iris[[2]]
ptest(x, y, FUN = function(x, y) cor(x, y), alternative = "t")
#> [1] 0.16