Learning Goals:

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.

library(pwr)

Exercise 1: Independent Samples t-Test

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.

result <- pwr.t.test(d = 0.32, power = 0.80, sig.level = 0.05, type = "two.sample", alternative = "two.sided")
result
## 
##      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

What is the minimum number of participants required per group?: About 155.

Why is power important in this type of comparison?: Power is important in this type of comparison because it tells you how likely the study is to detect a real effect. With power being 0.8 (80%), there is a good chance of finding a true difference between the two therapy groups and avoiding missing meaningful results because of sample size. It makes the study results more reliable.

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.

result_corr <- pwr.r.test(r = 0.3, power = 0.80, sig.level = 0.05, alternative = "two.sided")
result_corr
## 
##      approximate correlation power calculation (arctangh transformation) 
## 
##               n = 84.07364
##               r = 0.3
##       sig.level = 0.05
##           power = 0.8
##     alternative = two.sided

How many participants are needed?: 84 participants

Why would correlational studies require more/less people than a t-test?: Correlational studies will sometimes require more poeple because when you have two continuous variables, it can be harder to detect a relationship because the correlation is small. It can also require less people if the effect size is large and the data is less variable. T-tests compare differences between groups, and the sample size depends on how big the difference is and how spread out the data is. In summary, it depends upon the size of the effect and study design for whether correlational studies need more or fewer particpants.

Question 3: Chi-Square Test

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.

result_chisq <- pwr.chisq.test(w = 0.3, df = 3, power = 0.80, sig.level = 0.05)
result_chisq
## 
##      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

What is the total number of participants needed?: About 122 participants.

How does degrees of freedom affect the sample size?: Degrees of freedom depend on how many categories are in the data. When you have more categories (meaning higher degrees of freedom), you need a larger sample size to detect an effect. The degrees of freedom reflect the structure of the data and influence how many participants are needed.

Question 4: Multiple Regression

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

f2 <- 0.15  
u <- 5      
power <- 0.80  
sig.level <- 0.05  

result <- pwr.f2.test(u = u, f2 = f2, power = power, sig.level = sig.level)

result
## 
##      Multiple regression power calculation 
## 
##               u = 5
##               v = 85.21369
##              f2 = 0.15
##       sig.level = 0.05
##           power = 0.8

What is the total number of participants you need?: (n=u+v+1) n = 5 + 85.21369 + 1 = 91.21369. About 92 participants

Why do regression models require more people as you add more predictors? Regression models require more people as you add more predictors because each predictor adds a new parameter to to estimate, and more predictors mean the model is more complex and needs more data to accurately estimate the effects. It makes the results more reliable.

Wrap-Up Questions. Answer these in your own words:

Why is power analysis important before conducting a study?: It helps you figure out how many participants you will need to detect an effect if it exists. Additionally, it prevents having too many participants and proves your study results are reliable and trustworthy.

Which design required the most participants? Why do you think that is? The design that required the most participants was the independent samples t-test. I think that is because a larger size was needed to confidently detect the difference between the two groups, and the expected effect size of .32 is small. Smaller effect sizes usually mean a larger sample is required.

Which test would be most efficient if you had limited resources?: A correlation study would be the most efficient if you had limited resources because it requires fewer participants compared to the other tests.