Learn R Programming

flipr (version 0.2.1)

two_sample_pe: Two-Sample Permutation Point Estimate

Description

This function produces a point estimate of the parameters under investigation using the permutation framework.

Usage

two_sample_pe(
  null_specification,
  x,
  y,
  statistic = stat_hotelling,
  B = 1000,
  alternative = "two_tail",
  type = "exact",
  lower_bound = 0,
  upper_bound = 1,
  seed = NULL,
  verbose = FALSE
)

Arguments

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.

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

lower_bound

A scalar value specifying a rough lower bound of the interval over which searching the maximum of the p-value function. Default is 0.

upper_bound

A scalar value specifying a rough upper bound of the interval over which searching the maximum of the p-value function. Default is 1.

seed

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

verbose

A boolean specifying whether to display some information about the resolution of the maximization problem. Default is FALSE.

Value

A numerical vector providing a point estimate of the parameters.

Examples

Run this code
# NOT RUN {
x1 <- rnorm(10)
x2 <- rnorm(10, mean = 3)
null_spec <- function(y, parameters) {y - parameters[1]}
two_sample_pe(
  null_specification = null_spec,
  x = x1, y = x2,
  statistic = stat_t,
  lower_bound = 2,
  upper_bound = 4
)
# }

Run the code above in your browser using DataLab