two_mean_test: Simulation-based hypothesis test for a difference in means

View source: R/s216-applets.R

two_mean_testR Documentation

Simulation-based hypothesis test for a difference in means

Description

This function will run a simulation-based hypothesis test for a difference in means or difference in medians of a quantitative variable for two independent groups.

Usage

two_mean_test(
  formula,
  data,
  summary_measure = "mean",
  first_in_subtraction,
  as_extreme_as,
  direction = c("greater", "less", "two-sided"),
  number_repetitions = 1,
  add_normal = FALSE
)

Arguments

formula

Formula of the form response ~ predictor, where predictor defines the two groups of the explanatory variable and response is a quantitative response variable.

data

Data frame with columns for response and predictor variables.

summary_measure

Name of summary measure to return from simulations. Allowed values are "mean" for test of difference in means or "median" for test of difference in medians. Defaults to "mean".

first_in_subtraction

Value of predictor variable that should be first in order of subtraction for computing difference in means.

as_extreme_as

Value of observed difference in means.

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

data(pt)
two_mean_test(responses ~ brand,
  data = pt,
  first_in_subtraction = "B1",
  as_extreme_as = -.4,
  direction = "two-sided",
  number_repetitions = 1000
)

greenwood-stat/catstats documentation built on Aug. 1, 2022, 2:04 p.m.