Chapter Three Mean Difference Analysis (T-Test, Analysis of Variance)

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 55

Chapter Three

Mean difference analysis


(T-test, Analysis of Variance)
t-test

The t-test is used to test hypotheses about means


when the population variance is unknown (the
usual case). Closely related to z, the unit normal.
Developed by Gossett for the quality control of
beer.
Comes in 3 varieties:
Single sample, independent samples, and
dependent samples.
What kind of t is it?
Single sample t – we have only 1 group; want to test
against a hypothetical mean.
Independent samples t – we have 2 means, 2 groups; no
relation between groups, e.g., people randomly
assigned to a single group.
Dependent t – we have two means. Either same people in
both groups, or people are related, e.g., husband-wife,
left hand-right hand, hospital patient and visitor.
Single-sample z test

For large samples (N>100) can use z to test


hypotheses about means.  2
(X  )
(x  x) 
zM  sX n 1
est. M est. M  
n n
Suppose
H 0 :   10; H1 :   10; s X  5; n  200

Then sX 5 5
est. M     .35
N 200 14.14
If (11  10)
X  11  z   2.83; 2.83  1.96  p  .05
.35
The t Distribution
We use t when the population variance is unknown (the
usual case) and sample size is small (N<100, the usual
case).
The t distribution is a short, fat relative of the normal.
The shape of t depends on its df. As N becomes infinitely
large, t becomes normal.
Single-sample t-test

With a small sample size, we compute the same numbers


as we did for z, but we compare them to the t distribution
instead of the z distribution.
H 0 :   10; H1 :   10; s X  5; n  25
sX 5 (11  10)
est. M   1 X  11  t  1
n 25 1

t (.05,24)  2.064 (c.f. z=1.96) 1<2.064, n.s.

X  tˆ M
Interval =
11  2.064(1)  [8.936, 13.064]
Interval is about 9 to 13 and contains 10, so n.s.
Independent Samples t (1)
 
( x1  x2 )  ( 1   2 )
Looks just like z: t diff  est diff

df=n1-1+n2-1=n1+n2-2
If SDs are equal, estimate is:
2 2 2 1 1
 diff       
n1 n2  n1 n2 
Pooled variance estimate is weighted average:
 2  [(n1  1) s12  (n2  1) s22 ] /[1 /(n1  n2  2)]
Pooled Standard Error of the Difference (computed):

(n1  1) s12  (n2  1) s22  n1  n2 


est. diff   
n1  n2  2 n n
 1 2 
Independent Samples

  H 0 : 1   2  0; H1 : 1   2  0
( x1  x2 )  ( 1   2 )
t diff  est diff

x1  18; s12  7; n1  5

x2  20; s22  5.83; n2  7

tcrit = t(.05,10)=2.23
Dependent t

Observations come in pairs. Brother, sister, repeated measure.


 diff
2
  M2 1   M2 2  2 cov( x1 , x2 )

Problem solved by finding diffs between pairs di=xi1-xi2.

d
 (d ) i
 i
( d  d ) 2
est. MD 
sd
n s 
2
d
n 1 n
d  D0
t D f =n(pairs)-1
sd / n
Analysis of Variance
ANOVA (Analysis Of Variance) is a statistical method
for determining the existence of differences among
several population means.
ANOVA is designed to detect differences among means
from populations subject to different treatments
ANOVA is a joint test
The equality of several population means is tested
simultaneously or jointly.
ANOVA tests for the equality of several population means
by looking at two estimators of the population variance
(hence, analysis of variance).
One-Way Analysis of Variance

We want to study the effects of all p treatments on a


response variable
 For each treatment, find the mean and standard deviation
of all possible values of the response variable when using
that treatment
 For treatment i, find treatment mean i
One-way analysis of variance estimates and compares
the effects of the different treatments on the
response variable
 By estimating and comparing the treatment means 1, 2,
…, p
 One-way analysis of variance, or one-way ANOVA
10-11
ANOVA Notation
ni denotes the size of the sample randomly selected
for treatment i
xij is the jth value of the response variable using
treatment i
i is average of the sample of ni values for treatment
i
 i is the point estimate of the treatment mean i
si is the standard deviation of the sample of ni values
for treatment i
 si is the point estimate for the treatment (population)
standard deviation i
10-12
One-Way ANOVA
Assumptions
Completely randomized experimental design
 Assume that a sample has been selected
randomly for each of the p treatments on the
response variable by using a completely
randomized experimental design
Constant variance
 The p populations of values of the response
variable (associated with the p treatments) all
have the same variance

10-13
One-Way ANOVA Assumptions
Continued

Normality
 The p populations of values of the response
variable all have normal distributions
Independence
 The samples of experimental units are randomly
selected, independent samples

10-14
Testing for Significant Differences
Between Treatment Means

Are there any statistically significant


differences between the sample (treatment)
means?
The null hypothesis is that the mean of all p
treatments are the same
 H0: 1 = 2 = … = p
The alternative is that some (or all, but at
least two) of the p treatments have
different effects on the mean response
 Ha: at least two of 1, 2 , …, p differ

10-15
Testing for Significant Differences
Between Treatment Means Continued

Compare the between-treatment variability


to the within-treatment variability
 Between-treatment variability is the variability
of the sample means, sample to sample
 Within-treatment variability is the variability
of the treatments (that is, the values) within
each sample

10-16
Partitioning the Total Variability in the
Response

Total  Between  Within


Variability Treatment Treatment
Variability Variability

Total Sum  Treatment Sum  Error Sum


of Squares of Squares of Squares

TSS = SST  SSE

   
p ni p p ni
  xij  x
2
  ni  xi  x  2
   xij  xi 2
i 1 j 1 i 1 i 1 j 1

10-17
Mean Squares

The treatment mean-squares is


SST
MST 
p 1

The error mean-squares is


SSE
MSE 
n p

10-18
F Test for Difference Between
Treatment Means # 1

Suppose that we want to compare p


treatment means
The null hypothesis is that all treatment
means are the same:
H0: 1 = 2 = … = p
The alternative hypothesis is that they are not
all the same:
Ha: at least two of 1, 2 , …, p differ

10-19
F Test for Difference Between
Treatment Means #2

Define the F statistic:


SST
F=
MST

 p  1
MSE SSE
 n  p
The p-value is the area under the F curve to
the right of F, where the F curve has p – 1
numerator and n – p denominator degrees
of freedom

10-20
F Test for Difference Between
Treatment Means #3

Reject H0 in favor of Ha at the  level of significance if


F > For if
p-value < 
Fis based on p – 1 numerator and n – p denominator
degrees of freedom

10-21
Example

22
Cont’d
SST = 5(56.8-58)2 +5(58-58)2+ 5(60.2-58) = 31.4
SSE = (40-56.8)2 + ….+(67-56.8)2+(67-58)2+……+
(56-58)2+(66-60.2)2+…..+(56-60.2)2 =3441.6
TSS = SST +SSE = 3473
MST=SST/p-1 = 31.4/3-1=15.7
MSE=SSE/n-p = 3441.6/15-3= 286.8
F= MST/MSE=15.7/286.8=0.055
Fα (2,12)= F.05 (2,12) =3.89. Since F =.055 < Fα = 3.89,
do not reject H0.(μA= μB= μC)

23
F Test for Block Effects
H0: No difference between block effects
Ha: At least two block effects differ
MSB SSB/  p  1
Test Statistic : F= 
MSE SSE/   p-1 b-1 

Reject H0 if
F > For
p-value < 
Fis based on b-1 numerator and (p-1)
(b-1) denominator degrees of freedom

10-24
Two-Way Analysis of
Variance
A two factor factorial design compares the mean response for a levels
of factor 1 (for example, display height) and each of b levels of factor 2
( for example, display width.) A treatment is a combination of a level of
factor 1 and a level of factor 2

Factor 2
1 2 3… b
1
2 xijk = response for the
Factor 1

. kth experimental unit (k=1,…,m)


. assigned to the
. ith level of Factor 1 and the
a jth level of Factor 2
10-25
Two-Way ANOVA Table

Degrees Sum of Mean F


Source of Freedom Squares Squares Statistic
Factor 1 a-1 SS(1) MS(1) = SS(1) F(1) = MS(1)
a-1
MSE
Factor 2 b-1 SS(2) MS(2) = SS(2) F(2) = MS(2)
b-1
MSE
Interaction (a-1)(b-1) SS(int) MS(int) = SS(int) F(int) =
MS(int)
(a-1)(b-1) MSE
Error ab(m-1) SSE MSE = SSE
ab(m-1)
Total abm-1 SSTO 10-26
Estimation of Treatment Differences
Under Two-Way ANOVA, Factor 1

Individual 100(1 - )% confidence interval for i - i’

 2  tis based on ab(m-1)


(x i  x i' )  t /2 MSE   degrees of freedom
 bm 

Tukey simultaneous 100(1 - )% confidence interval for i - i’


qis the upper  percentage point of the
 1  studentized range for a and ab(m-1)
(x i  x i' )  q MSE  
 bm 

10-27
Estimation of Treatment Differences
Under Two-Way ANOVA, Factor 2

Individual 100(1 - )% confidence interval for j - j’


 2  tis based on ab(m-1)
(x  j  x  j ' )  t /2 MSE  
 am  degrees of freedom

Tukey simultaneous 100(1 - )% confidence interval for j - j’

 1  qis the upper  percentage point


(x  j  x  j ' )  q  MSE  
 am  of the studentized range for b and
ab(m-1)

10-28
MANOVA
MANOVA can be thought of as ANOVA for
situations in which there are several dependent
variables.
The principles of ANOVA extend to
MANOVA in that we can use MANOVA when
there is only one independent variable or when
there are several, we can look at interactions
between independent variables, and we can
even do contrasts to see which groups differ
from each other.
10-29
Cont’d

ANOVA can be used only in situations in which


there is one dependent variable (or outcome) and
so is known as a univariate test (univariate quite
obviously means ‘one variable’);

MANOVA is designed to look at several


dependent variables (outcomes) simultaneously
and so is a multivariate test (multivariate means
‘many variables’).

10-30
10-31
Chi-Square: χ 2

32
Different Scales, Different Measures of
Association

Scale of Both Measures of


Variables Association
Nominal Scale Pearson Chi-Square:
χ2

Ordinal Scale Spearman’s rho

Interval or Ratio Pearson r


Scale 33
Chi-Square (χ2) and Frequency
Data
Up to this point, the inference to the population
has been concerned with “scores” on one or
more variables, such as CAT scores,
mathematics achievement, and hours spent on
the computer.
We used these scores to make the inferences
about population means. To be sure not all
research questions involve score data.

34
Cont’d

Today the data that we analyze consists of


frequencies; that is, the number of individuals
falling into categories. In other words, the
variables are measured on a nominal scale.
The test statistic for frequency data is Pearson
Chi-Square. The magnitude of Pearson Chi-
Square reflects the amount of discrepancy
between observed frequencies and expected
frequencies.

35
Steps in Test of Hypothesis

1. Determine the appropriate test


2. Establish the level of significance:α
3. Formulate the statistical hypothesis
4. Calculate the test statistic
5. Determine the degree of freedom
6. Compare computed test statistic against a
tabled/critical value

36
1. Determine Appropriate Test
Chi Square is used when both variables are measured
on a nominal scale.
It can be applied to interval or ratio data that have
been categorized into a small number of groups.
It assumes that the observations are randomly
sampled from the population.
All observations are independent (an individual can
appear only once in a table and there are no
overlapping categories).
It does not make any assumptions about the shape of
the distribution nor about the homogeneity of
variances.
37
2. Establish Level of Significance

α is a predetermined value
The convention
α = .05
α = .01
α = .001

38
3. Determine The Hypothesis:
Whether There is an Association or Not

Ho : The two variables are independent


Ha : The two variables are associated

39
4. Calculating Test Statistics

Contrasts observed frequencies in each cell of a


contingency table with expected frequencies.
The expected frequencies represent the number of
cases that would be found in each cell if the null
hypothesis were true ( i.e. the nominal variables
are unrelated).
Expected frequency of two unrelated events is
product of the row and column frequency
divided by number of cases.
Fe= Fr Fc / N
40
4. Calculating Test Statistics

 ( Fo  Fe )  2
  
2

 Fe 

41
4. Calculating Test Statistics

Ob
fre se
qu rve
en d
cie
s

 ( Fo  Fe )  2
  
2

 Fe 

Ex que
fre
pe ncy
ct e
d
qu e d
cy
fre pect
en
Ex

42
Example

Suppose a researcher is interested in voting


preferences on gun control issues.
A questionnaire was developed and sent to a
random sample of 90 voters.
The researcher also collects information about the
political party membership of the sample of
90 respondents.

43
Bivariate Frequency Table or
Contingency Table
Favor Neutral Oppose f row

Democrat 10 10 30 50

Republican 15 15 10 40

f column 25 25 40 n = 90

44
Bivariate Frequency Table or
Contingency Table
Favor Neutral Oppose f row

Democrat 10 10 30 50

Republican 15 15 10 40

f column ed 25 25 40 n = 90
r v ies
b se n c
O que
fre 45
Row frequency
Bivariate Frequency Table or
Contingency Table
Favor Neutral Oppose f row

Democrat 10 10 30 50

Republican 15 15 10 40

f column 25 25 40 n = 90

46
Bivariate Frequency Table or
Contingency Table
Favor Neutral Oppose f row

Democrat 10 10 30 50

Republican 15 15 10 40

f column 25 25 40 n = 90
Column frequency

47
1. Determine Appropriate Test

1. Party Membership ( 2 levels) and Nominal


2. Voting Preference ( 3 levels) and Nominal

Degree of freedom
(row-1) (column-1)

48
3. Determine The Hypothesis

• Ho : There is no difference between D & R in


their opinion on gun control issue.

• Ha : There is an association between responses


to the gun control survey and the party
membership in the population.

49
4. Calculating Test Statistics

Favor Neutral Oppose f row

Democrat fo =10 fo =10 fo =30 50


fe =13.9 fe =13.9 fe=22.2
Republican fo =15 fo =15 fo =10 40
fe =11.1 fe =11.1 fe =17.8
f column 25 25 40 n = 90

50
4. Calculating Test Statistics

Favor Neutral Oppose f row


= 50*25/90
Democrat fo =10 fo =10 fo =30 50
fe =13.9 fe =13.9 fe=22.2
Republican fo =15 fo =15 fo =10 40
fe =11.1 fe =11.1 fe =17.8
f column 25 25 40 n = 90

51
4. Calculating Test Statistics

Favor Neutral Oppose f row

Democrat fo =10 fo =10 fo =30 50


fe =13.9 fe =13.9 fe=22.2
= 40* 25/90
Republican fo =15 fo =15 fo =10 40
fe =11.1 fe =11.1 fe =17.8
f column 25 25 40 n = 90

52
4. Calculating Test Statistics

(10  13.89) 2 (10  13.89) 2 (30  22.2) 2


 
2
  
13.89 13.89 22.2

(15  11.11) 2 (15  11.11) 2 (10  17.8) 2


 
11.11 11.11 17.8

= 11.03

53
6. Compare computed test
statistic against a tabled/critical
value
α = 0.05
df = 2
Critical tabled value = 5.991
Test statistic, 11.03, exceeds critical value
Null hypothesis is rejected
Democrats & Republicans differ significantly in
their opinions on gun control issues

54
The end

Thank you!
55

You might also like