regression_test: Simulation-based hypothesis test for regression

View source: R/s216-applets.R

regression_testR Documentation

Simulation-based hypothesis test for regression

Description

This function will run a simulation-based hypothesis test for a slope of simple linear regression or correlation between two quantitative variables.

Usage

regression_test(
  formula,
  data,
  summary_measure = c("slope", "correlation"),
  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 a quantitative 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 "slope" for test of slope or "correlation" for test of correlation.

as_extreme_as

Value of observed slope or correlation.

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.

Examples

data(mtfires)
mtfires$logHect <- log(mtfires$Hectares)
regression_test(logHect ~ Temperature,
  data = mtfires,
  summary_measure = "correlation",
  as_extreme_as = 1.388,
  direction = "greater",
  number_repetitions = 1000
)

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