Learn R Programming

flipr (version 0.2.1)

two_sample_viz: Two-Sample Permutation P-Value Function Graph

Description

This function plots the p-value function for a single parameter of interest, estimated via permutations.

Usage

two_sample_viz(
  null_specification,
  x,
  y,
  alpha = 0.05,
  statistic = stat_hotelling,
  B = 1000L,
  alternative = "two_tail",
  type = "exact",
  point_estimate = NULL,
  confidence_interval = NULL,
  lower_bound = 0,
  upper_bound = 1,
  n_grid_in = 20L,
  n_grid_out = 100L,
  seed = NULL
)

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.

alpha

A scalar specifying the desired significance level. Default is 0.05.

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

point_estimate

A scalar providing a point estimate of the parameter under investigation. Default is NULL, in which case the point estimate is computed by maximizing the p-value function via the two_sample_pe function.

confidence_interval

A length-2 numerical vector providing a confidence interval for the parameter under investigation to be used for setting the boundaries of the grid onto which the p-value will be displayed. Default is NULL, in which case the confidence interval is computed via the two_sample_ci function.

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.

n_grid_in

An integer specifying the size of the grid onto which the p-value function will actually be evaluated. Default is 20L.

n_grid_out

An integer specifying the size of the grid onto which the p-value function will be extrapolated for display. Default is 100L.

seed

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

Value

A ggplot object.

Examples

Run this code
# NOT RUN {
x1 <- rnorm(10)
x2 <- rnorm(10, mean = 3)
null_spec <- function(y, parameters) {y - parameters[1]}
# }
# NOT RUN {
 two_sample_viz(
    null_specification = null_spec,
    x = x1,
    y = x2,
    statistic = stat_t,
    B = 10000
  )
# }

Run the code above in your browser using DataLab