chisq_test_odds: Chi-square Test Sample Size Given Odds Ratio

Description Usage Arguments Value Details References Author(s) See Also Examples

View source: R/chisq_test.R

Description

Calculates sample size for chi-squared test of independence given the odds ratio.

Usage

1
2
3
4
5
6
7
8
9
chisq_test_odds(
  odds_ratio = NULL,
  p_control = NULL,
  p_treatment = NULL,
  power = NULL,
  conf_level = 0.95,
  sample_ratio = 1,
  visualize = FALSE
)

Arguments

odds_ratio

The expected odds ratio. That is, the ratio of the odds of the outcome in the test group relative to the control group. Optional, but see Details.

p_control

Your guess for prevalence of outcome in the control group. Optional but see Details.

p_treatment

Your guess for prevalence of outcome in the test group. Optional but see Details.

power

The ability of the test to detect an effect where there is one. Power = 1 - Prob(Type 2 error). Optional. See Value for details.

conf_level

Desired confidence level. Defaults to 95%.

sample_ratio

Ratio of test group to control group. 1 is even split.

visualize

Whether to plot power or prevalence of outcome in the control group vs sample size. Can be used to help make a decision.

Value

If power was not provided, returns vector containing possible power values and the appropriate sample size for each %. If all values were provided, returns a single sample size estimate.

Details

The function only needs to know two of the following three: odds_ratio, p_control, and p_treatment. If given all three, it will check to make sure the odds ratio is correct. It will figure out the missing third value from the other two.

References

Wang, H., Chow, S.-C., & Li, G. (2002). On sample size calculation based on odds ratio in clinical trials. Journal of Biopharmaceutical Statistics, 12(4), 471-483. doi:10.1081/BIP-120016231

Author(s)

Mikhail Popov

See Also

chisq_test_effect()

Examples

1
2
3
4
chisq_test_odds(p_treatment = 0.4, p_control = 0.25, power = 0.8)
chisq_test_odds(odds_ratio = 2, p_control = 0.4, power = c(0.8, 0.9, 0.95))
chisq_test_odds(odds_ratio = 2, p_control = 0.4)
chisq_test_odds(odds_ratio = 2, p_control = 0.4, visualize = TRUE)

wikimedia/wikimedia-discovery-wmf documentation built on Feb. 7, 2021, 12:19 a.m.