Anda di halaman 1dari 87

BOX PLOT

How to estimate the mean from a normal distribution.


How to compute a 95% confidence interval for the true
unknown population mean.
How to statistically test whether the population
sampled could have a specified population mean.
The five parts of a statistical test.
Type I and Type II errors associated with testing.
In general how sample size is estimated.
Worked example.
In this section we will discuss:
One Sample Mean Inference
Point Estimate of is the sample mean:
y
The Central Limit Theorems
tell us the shape of the
sampling
distribution
, N
n
| |
o

|
\ .
Estimation of the Population Mean, .
Interval Estimate of is the confidence interval:
n
y
o
o =
-1.96
+1.96
95% of sample means
expected to lie
in this interval.
2.5% of sample
means expected to
lie in this interval.
2.5% of sample
means expected to
lie in this interval.

n
o
n
o
Interval Estimate of the Population Mean
) 96 . 1 , 96 . 1 ( in
y y
y y o o +
is equivalent to the event
) 96 . 1 , 96 . 1 ( in
y y
y o o +
The event
x
y
-4 -3 -2 -1 0 1 2 3 4

y
y
y o 96 . 1
y
y o 96 . 1 +
y
o 96 . 1
1.96
y
o +
x
y
-4 -3 -2 -1 0 1 2 3 4
y
y o 96 . 1
1.96
y
y o +

1.96
y
o +
y
o 96 . 1
y
x
y
-4 -3 -2 -1 0 1 2 3 4

y y
y o 96 . 1 y
y o 96 . 1 +
In repeated sampling, the interval would
encompass the true parameter value 95%
of the time.
5% of the intervals dont include the true mean.
95% of the intervals include the true mean.
Meaning of a 95% Confidence Interval

99% Confidence Interval


(1-)100% Confidence Interval
y
y o 58 . 2
y
z y o
o
2

Read from Table


of the standard normal.
The o/2 critical value of the standard
normal distribution.
The value of the standard normal
distribution for which P(z>z
o/2
)= o/2 .
y
y o 96 . 1 95% Confidence Interval
y
n
o
o =
Critical Value for Confidence Interval


Confidence
Coefficient
(1-o)
Area to left of
z-value
1-o/2
Area to right of
z-value
o/2
Corresponding
z-value
z
o/2


.90 .95 .05 1.645

.95 .975 .025 1.96

.98 .99 .01 2.33

.99 .995 .005 2.58

.99
Common Critical Values
Using an Estimate of o
What if we dont know the value of o ?
We simply replace o with its estimate s
in the confidence interval equation.
However, the sampling distribution of z is no longer normal, but follows
a t distribution instead.
This involves replacing in the CI the normal critical value, z
o/2
, with a
critical value from a t distribution, t
n-1, a/2
(more on this later).
If n is large (30 or more), it turns out that because of the Central Limit
Theorem the normal is a good enough approximation to the t, and
we can therefore use z
o/2
, after all. (But use the t all the time.)

=
n
i
i
y y
n
s
1
2
) (
1
1
y
z
s
n

=
n=50 y=105 s=11
In a large amount of repeated
sampling, 95 out of 100 intervals
constructed this way would include the
true mean.
o
o
o
=
=
=
0 05
2
0 025
196
2
.
.
. z
y z n y s n
n
z

o o
o
/ /
( . )( )
( . , . )
2 2
105 196
11
10195 108 05
or
95% CI for
99% CI for
58 . 2
005 . 0
2
01 . 0
2
=
=
=
o
o
o
z
y z n y s n
n
z

o o
o
/ /
( . )( )
( . , . )
2 2
105 258
11
10098 10901
or
In a large amount of repeated
sampling, 99 out of 100 intervals
constructed this way would include the
true mean.
Example
The CI equation can be turned around to allow computation of the
sample size needed to estimate the true mean with a specified
level of precision and confidence.
Need three things:

1) Target level of confidence: (1-o)100%
2) Tolerable error (half of CI width): E
3) Estimate of population standard deviation: o
Typical Confidence Levels
90%
95%
99%
i) Prior Knowledge
ii) Pilot Sample
iii) Expert Guess (range/4)
Target Precision
Sample Size Determination
n
y
z
o
o 2 /

Equate the CI precision to the target precision and solve for n.


n
E
n
E
E
n
z z z
=
|
.
|

\
|
=> = => =
2
2 / 2 / 2 /
o o o
o o o
Estimated
sample
size
Equate this to E.
Precision can be specified relative to o.
100(1-o)% CI for
( ) % 95 % 100 1
25 . 0
oz 2
=
=
=
o
o
E
o
2
025 = .
o/
.
2
196
z
=
( ) integer) highest next to (round 246 96 . 1 2 4
25 .
2 96 . 1
2
2
= =
|
.
|

\
|

n
E
2
2
z
=
|
.
|

\
|
o
o/
Sample Size Example
Take home message: If you have some idea of
the underlying variability in the population and
you know roughly how precise you wish the
mean estimate to be you can compute needed
sample size.
Two Independent Populations
Develop a confidence interval for the difference in
means between two independent normal
populations.
Develop a statistical test for the difference in means
between two independent normal populations,
assuming equal population variances.
Develop a statistical test for the difference in means
between two independent normal populations,
assuming unequal population variances.
Develop a nonparametric statistical test for the
difference in means between two independent
populations, assuming equal population variances.
Goals
Take soil samples
at random locations
within the site and
at random locations
at areas outside the
site.

Assume values at
areas outside the
site are unaffected
by site activities
that lead to
contamination.
Need to determine if concentration of contaminant at an old industrial
site is greater than background levels from areas surrounding the site.
Situation
1. Background level of contaminant is not statistically different from
the no-detect level (-5.0) [on a natural log scale].
2. Site level of contaminant is not statistically different from the no-
detect level (-5.0).
3. Site level is not statistically different from Background level.

2
-5.0

2
Is the situation
this or
this?
Hypotheses of Interests
Background level of contaminant is not statistically
different from the no-detect level (-5.0).
Site level of contaminant is not statistically
different from the no-detect level (-5.0).
One sided t-tests:
i
i i
i
n
s
y
t
) (
=
R.R.
1 ,
>
i
n i
t t
o
n t
.05,n
6 1.943
7 1.895
8 1.860
9 1.833
T. S.
i = 1 => Background areas (B)
i = 2 => Contamination site (S)
Critical Values
One- Sample Hypothesis Tests
H
0
:
i
s -5.0
H
A
:
i
> -5.0
Y
-2.96
-1.09
-3.13
-2.12
-2.59
-4.31
-1.20
13 1 s
48 2 y
7 n
1
1
1
.
.
=
=
=
H
0
:
B
s
0
= -5.0
H
A
:
B
>
0
= -5.0
T.S.
R.R.
1 0
2.48 ( 5.0)
5.90
1.13
7
y
t
s
n

= = =
Pr(Type I error) = o = 0.05
Reject H
0
if t > t
o,n-1
T
0.05,6
=1.943
Conclusion:
Since 5.90 > 1.943 we reject H
0
and
conclude that the true average
background level is above -5.0.
Same test could be performed for contaminated site data.
DATA and One-Sided T-tests
H
0
: Site level is not different from Background level. (
B
=
S
)

H
A
: Site level is different from Background level. (
B
=
S
)
This requires comparing sample means from two
independent samples, one from each population.
T. S.
2 1
y y
2 1
s
y y
t

=
) (
the standard error of the
difference of the two means.
2 1
y y
s

Obvious
test
statistic.
Comparison Hypothesis
If the true variances of the two populations are known,
we use the property of independent random variables
that says that Var(X-Y) = Var(X) + Var(Y)
[Only works for variances, not standard deviations.]
2 1
) (
2 1
y y
y y
z

=
o
T. S.
Standard Error of the Difference of Two Means
2
2
2
1
2
1
2 1
2
y y
n n
y Var y Var
2 1
o
+
o
= + = o

) ( ) (
2
2
2
1
2
1
2 1
n n
y y
o o
o + =

From sampling Dist of


From sampling Dist of
1
Y
2
Y
2
) 1 ( ) 1 (
2 1
2
2 2
2
1 1
+
+
=
n n
s n s n
s
p
2 1
1 1
2 1
n n
s s
p y y
+ =

2 1
1 1
2 1
n n
p y y
+ =

o o
True standard error of
the difference of two means.
Estimate of the standard
error of the mean differences.
Estimate of the common
(Pooled) standard deviation.
Assume the two populations have the same, or
nearly the same true variance, o
2
p
.
( )
2 1
p
2 n n
2
2 1
n
1
n
1
s t y y
2 1
+
+
o
,
2 n n
s 1 n s 1 n
s
2 1
2
2 2
2
1 1
p
+
+
=
) ( ) (
Assume confidence level of (1-o)100%
Confidence Interval for difference
0 2 1 o
D : H =
df , 2 / o 0 2 1 A
df , o 0 2 1 A
df , o 0 2 1 A
t t if H reject , D | | : H
t t if H reject , D : H
t t if H reject , D : H
o
o
o



> >
< <
> >
Test Statistic:
2 1
p
o 2 1
n
1
n
1
s
D y y
t
+

=
2 n n
s 1 n s 1 n
s
2 1
2
2 2
2
1 1
p
+
+
=
) ( ) (
2 n n df
2 1
+ =
Pr(Type I Error) = o
Pooled Variances T-test
Statistical test for
difference of means
H
0
:
B
-
S
= 0
H
A
:
B
-
s
= 0
H
A
: Average site level significantly different from background.
Y
B
Y
S

-2.96 -3.81
-1.09 -5.83
-3.13 -5.70
-2.12 -4.11
-2.59 -3.83
-4.31 -5.01
-1.20 -5.49
13 1 s
48 2 y
7 n
1
1
1
.
.
=
=
=
89 0 s
83 4 y
7 n
2
2
2
.
.
=
=
=
Background Site
EXAMPLE
CONT
2 7 7
89 . 0 ) 6 ( 13 . 1 ) 6 (
2
) 1 ( ) 1 (
2 2
2 1
2
2 2
2
1 1
+
+
=
+
+
=
n n
s n s n
s
p
017 . 1 =
017 1 s
p
. =
5436 .
7
1
7
1
017 . 1
1 1
2 1
2 1
= + = + =

n n
s s
p y y
T.S.
305 . 4
5436 . 0
0 ) 82 . 4 ( 48 . 2
1 1
2 1
2 1
=

=
+

=
n n
s
D y y
t
p
o
R.R. Reject if:
179 . 2
12 , 025 .
,
2
= = > t t t
df
o
Conclusion: Since 4.304 > 2.179 we reject H
0
and
conclude that site concentration levels are
significantly different from background.
Pr(Type I Error) = o = 0.05
What if the two populations do
not have the same variance?
New estimate of standard error of difference.
Test and CI is no longer exact - uses Satterthwaites
approximate df value (df).
T.S.:
2
2
2
1
2
1
f d , 2 / 2 1
) (
n
s
n
s
t y y +
' o
,
) 1 )( 1 ( ) 1 (
) 1 )( 1 (
f d
2
1
2
2
2 1
c n c n
n n
+

=
'
2
2
2 1
2
1
1
2
1
/ /
/
n s n s
n s
c
+
=
Round df down to the nearest integer.
Separate Variances
CI and T-test
C.I.:
2
2
2
1
2
1
2 1
'
) (
n
s
n
s
D y y t
o
+ =
Redo Test
For site contamination example, assume o
1
= o
2
and redo test.
6171 .
7
7921 . 0
7
276 . 1
7
276 . 1
2
2
2
1
2
1
1
2
1
=
|
.
|

\
|
+
|
.
|

\
|
|
.
|

\
|
=
+
=
n
s
n
s
n
s
c
T.S.
304 4
5437 0
34 2
7
87 0
7
13 1
82 4 48 2
n
s
n
s
D y y
t
2 2
2
2
2
1
2
1
o 2 1
.
.
.
. .
) . ( ,
'
= =
+

=
+

=
Conclusion:
Since 4.304 > 2.201 we reject H
0
and
conclude that site concentration levels are
significantly different from background.
R.R.
Reject if:
201 . 2 | |
11 , 025 . df , 2 /
= = >
'
t t t
o
4 . 11
) 6171 . 0 1 )( 6 ( 6171 . 0 ) 6 (
) 6 )( 6 (

) 1 )( 1 ( ) 1 (
) 1 )( 1 (
f d
2 2
2
2
2
1
2 1
=
+
=
+

=
'
c n c n
n n
One-sided Test:
n n n
z z
n = = A >
A
+
=
2 1 2 1
2
2 2
, | | ,
) ( 2

o
| o
o = Pr(Type I Error)
| = Pr(Type II Error)
Two-sided Test:
n n n
z z
n = = A >
A
+
=
2 1 2 1
2
2
2 /
2
, | | ,
) ( 2

o
| o
Sample Size
Determination
(1-o)100% CI for
1

2
:
n n n E
E
z
n = = = =
2 1
2
2
2 /
2
width, interval
2
1
,
2
o
o
In our sample, a A of 2.34 was observed. What if we
had wanted to be sure that a A of say 1 unit would be
declared significant with:
0.05 = o = Pr(Type I Error)
0.10 = | = Pr(Type II Error)
Assume a common population variance of o
2
= 1.
18 11 17 280 1 645 1 2
1
z z 1 2
z z 2
n
2
2
2
1 0 05 0
2
2
2 2
~ = + =
+
=
A
+ o
=
| o
. ) . . (
) (
) ( ) (
) (
. .
21 ) 280 . 1 96 . 1 ( 2
) 1 (
) ( ) 1 ( 2
) ( 2
2
2
2
1 . 0 025 . 0
2
2
2
2
2
~ + =
+
=
A
+
=
z z
z z
n
| o
o
Two-sided test
One-sided test
Example of Sample Size Determination
n=n
1
=n
2
Summary
These two-sample inferences require the assumption of
independent, normal population distributions.
If we have reason to believe the two population
variances are equal, then we should use the pooled
variances method. This results in more powerful
inferences.
We need not worry about the normality assumption
when both sample sizes are large, all results are still
approximately correct. (CLT.)
What to do when independence does not hold?
Advanced!
Testing Multiple Means
and the Analysis of Variance
Situations where comparing more than two
means is important.
The approach to testing equality of more than
two means.
Introduction to the analysis of variance table, its
construction and use.
Study Designs and Analysis
Approaches
1. Simple Random Sample
from a population with
known o - continuous
response.
2. Simple Random Sample
from a population with
unknown o - continuous
response.
3. Simple Random Samples
from 2 popns with known o.
4. Simple Random Samples
from 2 popns with unknown
o.
One sample z-test.
One sample t-test.
Two sample z-test.
Two sample t-test.
One sample is drawn independently and randomly from
each of t > 2 populations.
Sampling Study with t>2
Populations
Objective: to compare the means of the t populations for
statistically significant differences in responses.
Initially we will assume all populations have common
variance, later, we will test to see if this is indeed true.
(Homogeneity of variance tests).
Health
Eaters
Sampling Study
Vegetarians
Meat &
Potato
Eaters
Random
Sample
Cholesterol
Levels
1
n 1
12
11
y
y
y

Random
Sample
Random
Sample
2
n 2
22
21
y
y
y

3
n 3
32
31
y
y
y

Experimental Study
with t>2 treatments
Experimental Units: samples of size n
1
, n
2
, , n
t
, are
independently and randomly drawn from one
populations.
Separate treatments are applied to each sample.
A treatment is something done to the experimental
units that would be expected to change the distribution
(usually only the mean) of the response(s).
Note: if all samples are drawn from the same population
before application of treatments, the homogeneity of
variances assumption might be plausible.
Experimental Study
Male College Undergraduate Students
Set of
Experimental
Units
Health
Diet
Veg.
Diet
M & P
Diet
Cholesterol
Levels @ 1
year.
1
n 1
12
11
y
y
y

2
n 2
22
21
y
y
y

3
n 3
32
31
y
y
y

Set of
Experimental
Units
Set of
Experimental
Units
Random Sampling
Responses
Hypothesis
0 1 2
:
: some of the means are different
t
a
H
H
= = =
Let
i
be the true mean of treatment group i (or population i ).
Hence we are interested in whether all the groups
(populations) have exactly the same true means.
The alternative is that some of the groups (populations)
differ from the others in their means.

Let
0
be the hypothesized common mean under H
0
.
Each population has normally distributed responses
around their own means, but the variances are the same
across all populations.
A Simple Model
Let y
ij
be the response for experimental unit j in group i.
i=1,2, ..., t
j=1,2, ..., n
i

i ij
) y ( E =
Let c
ij
= y
ij
-
i
be the residual/ deviation from the group mean.
Assuming y
ij
~ N(
i
, o
2
), then c
ij
~ N(0, o
2
)
If H
0
holds, y
ij
=
0
+ c
ij
, that is, all groups have the same
mean and variance.
Another way of saying that we expect the group
mean to be
i
.
ij i ij
y c + =
A Nave Testing Approach
Test each possible pair of groups by
performing all pair-wise t-tests.
3 2 0
3 1 0
2 1 0
: H
: H
: H
=
=
=
Assume each test is performed at the o=0.05 level.
For each test, the probability of not rejecting H
o
when H
o
is true is 0.95 (1-o).
The probability of not rejecting H
o
when Ho is true for all three tests is (0.95)
3

= 0.857.
Thus the true significance level for the overall test of no difference in the
means will be 1-0.857 = 0.143, NOT the o=0.05 level we thought it would be.
In each individual t-test, only part of the information available to
estimate the underlying variance is actually used. This is inefficient -
WE CAN DO MUCH BETTER!
x
y
-4-3-2-101234
x
y
-4-3-2-101234
x
y
-4-3-2-101234
Testing Approaches - Analysis of Variance
The term analysis of variance comes from the fact
that this approach compares the variability observed
among sample means to a pooled estimate of the
variability among observations within each group
(or treatment).
1
y
2
y
3
y
Among sample means variance (the between groups variance)
Pooled within
groups variance
Extreme Situations
Within group variance is large compared to variability between means.
Unclear separation of means.
x
y
-4-3-2-101234
x
y
-4-3-2-101234
x
y
-4-3-2-101234
Within group variance is small compared to variability between means.
Clear separation of means.
x
y
-4-3-2-101234
x
y
-4-3-2-101234
x
y
-4-3-2-101234
Pooled Variance
From two-sample t-test with assumed equal variance, o
2
, we produced a
pooled (within-group) sample variance estimate.
2 n n
s ) 1 n ( s ) 1 n (
s
n
1
n
1
s
y y
t
2 1
2
2 2
2
1 1
p
2 1
p
2 1
+
+
=
+

=
If all the n
i
are equal to n then this reduces to an average variance.

=
=
t
1 i
2
i
2
w
s
t
1
s
Extend the concept of a pooled variance to t groups as follows:
t n
SSW
) 1 n ( ) 1 n ( ) 1 n (
s ) 1 n ( s ) 1 n ( s ) 1 n (
s
T t 2 1
2
t t
2
2 2
2
1 1
2
w

=
+ + +
+ + +
=

=
=
t
1 i
i T
n n
Variance among Group Means
If we assume each group is of the same size, say n, then under H
0
, (all means
equal), s
2
is an estimate of o
2
/n (the variance of the sampling distribution of the
sample mean). Hence, n times s
2
is an estimate of o
2
. When the sample sizes
are unequal, the estimate is given by.
Consider the variance among the group
means computed as:
t
i
i 1
t
2
i
2
i 1
y
y
t
(y y )
s
t 1
=
--
--
=
=

1 1
) (
1
2
2

=
- - -
t
SSB
t
y y n
s
t
i
i i
B

= =
- -
=
-
=
=
t
1 i
n
1 j
ij
T
n
1 j
ij i
i
i
y
n
1
y
y y
where
F-test
Now we have two estimates of s
2
, one based on between means variability
and one based on pooled within group variability. Note that if the groups
truly have different means, s
b
2
will be greater than s
w
2
. Hence the F-
statistics is written as:
) t n ( ), 1 t (
2
W
2
B
T
F ~
s
s
F

=
If H
0
holds, the computed F-statistics should be close to 1.
If H
A
holds, the computed F-statistic should be much greater than 1.
We use the appropriate critical value from the F - table to
help make this decision.
Hence,the F-test is really a test of equality of means under the
assumption of normal populations and homogeneous variances.
Partition of Sums of Squares
Total
Sums of
Squares
Sums of
Squares
Between
Means
Sums of
Squares
Within
Groups
( ) ( )
( )
i i
2
n n
t t t
2
2
ij ij i i i
i 1 j 1 i 1 j 1 i 1
y y y y n y y
-- - --
= = = = =
= +

=
+
TSS
=
SSW
+
SSB
i i
n n 2
t t
2 2 2
ij T ij
i 1 j 1 i 1 j 1
T
2 2
t t
2
i
i i
i 1 i 1
i T
y
TSS (y y ) (n 1)s y
n
y y
SSB n (y y )
n n
SSW TSS SSB
--
--
= = = =
- --
- --
= =
= = =
= =
=

TSS measures
variability about
the overall mean
The AOV (Analysis of Variance) Table
The computations needed to perform the F-test for
equality of variances are organized into a table.
Partition of
the sums of
squares
Partition of
the degrees
of freedom
Variance
Estimates
Test
Statistic
Example-Excel
=average(b6:b10)
=var(b6:b10)
=sqrt(b13)
=count(b6:b10)
=(B15-1)*B13
=(sum(B15:D15)-1)*var(B6:D10)
=sum(b16:d16)
=b18-b19
Excel Analysis Tool
Pac
proc anova;
class popn;
model resp = popn ;
title 'Table 13.1 in Ott -
Analysis of Variance';
run;
Table 13.1 in Ott - Analysis of Variance 31

Analysis of Variance Procedure

Dependent Variable: RESP
Sum of Mean
Source DF Squares Square F Value Pr > F

Model 2 2.03333333 1.01666667 5545.45 0.0001

Error 12 0.00220000 0.00018333

Corrected Total 14 2.03553333

R-Square C.V. Root MSE RESP Mean

0.998919 0.247684 0.013540 5.466667


Source DF Anova SS Mean Square F Value Pr > F

POPN 2 2.03333333 1.01666667 5545.45 0.0001

Example SAS
proc glm;
class popn;
model resp =
popn / solution;
title 'Table
13.1 in Ott;
run;


General Linear Models Procedure

Dependent Variable: RESP
Sum of Mean
Source DF Squares Square F Value Pr > F

Model 2 2.03333333 1.01666667 5545.45 0.0001

Error 12 0.00220000 0.00018333

Corrected Total 14 2.03553333

R-Square C.V. Root MSE RESP Mean

0.998919 0.247684 0.013540 5.466667


Source DF Type I SS Mean Square F Value Pr > F

POPN 2 2.03333333 1.01666667 5545.45 0.0001

Source DF Type III SS Mean Square F Value Pr > F

POPN 2 2.03333333 1.01666667 5545.45 0.0001


T for H0: Pr > |T| Std Error of
Parameter Estimate Parameter=0 Estimate

INTERCEPT 5.000000000 B 825.72 0.0001 0.00605530
POPN 1 0.900000000 B 105.10 0.0001 0.00856349
2 0.500000000 B 58.39 0.0001 0.00856349
3 0.000000000 B . . .

NOTE: The X'X matrix has been found to be singular and a generalized inverse
was used to solve the normal equations. Estimates followed by the
letter 'B' are biased, and are not unique estimators of the parameters.
GLM in SAS
Minitab
Example
One-way Analysis of Variance

Analysis of Variance
Source DF SS MS F P
Factor 2 2.033333 1.016667 5545.45 0.000
Error 12 0.002200 0.000183
Total 14 2.035533
Individual 95% CIs For Mean
Based on Pooled StDev
Level N Mean StDev ----+---------+---------+---------+--
EG1 5 5.9000 0.0158 (*
EG2 5 5.5000 0.0071 *)
EG3 5 5.0000 0.0158 (*
----+---------+---------+---------+--
Pooled StDev = 0.0135 5.10 5.40 5.70 6.00
STAT > ANOVA > OneWay (Unstacked)

Anda mungkin juga menyukai