two_proportion_bootstrap_CI: Bootstrap confidence interval for a difference in proportions

View source: R/s216-applets.R

two_proportion_bootstrap_CIR Documentation

Bootstrap confidence interval for a difference in proportions

Description

This function will create a bootstrap confidence interval for a difference in proportion of successes between two independent groups.

Usage

two_proportion_bootstrap_CI(
  formula,
  data,
  first_in_subtraction,
  response_value_numerator,
  confidence_level = 0.95,
  number_repetitions = 100
)

Arguments

formula

Formula of the form response ~ predictor, where predictor defines the two groups of the explanatory variable and response is binary or a two-level categorical variable.

data

Data frame with columns for response and predictor variables.

first_in_subtraction

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

response_value_numerator

Value of response that corresponds to "success" when computing proportions.

confidence_level

Confidence level for interval in decimal form. Defaults to 0.95 (95% confidence interval).

number_repetitions

Number of bootstrapped resamples.

Value

Returns plot of distribution of bootstrapped statistics, with values as or more extreme than percentile confidence interval range highlighted, and reports confidence interval as subtitle on plot.

Examples

data(pt)
pt$twoSeconds <- ifelse(pt$responses >= 2, "Yes", "No")
two_proportion_bootstrap_CI(twoSeconds ~ brand,
  data = pt,
  first_in_subtraction = "B1",
  response_value_numerator = "Yes",
  confidence_level = 0.95,
  number_repetitions = 1000
)

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