Description Usage Arguments Value Details References Author(s) See Also Examples
Calculates sample size for chi-squared test of independence given the odds ratio.
1 2 3 4 5 6 7 8 9 |
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. |
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.
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.
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
Mikhail Popov
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.