Learn R Programming

flipr (version 0.2.1)

two_sample_pf: Two-Sample Permutation P-Value Function

Description

This function calculates the permutation p-value function for two-sample problems. This is done through the specification of a set of null hypotheses of the form F_X = F_{g(Y, parameters)} where g is a user-supplied function.

Usage

two_sample_pf(
  parameters,
  null_specification,
  x,
  y,
  statistic = stat_hotelling,
  B = 1000L,
  alternative = "right_tail",
  combine_with = "tippett",
  type = "exact",
  seed = NULL
)

Arguments

parameters

A list of vectors specifying a set of candidate parameter values under the null hypothesis.

null_specification

A function with two arguments y and parameters such that F_X = F_{null_specification(Y, parameters)} under the null hypothesis.

x

A list or matrix representing the 1st sample.

y

A list or matrix representing the 2nd sample.

statistic

A character vector specifying the chosen test statistic(s). These can be stat_hotelling or user-specified functions that define desired statistics. See the section User-supplied statistic function for more information on how these user-supplied functions should be structured for compatibility with the flipr framwork. Default is stat_hotelling.

B

The number of sampled permutation. Default is 1000L.

alternative

A string specifying whether the p-value is right-tailed, left-tailed or two-tailed. Choices are "right_tail", "left_tail" and "two_tail". Default is "right_tail". Obviously, if the test statistic used in argument statistic is positive, all alternatives will lead to the two-tailed p-value.

combine_with

A string specifying the combining function to be used to compute the single test statistic value from the set of p-value estimates obtained during the non-parametric combination testing procedure. Default is "tippett", which picks Tippett's function.

type

A string specifying if performing an exact test through the use of Phipson-Smyth estimate of the p-value or an approximate test through a Monte-Carlo estimate of the p-value. Default is "exact".

seed

An integer specifying the seed of the random generator useful for result reproducibility or method comparisons. Default is NULL.

Value

A vector of p-values of the permutation test for each parameter values specified through the first argument.

Examples

Run this code
# NOT RUN {
x1 <- rnorm(10)
x2 <- rnorm(10, 3)
null_spec <- function(y, parameters) {y - parameters[1]}
two_sample_pf(
  parameters = 3,
  null_specification = null_spec,
  x = x1,
  y = x2,
  statistic = stat_t,
  seed = 1234,
  B = 1000,
  alternative = "two_tail"
)
# }

Run the code above in your browser using DataLab