one_mean_test: Simulation-based hypothesis test for a single mean

View source: R/s216-applets.R

one_mean_testR Documentation

Simulation-based hypothesis test for a single mean

Description

This function will run a simulation-based hypothesis test for a single mean or median of a quantitative variable.

Usage

one_mean_test(
  data,
  null_value = 0,
  summary_measure = "mean",
  shift = 0,
  as_extreme_as,
  direction = c("greater", "less", "two-sided"),
  number_repetitions = 1,
  add_normal = FALSE
)

Arguments

data

Vector of quantitative data values.

summary_measure

Name of summary measure to return from simulations. Allowed values are "mean" or "median". Defaults to "mean".

shift

Amount to shift data values for bootstrapping of null distribution.

as_extreme_as

Value of observed mean.

direction

Direction of alternative hypothesis. Allowed values are "greater", "less", or "two-sided".

number_repetitions

Number of simulated samples.

add_normal

Logical value indicating whether to superimpose a normal curve on the histogram. Defaults to FALSE.

Value

Returns plot of distribution of simulated statistics, with values as or more extreme than specified value highlighted, and reports proportion of simulations as or more extreme than specified as subtitle on plot.

Examples

set.seed(117)
x <- rnorm(25)
m <- mean(x)
one_mean_test(x,
              summary_measure = "mean",
              shift = -m,
              as_extreme_as = m,
              direction = "two-sided",
              number_repetitions = 100
)

greenwood-stat/catstats documentation built on Dec. 14, 2024, 6:25 p.m.