power.chisq.gof | R Documentation |
Calculates power or sample size (only one can be NULL at a time) for Chi-square goodness-of-fit or independence tests.
NOTE: The pwrss.chisq.gofit()
function is deprecated. However, it will remain available as a wrapper for the power.chisq.gof()
function.
power.chisq.gof(w, null.w = 0, df,
n = NULL, power = NULL, alpha = 0.05,
ceiling = TRUE, verbose = TRUE, pretty = FALSE)
w |
Cohen's w effect size under alternative. It can be any of Cohen's W, Phi coefficient, or Cramer's V but degrees of freedom should be specified accordingly. Phi coefficient is defined as |
null.w |
Cohen's w effect size under null. |
df |
integer; degrees of freedom. Defined as (n.cells - 1) if |
n |
integer; total sample size. |
power |
statistical power, defined as the probability of correctly rejecting a false null hypothesis, denoted as |
alpha |
type 1 error rate, defined as the probability of incorrectly rejecting a true null hypothesis, denoted as |
ceiling |
logical; whether sample size should be rounded up. |
verbose |
logical; whether the output should be printed on the console. |
pretty |
logical; whether the output should show Unicode characters (if encoding allows for it). |
parms |
list of parameters used in calculation. |
test |
type of the statistical test (Chi-square Test). |
df |
degrees of freedom. |
ncp |
non-centrality parameter under alternative. |
null.ncp |
non-centrality parameter under null. |
chisq.alpha |
critical value. |
power |
statistical power |
n |
total sample size. |
Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum Associates.
# ---------------------------------------------------------#
# Example 1: Cohen's W #
# goodness-of-fit test for 1 x k or k x 1 table #
# How many subjects are needed to claim that #
# girls choose STEM related majors less than males? #
# ---------------------------------------------------------#
## Option 1: Use cell probabilities
## from https://www.aauw.org/resources/research/the-stem-gap/
## 28 percent of the workforce in STEM field is women
prob.vector <- c(0.28, 0.72)
null.prob.vector <- c(0.50, 0.50)
probs.to.w(prob.vector, null.prob.vector)
power.chisq.gof(w = 0.44, df = 1,
alpha = 0.05, power = 0.80)
# ---------------------------------------------------------#
# Example 2: Phi Coefficient (or Cramer's V or Cohen's W) #
# test of independence for 2 x 2 contingency tables #
# How many subjects are needed to claim that #
# girls are underdiagnosed with ADHD? #
# ---------------------------------------------------------#
## from https://time.com/growing-up-with-adhd/
## 5.6 percent of girls and 13.2 percent of boys are diagnosed with ADHD
prob.matrix <- rbind(c(0.056, 0.132),
c(0.944, 0.868))
colnames(prob.matrix) <- c("Girl", "Boy")
rownames(prob.matrix) <- c("ADHD", "No ADHD")
prob.matrix
probs.to.w(prob.matrix)
power.chisq.gof(w = 0.1302134, df = 1,
alpha = 0.05, power = 0.80)
# --------------------------------------------------------#
# Example 3: Cramer's V (or Cohen's W) #
# test of independence for j x k contingency tables #
# How many subjects are needed to detect the relationship #
# between depression severity and gender? #
# --------------------------------------------------------#
## from https://doi.org/10.1016/j.jad.2019.11.121
prob.matrix <- cbind(c(0.6759, 0.1559, 0.1281, 0.0323, 0.0078),
c(0.6771, 0.1519, 0.1368, 0.0241, 0.0101))
rownames(prob.matrix) <- c("Normal", "Mild", "Moderate",
"Severe", "Extremely Severe")
colnames(prob.matrix) <- c("Female", "Male")
prob.matrix
probs.to.w(prob.matrix)
power.chisq.gof(w = 0.03022008, df = 4,
alpha = 0.05, power = 0.80)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.