WOLFRAM NOTEBOOK

WOLFRAM|DEMONSTRATIONS PROJECT

Exploring Robustness of Mean-Difference Confidence Intervals

random seed
1987
n
X
5
n
Y
5
σ
X
1
distribution of X
normal
uniform
Laplace
exponential
distribution of Y
normal
uniform
Laplace
exponential
method
t (Welch)
t (pooled)
Z
Z (pooled)
t (conservative)
This Demonstration examines confidence intervals at the 95% level for the difference in means in random samples
X
1
,,
X
n
X
and
Y
1
,,
Y
n
Y
from either a normal, uniform, Laplace, or centered exponential distribution. The distributions all have mean 0. The variance of the
X
distribution can be varied from 1 to 10 and the variance of
Y
is fixed at 1. Several methods available in the Mathematica function MeanDifferenceCI are examined. The "t (Welch)" method is the default method with MeanDifferenceCI, "t (pooled)" corresponds to the option setting
EqualVariancesTrue
, while "Z" and "Z (pooled)" correspond to setting the option KnownVariance to the sample variances of
X
and
Y
or else to the pooled variance estimate. The fifth method is a conservative approximation using the two-sample t-statistic with degrees of freedom equal to
min(
n
x
,
n
y
)-1
.
The scaling on the horizontal axis is in terms of
σ
δ
=
1+
2
σ
x
, the standard deviation of
X-Y
.
Each iteration shows 100 confidence intervals, the nominal coverage probability
C
, and the empirical coverage probability
C
. By changing the random seed, more confidence intervals are produced and an increasingly accurate estimate of the true coverage probability is obtained. Try doing at least 10,000 simulations.
If the true coverage probability is greater than the nominal one, in this case set to 95% in our initialization code, the method is said to be conservative. Ideally the empirical coverage probability should be close to the nominal value. As an approximation, conservative confidence intervals are much more acceptable than ones that are not.
Using this Demonstration you can easily find that the "t (pooled)" method is not conservative when the variances are not equal. Also the
Z
-methods do not work well unless the sample sizes are quite large. Overall the "t (Welch)" works best even though it is also an approximation. The "t (pooled)" is exact for normal populations with equal variances but is not recommended since it is not robust when this assumption does not hold. The loss in degrees of freedom with the assumption of unequal variances is usually not as important.
The 95% confidence interval for
δ=
μ
Y
-
μ
X
is equivalent to a test of the null hypothesis
H
0
:δ=0
versus
H
a
:δ0
at level
α=0.05
. The empirical type I error rate is estimated by
α
=1-
C
. The red lines correspond to cases where
H
0
is rejected at the 5% level.
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.