One-Sample t-Test and Confidence Interval with Dot Chart in Small Samples

​
δ/σ
1.5
n
9
random seed
α
0.1
0.05
0.01
show null distribution
show true distribution
show sampling distribution
show sample mean
show confidence interval & p-value
show power function
The dot chart represents a random sample of size
n=9
from a normal distribution, shown in blue, with mean
μ
0
+δ
and standard deviation
σ
. This is the true distribution. This Demonstration focuses on the null hypothesis,
H
0
:
μ=
μ
0
. For hypothesis testing, it is assumed that the sample is from a normal population with unknown mean and unknown variance. The hypothetical distribution,
N(
μ
0
,σ)
, is shown in green. When
δ=0
, the null distribution and true distribution are the same, but otherwise they are different.
The gray curve shows the sampling distribution. The
(1-α)
%
two-sided confidence interval based on the random sample is shown below with
α=0.05
. The confidence interval is colored red, to indicate that the hypothesized mean
μ
0
is not included in the interval; otherwise the color is blue. So when
δ=0
, this confidence interval will be blue about
100(1-α)%
of the time and for larger
|δ|
this happens less frequently.
The observed two-sided
p
-value is shown at the top.
By using the "random seed" slider, we can see that the
p
-values are random and depend on the random sample. The location and width of the confidence interval as well as the sampling distribution also vary and depend on the random sample. Both of these widths tend to decrease as the sample size increases but there is considerable variation due to random sampling. Similarly, when
α
is increased or decreased the width of the confidence interval tends to increase or decrease.
The sample mean is represented by the thin magenta line extending from the midpoint of the confidence interval to the center value of the sampling density.
The width of the confidence tends to increase if
α
is decreased, although due to the small samples there is a large variation simply due to random sampling. This is noticeable by changing the random seed.
The confidence interval also tends to increase if the sample size
n
is decreased as does the width of the sampling distribution. Due to the small samples, there are large variations in the width of the confidence interval and sampling distribution.

Details

We focus on small samples,
n=3,…,12
to avoid resizing and thus distorting the graphic, which is an important consideration for dynamic plots.
Snapshot 1: A new sample with
n=12
instead of
n=9
. The width of the confidence interval is slightly larger than in the thumbnail as might be expected. But click the "random seed" slider "+" button and then click the play button to see there is considerable variation in the size of the confidence interval. This is because the t-test is used. If a
Z
test were used, the width of the confidence interval would only depend on
n
and
α
and not on the actual data.
Snapshot 2: Same setting as snapshot 1 but a new sample. Notice the sampling distribution has changed and is not quite so centered over the true distribution. In this case, the confidence interval is actually wider than snapshot 1 and even wider than the case when
n=9
. This is due to randomness.
Snapshot 3: This scenario provides a teaching simulation. The instructor might say, "I think the average height of men in this class is about 5.5 feet". The null distribution with
μ
0
=
′
5.5
is shown. The dot chart shows the results of a simulated sample of size 3. In this case, all the observations are greater than
μ
0
.
Snapshot 4: The 95% confidence and the
p
-value are now shown. The 95% confidence interval includes
μ
0
and the
p
-value is 0.1888 so there is evidence against finding
H
0
could easily be due to chance. We have used a two-sided test, which is more conservative than one-sided alternatives. In general, as recommended in[1] §1.8, one-sided tests may, in actual practice, too easily result in spurious findings and so are not recommended.
Snapshot 5: Increasing the size of sample to
n=8
provides strong evidence that
H
0
is not true.
Snapshot 6: Let
β
and
1-β
denote the probability of a type II error and power, respectively. The power curve,
1-β
versus
δ/σ
, for the two-sample t-test when
n=8
and
α=0.05
is shown. By symmetry, the curve is only shown for
δ/σ≥0
. Green is used to indicate the power at the set value of
δ
, in this case
δ/σ=1
. In planned experiments, usually a minimum power of 90% is desired and the green lines indicate the size of
δ/σ
needed to attain 90% power. So from the plot we see that
δ/σ=1
,
1-β≈0.68
and that to achieve 90% we would need
δ/σ=1.35
. Another way 90% could be achieved is by increasing the sample size
n
. Slide
n
up to 12 and you see that we can attain about 90% with
n=12
. The computation of power in the one-sample t-test is discussed in many textbooks (see also Noncentral t-distribution). To exit the power curve display, uncheck the checkbox.
Snapshot 7: When
δ=0
is selected, we can explore how the t-test behaves when the null hypothesis is true. In this case the
p
-value is uniformly distributed between 0 and 1. When the "random seed" slider is changed, fresh
p
-values and confidence intervals are generated. If
δ
is increased, the
p
-values are still random but tend to be smaller reflecting the fact that
H
0
becomes less tenable.
Snapshot 8: Similar to snapshot 7, but we just show the true distribution and the sampling distribution and ignore the hypothesis testing.
Many other scenarios that offer illuminating insights may be obtained by experimenting with other settings.

References

[1] G. van Belle, Statistical Rules of Thumb, 2nd ed., New York: Wiley, 2008.

External Links

Hypothesis Testing (Wolfram MathWorld)
How Do Confidence Intervals Work?
Exploring Robustness of Mean-Difference Confidence Intervals
Robustness of Student t in the One-Sample Problem
Sampling Distribution of the Mean and Standard Deviation in Various Populations
The p-Value in One-Sample Tests for the Mean

Permanent Citation

Douglas Woolford, Ian McLeod
​
​"One-Sample t-Test and Confidence Interval with Dot Chart in Small Samples"​
​http://demonstrations.wolfram.com/OneSampleTTestAndConfidenceIntervalWithDotChartInSmallSample/​
​Wolfram Demonstrations Project​
​Published: August 30, 2011