Even a correctly run test can reach the wrong decision. It can reject a null hypothesis that is true, or fail to reject one that is false. A team planning an experiment wants to know how likely each mistake is before any data are collected, and above all whether the study has a fair chance of detecting an improvement large enough to be useful. This lesson defines the two errors, computes power for a simple test at two effect sizes, and turns the calculation around to choose a sample size.
Key terms
Type I error
Definition A type I error is rejecting when is true. A test has significance level when, under the model, its probability of rejecting is at most for every parameter value in . So the probability of a type I error is at most , and it can be smaller, for example for a discrete test statistic.
In plain words A type I error is a false alarm, and caps how often a true null sets one off. The level is a probability computed by assuming the null is true. It is not the probability that a particular significant result is a false alarm. That second probability also depends on how often the tested nulls are true and on the power against the real effects. Suppose hypotheses are tested, of them true nulls whose tests reject with probability exactly and with real effects that the tests detect with probability . The expected numbers of rejections are among the true nulls and among the real effects, so in the long run about 36 percent of the rejections are type I errors.
Example The example test of this lesson uses independent observations from a normal distribution with unknown mean and known standard deviation , and tests against at . The sample mean has standard error . With the quantile of the standard normal distribution, so that , the test rejects when the observed mean exceeds
If , then and exactly, so this test makes a type I error with probability .
Type II error
Definition A type II error is failing to reject when is false. Its probability depends on which value in is true, so it is always computed at a specified alternative value . It is written , the probability that the test fails to reject when is the true parameter value. A subscript such as marks a probability computed with that true value.
In plain words A type II error is a missed effect. A test does not have one type II error rate. It has one for each possible true effect, and a test like the example below misses small effects more often than large ones.
Example For the example test, if the true mean is , then and
If the true mean is , then . The same test misses a 2-unit effect about 74 percent of the time and a 5-unit effect about 20 percent of the time.
Power
Definition The power of a test at an alternative value is the probability of rejecting when is the true value, which is . The probability of rejecting, viewed as a function of the true parameter value, is the power function of the test. At values in it gives the type I error probability. Power depends on the true effect, the variability of the data, the sample size, the level , whether the test is one-sided or two-sided, and the design and model. For the one-sided z test of at level with observations, as in the example, the power at a true mean is
In plain words Power is the chance that the study detects an effect of a stated size if that effect is real. It always refers to a specific effect. For the example test at a true mean above , a larger sample, less noisy measurements, a larger true effect or a larger each raise it, though a larger also means more false alarms. Its power function equals at and drops below when , since a one-sided test is not looking in that direction.
Example For the example test the power is at and at , with the same rejection rule, sample size and noise. A simulation that draws 100,000 sample means from each alternative and applies the rule gives rejection frequencies close to these values, with Monte Carlo standard errors of about and . The simulation checks the arithmetic of the model. It is not evidence that a real effect exists.
Power analysis
Definition A power analysis, done when a study is planned, relates the significance level, sample size, variability, effect size and power for a stated test and model. It is most often used to find the sample size that gives a target power at an effect size chosen because it matters in practice. For the one-sided test of against with independent normal observations and known , and a target power larger than , the power at with is at least exactly when is at least
The planned sample size is this number rounded up to a whole number.
In plain words Decide in advance which effect would be worth detecting, then choose a sample large enough to detect it with high probability. The formula belongs to this one test. Unknown variance, a two-sided alternative, unequal groups, clustering or dropouts each call for a different calculation. Power computed after the study by plugging in the observed estimate, often called observed power, adds no information beyond the p-value. For the one-sided test above it is a decreasing function of the p-value alone and equals exactly when the p-value equals . After the study, a confidence interval for the effect is the useful summary.
Example Take , , and target power . With the quantile sum is , and
so the plan calls for observations. With observations the power at is about , while would give about .
Minimum detectable effect
Definition For a fixed design, sample size, level and target power , the minimum detectable effect is the smallest effect size at which the power of the test reaches . For the one-sided test with known described above,
In plain words The minimum detectable effect describes the design, not the data. Effects smaller than it can still produce a rejection, only with probability below the target. It is also a different idea from the smallest effect that would matter in practice, which comes from the subject, not from the sample size. A good plan makes the minimum detectable effect no larger than that practical threshold.
Example With , , and target power ,
A 2-unit effect is below this, and the power there is only about . Because the standard error shrinks like , quadrupling the sample to halves the minimum detectable effect to about units.
Optional stopping
Definition Optional stopping means letting the results seen so far decide when data collection ends, for example by testing after each batch of data and stopping at the first significant result, and then analyzing the data as if the sample size had been fixed in advance. When every look uses a z test at the same level, the probability under that at least one of several looks rejects exceeds that level, and it grows as looks are added. With independent, identically distributed observations and a z test at every look, a true null is eventually rejected with probability if the number of looks is unlimited.
In plain words Each look is another chance for noise to cross the line, and stopping as soon as it does keeps the false alarm and never collects the later data that might have reversed it. The looks are strongly dependent because they share data, so the inflation cannot be found by treating them as independent tests. Sequential designs that plan the looks in advance, with stricter boundaries set so that the overall type I error probability stays at most , avoid the problem.
Example Apply the example test with after observations and, if it does not reject, again after . When the null is true, the probability that at least one of the two looks rejects is about . With looks after , , , and observations it is about , well above the the analysis would report.
Check yourself
- For the example test (, , , rejection when ), find the power and the type II error probability at a true mean of .
Show the answer
If , then , and in standard units the boundary is . The power is
and the type II error probability is .
- A study uses the example test, which has power about against a 2-unit effect, and the result is not significant. Does the study rule out a 2-unit effect? Name two design changes that would raise the power at that effect.
Show the answer
No. If the true effect were 2 units, the test would fail to reject about 74 percent of the time, so a nonsignificant result is entirely ordinary under that effect. An interval estimate shows which effect sizes remain compatible with the data. More independent observations raise the power, and with the power at units is about . More precise measurement also raises it, since halving to at gives the same . A more efficient design such as pairing can help as well. Raising would increase power too, but only by accepting more false alarms.
- Under the same model (, one-sided, ), how many observations give power at least against a 5-unit effect? Use .
Show the answer
The quantile sum is , so the planning formula gives
so the plan needs observations. A check confirms it, since the power at is about with observations and about with . Rounding down would miss the target.