3
$\begingroup$

In Jay L. Devore 'Probability and Statistics for Engineering and the Sciences', he presents the following formula to retrieve β, when we consider a two-tailed test and the population mean is known.

$\beta_{(\mu')} = \Phi({z_{\alpha/2}+\frac{\mu_0 - \mu'}{\sigma/\sqrt{n}}}) - \Phi({-z_{\alpha/2}+\frac{\mu_0 - \mu'}{\sigma/\sqrt{n}}})$

Therefore I tried to apply this to a mock-up data:

Desired $\alpha = 0.05$

$\mu_0 = 14$

$\mu' = 15$

$n = 4$

$\sigma = 1.496$

From this I get:

$\beta = \Phi(1.96 + \frac{-1}{0.374}) - \Phi(- 1.96 + \frac{-1}{0.374})$

$\beta = \Phi(-0.714) - \Phi(-4.634)$

$β = 0.24$

However, when I try to get power from R language:

> power.t.test(n = 4, delta = 1, sd = 1.496, 
               sig.level = 0.05, power = NULL, 
               type = "one.sample", alternative = "two.sided")

I get power = $0.1578781$ ($\beta = 0.84$).

This is a huge difference and it's making me nuts. What am I doing wrong, and why both formulas seem to be the same thing, though they are obviously not?

$\endgroup$
2
  • 4
    $\begingroup$ Devore is pretty careful, so I'm sure he remarks at some point that this formula holds only for a Z test and not a t test. $\endgroup$
    – whuber
    Commented Jan 1, 2018 at 16:01
  • 1
    $\begingroup$ One problem is that in your case $\sigma$/sqrt(n) =1.496/2=0.748 and not 0.374. $\endgroup$ Commented Jan 1, 2018 at 17:35

1 Answer 1

8
$\begingroup$

There are several mistakes here, first of all, since $n=4$, you should divide $\sigma$ by $\sqrt{4}=2$ instead. So the correct type II rate is

> pnorm(qnorm(0.975) - 2 / 1.496) - pnorm(qnorm(0.025) - 2 / 1.496)
[1] 0.7328904

To check the result in R, you may call pwr.norm.test from package pwr:

> pwr.norm.test(d = 1 / 1.496, n = 4, sig.level = 0.05)

     Mean power calculation for normal distribution with known variance 

              d = 0.6684492
              n = 4
      sig.level = 0.05
          power = 0.2671096
    alternative = two.sided

On the other hand, power.t.test computes the power of the $t$-test, where population $\sigma$ is unknown and must be estimated. In this case, the power function is given by $$F\left(t_{n-1,\alpha_0/2}\right)+1-F\left(-t_{n-1,\alpha_0/2}\right),$$ where $F$ denotes cdf of the non-central $t$-distribution with df $n-1$ and non-centrality $$\psi=\frac{\mu-\mu_0}{\sigma/\sqrt{n}}.$$ In R, the power can be computed in the following ways:

> pt(qt(0.025, 3), 3, ncp = 2 / 1.496) + pt(qt(0.975, 3), 3, ncp = 2 / 1.496, lower.tail = F)
[1] 0.1592488
> power.t.test(n = 4, delta = 1, sd = 1.496, sig.level = 0.05, type = "one.sample" , strict = T)

     One-sample t test power calculation 

              n = 4
          delta = 1
             sd = 1.496
      sig.level = 0.05
          power = 0.1592488
    alternative = two.sided

The $0.1578781$ value you previously got only accounts for one tail (without setting strict = TRUE).

$\endgroup$
3
  • $\begingroup$ Thanks very much for your answer. I'm following it step by step to learn the most from it. For instance, I didn't understand why you set the variable d in pwr.norm.test, which refers to effect size, as 1/1.496. Could you please clarify this? $\endgroup$
    – rnahumaf
    Commented Jan 1, 2018 at 19:01
  • 1
    $\begingroup$ @rnahumaf: The effect size here is also known as Cohen's $d$, google it should give you plenty of results. Also check out pwr's documentation to see how to use pwr.norm.test $\endgroup$
    – Francis
    Commented Jan 1, 2018 at 19:09
  • 1
    $\begingroup$ @rnahumaf: that said, internally pwr.norm.test calls pnorm(qnorm(sig.level/2, lower = FALSE) - d * sqrt(n)), so it's more of a parameterization issue. $\endgroup$
    – Francis
    Commented Jan 1, 2018 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.