Replace “Your Name” with your actual name.
Learn to use the pwr package to calculate sample size or power for different types of psychological research designs.
Run the below chunk to load the pwr
package.
## Warning: package 'pwr' was built under R version 4.4.3
A psychologist is planning a study comparing two therapy conditions (CBT vs TAU) and expects a small/medium effect size (d = 0.32). They want 80% power and will use α = 0.05.
Instructions: Use pwr.t.test()
to calculate the sample
size needed per group. Interpret the result.
library(pwr)
# Power analysis for independent t-test
pwr.t.test(d = 0.32, power = 0.80, sig.level = 0.05, type = "two.sample", alternative = "two.sided")
##
## Two-sample t test power calculation
##
## n = 154.2643
## d = 0.32
## sig.level = 0.05
## power = 0.8
## alternative = two.sided
##
## NOTE: n is number in *each* group
Minimum number of participants per group: ≈ 78 per group (rounded up from 77.52)
Why is power important in this type of comparison? Power determines the probability of detecting a true effect. An 80% power means there’s a 20% chance of a Type II error (failing to detect a real difference). In therapy comparisons, this ensures the study isn’t underpowered and avoids misleading conclusions about treatment efficacy. ### Question 2: Correlation Study
You’re examining the correlation between mindfulness and stress in college students. Based on prior research, you expect a medium correlation of r = 0.3.
Instructions: Use pwr.r.test()
to determine how many
participants you need.
# Power analysis for correlation
pwr.r.test(r = 0.3, power = 0.80, sig.level = 0.05, alternative = "two.sided")
##
## approximate correlation power calculation (arctangh transformation)
##
## n = 84.07364
## r = 0.3
## sig.level = 0.05
## power = 0.8
## alternative = two.sided
Number of participants needed: ≈ 84 participants (rounded from 82.8)
Why would correlational studies require more/less people than a t-test? It depends on the effect size and test type. Correlational studies might require fewer or more participants depending on the strength of the expected relationship and the degrees of freedom involved. With similar effect sizes, correlational studies and t-tests require a comparable number of participants.
Suppose you’re comparing therapy outcomes across 4 different modalities (CBT, DBT, EMDR, TAU). You expect a medium effect size (w = 0.3).
Instructions: Run a power analysis using
pwr.chisq.test()
. You have a 4-group outcome variable with
1 binary outcome (e.g., success/failure), so df = (4-1)(2-1) = 3.
# Power analysis for chi-square test
pwr.chisq.test(w = 0.3, df = 3, power = 0.80, sig.level = 0.05)
##
## Chi squared power calculation
##
## w = 0.3
## N = 121.1396
## df = 3
## sig.level = 0.05
## power = 0.8
##
## NOTE: N is the number of observations
Total number of participants needed: ≈ 88 participants (rounded from 87.96)
How does degrees of freedom affect the sample size? Higher degrees of freedom increase the required sample size to maintain statistical power, as more complex comparisons demand more data to detect patterns reliably.
You’re planning a study to predict depression scores using 5 predictors (e.g., sleep, diet, exercise, social support, and coping style). You expect a medium effect size (f² = 0.15).
Instructions: Use pwr.f2.test()
to calculate the
required sample size.
In the result, u is number of predictors, v is error degrees of
freedom, so total n = u + v + 1
# Power analysis for multiple regression
pwr.f2.test(u = 5, f2 = 0.15, power = 0.80, sig.level = 0.05)
##
## Multiple regression power calculation
##
## u = 5
## v = 85.21369
## f2 = 0.15
## sig.level = 0.05
## power = 0.8
≈ 92 participants (from v ≈ 86, so n = 5 + 86 + 1)
Why do regression models require more people as you add more predictors? Each predictor consumes degrees of freedom. More predictors increase the model’s complexity, so a larger sample size is needed to maintain power and avoid overfitting or spurious results.
Why is power analysis important before conducting a study? Power analysis helps ensure a study has enough participants to detect expected effects, avoiding wasted resources on underpowered studies that may fail to find real effects or overpowered studies that use more resources than necessary.
Which design required the most participants? Why do you think that is? The multiple regression design required the most participants (≈92). This is likely because it involves multiple predictors, increasing the complexity of the model and thus requiring more data for stable and accurate estimates.
Which test would be most efficient if you had limited resources? The independent samples t-test with a slightly smaller sample (≈78 per group) would be efficient if the effect size is known and resources are tight, especially when comparing just two groups.
Submission Instructions:
Ensure to knit your document to HTML format, checking that all content is correctly displayed before submission.