Calculates power or sample size (only one can be NULL at a time) for two proportions using the normal approximation method.
Validated via G*Power and PASS documentation.
power.z.twoprops(
prob1 = NULL,
prob2 = NULL,
req.sign = "+",
margin = 0,
n.ratio = 1,
n2 = NULL,
power = NULL,
alpha = 0.05,
alternative = c("two.sided", "one.sided", "two.one.sided"),
arcsine = FALSE,
correct = FALSE,
paired = FALSE,
rho.paired = 0.5,
std.error = c("pooled", "unpooled"),
ceil.n = TRUE,
verbose = 1,
utf = FALSE
)power.z.twoprop(
prob1 = NULL,
prob2 = NULL,
req.sign = "+",
margin = 0,
n.ratio = 1,
n2 = NULL,
power = NULL,
alpha = 0.05,
alternative = c("two.sided", "one.sided", "two.one.sided"),
arcsine = FALSE,
correct = FALSE,
paired = FALSE,
rho.paired = 0.5,
std.error = c("pooled", "unpooled"),
ceil.n = TRUE,
verbose = 1,
utf = FALSE
)
list of parameters used in calculation.
type of the test, which is "z" or "exact".
statistical power \((1-\beta)\).
mean of the alternative distribution.
standard deviation of the alternative distribution.
mean of the null distribution.
standard deviation of the null distribution.
critical value(s).
sample size in the form of c(n1, n2) (applies to independent proportions).
total sample size (applies to independent proportions).
paired sample size (applies to paired proportions).
probability of success in the first group.
probability of success in the second group.
whether estimated prob is smaller or larger than the other (when minimum detectable prob is of interest).
ignorable prob1 - prob2 difference. For two
one-sided tests provide lower and upper margins in the
form of c(lower, upper).
sample size ratio (n1 / n2).
integer; sample size for the second group.
statistical power, defined as the probability of correctly rejecting a false null hypothesis, denoted as \(1 - \beta\).
type 1 error rate, defined as the probability of incorrectly rejecting a true null hypothesis, denoted as \(\alpha\).
character; the direction or type of the hypothesis test: "two.sided", "one.sided", or "two.one.sided".
logical; whether arcsine transformation should be applied. Note that this only applies to independent proportions without continuity correction.
logical; whether Yates' continuity correction should be applied to the test statistic. Ignored for the paired test.
logical; if TRUE samples are paired. FALSE
by default.
correlation between paired observations.
character; whether to calculate standard error using "pooled" or "unpooled" standard deviation. Ignored for the paired test.
logical; TRUE rounds up sample size in each group.
1 by default (returns test, hypotheses, and
results), if 2 a more detailed output is given
(plus key parameters and definitions), if 0 no
output is printed on the console.
logical; whether the output should show Unicode
characters (if encoding allows for it). FALSE by
default.
NB: The pwrss.z.2props() function is deprecated, but it will remain
available as a wrapper for the power.z.twoprops() function during
a transition period.
Bulus, M., & Polat, C. (2023). pwrss R paketi ile istatistiksel guc analizi [Statistical power analysis with pwrss R package]. Ahi Evran Universitesi Kirsehir Egitim Fakultesi Dergisi, 24(3), 2207-2328. https://doi.org/10.29299/kefad.1209913
# power
power.z.twoprops(prob1 = 0.65, prob2 = 0.60,
alpha = 0.05, n2 = 500,
alternative = "one.sided")
# sample size
power.z.twoprops(prob1 = 0.65, prob2 = 0.60,
alpha = 0.05, power = 0.80,
alternative = "one.sided")
Run the code above in your browser using DataLab