Correlation coefficient is used for effect size measure. Usse 0.1, 0.3, 0.5 to represent small, medium and large sizes.
# correlation coeffpwr::pwr.r.test(r =0.3, sig.level =0.05, power =0.8, 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
Linear regression (F-test)
F-test for linear regression is testinng whether \(R^2\) is greater than zero (one-sided). \(R^2\) is the explained variance by using the predictors, \(R^2 = 0.3\) means that 30% of the variance are explained by the model.
Cohen’s f2, based on \(R^2\), goodness of fit (\(f2 = R^2/(1-R^2)\)). use 0.02, 0.15, 0.35 to represent small, medium and large effect sizes.
u: number of predictors
v: n-u-1
as a result, sample size n = v+u+1
# effect size f2 = 0.15; use u=3 predictorspwr::pwr.f2.test(u =3, f2 =0.3, sig.level =0.05, power =0.8)
Multiple regression power calculation
u = 3
v = 36.47078
f2 = 0.3
sig.level = 0.05
power = 0.8
Here v = 73, sample size is 73+3+1 = 77.
Alternatively, can use pwrss::pwrss.f.reg(). The parameter is r2 rather than f2 (but can also use f2).
pwrss::pwrss.f.reg(r2 =0.3, k =0.3, power =0.8, alpha =0.05)
Linear Regression (F test)
R-squared Deviation from 0 (zero)
H0: r2 = 0
HA: r2 > 0
------------------------------
Statistical power = 0.8
n = 14
------------------------------
Numerator degrees of freedom = 0.3
Denominator degrees of freedom = 12.415
Non-centrality parameter = 5.878
Type I error rate = 0.05
Type II error rate = 0.2
# should be equivalent to# pwr::pwr.f2.test(u = 3, f2 = 0.3/0.7, sig.level = 0.05, power = 0.8)
GLM
Resources
Sample size calculation in clinical trial using R.
Park et al. 2023. https://doi.org/10.7602/jmis.2023.26.1.9
Bulus, M (2023) pwrss: Statistical Power and Sample Size Calculation Tools. R package version 0.3.1. https://CRAN.R-project.org/package=pwrss. Vignette documentation