randomize: Randomize a Two Proportions Hypothesis Test

View source: R/randomize.r

randomizeR Documentation

Randomize a Two Proportions Hypothesis Test

Description

For a hypothesis test involving two proportions, create a vector of simulated statistics by using randomization.

Usage

randomize(failA, successA, totalA, failB, successB, totalB, numRepetitions)

Arguments

failA

The number of observed "failures" in "Group A". Must be a positive, whole number; if not, it will be rounded to the nearest whole number.

successA

The number of observed "successes" in "Group A". Must be a positive, whole number; if not, it will be rounded to the nearest whole number.

totalA

The sample size of "Group A". Must be a positive, whole number; if not, it will be rounded to the nearest whole number.

failB

The number of observed "failures" in "Group B". Must be a positive, whole number; if not, it will be rounded to the nearest whole number.

successB

The number of observed "successes" in "Group B". Must be a positive, whole number; if not, it will be rounded to the nearest whole number.

totalB

The sample size of "Group B". Must be a positive, whole number; if not, it will be rounded to the nearest whole number.

numRepetitions

The number of times to repeat the simulation process. Must be a positive, whole number; if not, it will be rounded to the nearest whole number.

Value

A vector of simulated statistics under the null hypothesis. The vector will be the same length as numRepetitions.

Examples


# Group A has 402 failures, 198 successes, 600 in total. Group B has 120 failures, 
80 successes, 200 in total. Run a randomization 1000 times to see the simulated differences
in sample proportions (simulated statistics).
randomize(failA = 402, successA = 198, totalA = 600, failB = 120, successB = 80, 
totalB = 200, numRepetitions = 1000)


STATS250SBI/stats250sbi documentation built on March 18, 2022, 1:14 p.m.