
Additional Topic
Math 219
Heiberger and Holland
Sections 3.7 - 3.10

VO2Max 1 dataset
| Fitness | n | mean | sd |
|---|---|---|---|
| High | 24 | 117.46 | 10.70 |
| Low | 24 | 108.92 | 18.22 |
The observed difference in means is \[\begin{array}{lcr}\bar{x}_h-\bar{x}_l &=& 117.46-108.92\\ &=& 8.54\end{array}\]
Histogram of differences in means (null distribution) calculated from 1,000 random permutations of math achievement scores. Observed difference is indicated by dashed vertical line.
# A tibble: 1 × 2
n_extreme p_val
<int> <dbl>
1 28 0.028
pwr package.1
effect size, d.For two means with equal sample sizes, the effect size is given by
\(d = (\mu_h - \mu_l)/\sigma\)
\(\sigma = \sqrt{(s_h^2 + s_l^2)/2} = \sqrt{(10.70^2 + 18.22^2)/2} = 14.94\)
and
\(d = 8.54/14.94 = 0.572\)
Two-sample t test power calculation
n = 24
d = 0.572
sig.level = 0.05
power = 0.6207076
alternative = greater
NOTE: n is number in *each* group
pwr.t.test function to find the sample size we need to get the desired statistical power of 80%library(pwr)
pwr.t.test(n = NULL,
d = 0.572,
sig.level = 0.05,
alternative = "greater",
power = 0.8)
Two-sample t test power calculation
n = 38.48717
d = 0.572
sig.level = 0.05
power = 0.8
alternative = greater
NOTE: n is number in *each* group
library(pwr)
pwr.t.test(n = NULL,
d = 0.572,
sig.level = 0.01,
alternative = "greater",
power = 0.80)
Two-sample t test power calculation
n = 62.71908
d = 0.572
sig.level = 0.01
power = 0.8
alternative = greater
NOTE: n is number in *each* group
library(pwr)
pwr.t.test(n = NULL,
d = 0.572/2,
sig.level = 0.05,
alternative = "greater",
power = 0.80)
Two-sample t test power calculation
n = 151.8511
d = 0.286
sig.level = 0.05
power = 0.8
alternative = greater
NOTE: n is number in *each* group
cpr data set from the openintro package we explored in Ch. 14 & 17group: treatment (received blood thinner) or control (did not)outcome: died or survived (for at least 24 hours)| group | died | survived | total |
|---|---|---|---|
| control | 39 | 11 | 50 |
| treatment | 26 | 14 | 40 |
| total | 65 | 25 | 90 |
Difference in proportions of “survived”: \[\hat{p}_T-\hat{p}_C=\frac{14}{40}-\frac{11}{50}=0.13\]

effect size, h.For two proportions with different sample sizes, the effect size is given by
\[h = 2sin^{-1} (\sqrt{p_T}) - 2sin^{-1} (\sqrt{p_C})\]
\[h = 2sin^{-1} (\sqrt{0.35}) - 2sin^{-1} (\sqrt{0.22})\] \[ = 1.2661 - 0.9764 = 0.2897 \]
library(pwr)
pwr.2p2n.test(h = 0.2897,
n1 = 40,
n2 = 50,
sig.level = 0.05,
alternative = "two.sided")
difference of proportion power calculation for binomial distribution (arcsine transformation)
h = 0.2897
n1 = 40
n2 = 50
sig.level = 0.05
power = 0.2765951
alternative = two.sided
NOTE: different sample sizes
difference of proportion power calculation for binomial distribution (arcsine transformation)
h = 0.2897
n1 = 172
n2 = 215
sig.level = 0.05
power = 0.8083766
alternative = two.sided
NOTE: different sample sizes
effect size, w.To find effect size, w, for a two-way table
\(w = \sqrt{\sum_{i=1}^{m} (p0_i-p1_i)^2/p0_i}\)
pns_effect <- ES.w2(pnsprop_table)
pwr.chisq.test(w = pns_effect,
N= total_sum,
df = 4,
sig.level = 0.05)
Chi squared power calculation
w = 0.0943384
N = 149
df = 4
sig.level = 0.05
power = 0.1260314
NOTE: N is the number of observations
pwr finds required sample size, N
Chi squared power calculation
w = 0.0943384
N = 1341.083
df = 4
sig.level = 0.05
power = 0.8
NOTE: N is the number of observations
| Inference Test | Function1 | Effect |
|---|---|---|
| one proportion | pwr.p.test | h |
| two proportion (equal n) | pwr.2p.test | h |
| t-test (1, equal n, paired) | pwr.t.test | d |
| t-test (unequal n) | pwr.t2n.test | d |
| balanced one-way ANOVA | pwr.anova.test | f |
\(f = \sqrt{\sum_{i=1}^{k} p_i(\mu_i-\mu)^2/\sigma^2}\)
See Statistical Power Analysis for the Behavioral Sciences by J Cohen for information on calculating effect sizes for statistical power calculations
the effect size)pwr package in R to find the necessary sample size to control these errors