TB sections 5.4
2024-11-20
Let’s watch this youtube video to jog our memory (remind us of what we learned):
Study Design:1
What elements are at play?
More familiar with first two, but let’s define #3 and #4 more
Power (or sensitivity) (\(1 - \beta\)): Probability of rejecting the null hypothesis given that the null is false (correct)
From the applet at https://rpsychologist.com/d3/NHST/
Let’s look at the following scenarios:
Solve for power: decreasing type 1 error (\(\alpha\))
Solve for power: increasing type 1 error (\(\alpha\))
Solve for power: decrease sample size
Solve for power: increase sample size
Solve for power: increase difference of means
Solve for power: decrease difference of means
From the applet at https://rpsychologist.com/d3/NHST/
Let’s say we have:
Find the power of a 2-sided test if the actual mean is \(3\) and our significance level is 0.05.
Let’s say we have:
Find the power of a 2-sided test if the actual mean is \(3\) and our significance level is 0.05.
Thus under the alternative population, we need to calculate \(P(X_A \le -1.96) + P(X_A \ge 1.96)\)
Under the alternative population we have \(X_A \sim Norm(3,1)\)
# left tail + right tail:
pnorm(-1.96, mean=3, sd=1,
lower.tail=TRUE) +
pnorm(1.96, mean=3, sd=1,
lower.tail=FALSE)
[1] 0.8508304
Answer: The power is 85%
pnorm(-1.96, mean=3, sd=1, lower.tail=TRUE)
is essentially 0 in this case.pwr
for power analyses1pwr.t.test
for both one- and two-sample t-testsLeave out:
n
: returns sample sized
: returns Cohen’s d/effect size (next slide)sig.level
: get significance level (not typical)power
: returns powerd
is Cohen’s d effect size
One-sample test (or paired t-test):
\[d = \frac{\mu-\mu_0}{s}\]
Two-sample test (independent):
\[d = \frac{\bar{x}_1 - \bar{x}_2}{s_{pooled}}\]
Conversely, we can calculate how much power we had in our body temperature one-sample test, given the sample size of 130.
\[1-\beta= P\left(Z \leq z-z_{1-\alpha/2}\right)+P\left(Z \leq -z-z_{1-\alpha/2}\right) \quad ,\quad \text{where } z=\frac{\mu-\mu_0}{s/\sqrt{n}}\]
\(\Phi\) is the probability for a standard normal distribution
[1] -5.466595
[1] 0.9997731
If the population mean is 98.2 instead of 98.6, we have a 99.98% chance of correctly rejecting \(H_0\) when the sample size is 130.
d
: \(d = \frac{\mu-\mu_0}{s}\)pwr
: sample size for one mean testSpecify all parameters except for the sample size:
pwr
: power for one mean testSpecify all parameters except for the power:
pwr
: Two-sample t-test: sample sizeExample: Let’s revisit our caffeine taps study. Investigators want to know what sample size they would need to detect a 2 point difference between the two groups. Assume the SD in both group samples is 2.6.
Specify all parameters except for the sample size:
::::::
pwr
: Two-sample t-test: powerExample: Let’s revisit our caffeine taps study. Investigators want to know what power they have to detect a 2 point difference between the two groups. The two groups are both size 35 (like in our previous example). Assume the SD in both group samples is 2.6.
Specify all parameters except for the power:
Lesson 14 Slides