Call Girl Coimbatore Prisha☎️ 8250192130 Independent Escort Service Coimbatore
t-test and one way ANOVA.ppt game.ppt
1. Principle of statistical inference
in two group population
University of Gondar
College of medicine and health science
Institute of public health
Department of Epidemiology and Biostatistics
Malede M. (BSc., MPH)
2. Planning analysis
• Areas of statistics that have most influenced medical
statistics in recent years
– Generalized linear models (including multiple linear
regression),
– Survival analysis,
– Categorical data analysis,
– Spatial statistics, and Bayesian methods (in diagnostic,
epidemiological and clinical trials contexts).
– Meta-analysis, as a tool for evidence-based medicine.
3. Over view of Basics
• Hypotheses
– H0 = Null-hypothesis
– H1 = experimental/
research hypothesis
• Descriptive vs. inferential
statistics
• (Gaussian)
distributions
• p-value & alpha-level
(probability and
significance)
Population
z-tests and distributions
Sample
(of a population)
t-tests and distributions
Research
Questions
4. Two sample mean and proportion
4
• Still now we have seen estimate for only single mean and
single proportion. However it is possible to compute point
and interval estimation for the difference of two sample
means.
• let x1, x2, …, xn1 are samples from the first population and
y1, y2, …, yn2 be sample from the second population.
• Sample mean for the first population be
• Sample mean for the second population
• Then the point estimate for the difference of means (µ1-µ2) is
given by )
( Y
X
Y
X
5. Two sample estimation
5
• A (1-α)100% confidence interval for the
difference of means is given If
are known
2
2
2
1
2
1
2
)
(
n
n
z
y
x
2
1,
and
6. Hypothesis testing for two sample means
6
• The steps to test the hypothesis for difference of means is the
same with the single mean
Step 1: state the hypothesis
Ho: µ1-µ2 =0
VS
HA: µ1-µ2 ≠0, HA: µ1-µ2 <0, HA: µ1-µ2 >0
Step 2: Significance level (α)
Step 3: Test statistic
2
2
2
1
2
1
2
1 )
(
)
(
n
n
y
x
zcal
7. Example
7
• A researchers wish to know if the data they have collected
provide sufficient evidence to indicate a difference in mean
serum uric acid levels between normal individual and
individual with down’s syndrome. The data consists of serum
uric acid readings on 12 individuals with down’s syndrome
and 15 normal individuals. The means are 4.5mg/100ml and
3.4 mg/100ml with standard deviation of 2.9 and 3.5
mg/100ml respectively.
0
:
0
:
2
1
2
1
A
O
H
H
9. Estimation and hypothesis testing for two population proportion
9
• Let n1 and n2 be the sample size from the two population. If
x and y are the out come of interest then the point estimate
for each population is given by p1=x/n1 and p2=y/n2
respectively.
• The point estimates π1-π2 =p1-p2
• The interval estimate for the difference of proportions is
given by
• If the sample size is large and n1p1>5, n1 (1-p1)>5, n2p2>5,
then
2
2
2
1
1
1
2
2
1
)
1
(
)
1
(
n
p
p
n
p
p
z
p
p
10. Hypothesis testing for two proportions
10
• To test the hypothesis
Ho: π1-π2 =0 VS HA: π1-π2 ≠0
The test statistic is given by
2
2
2
1
1
1
2
1
2
1
)
1
(
)
1
(
)
(
)
(
n
p
p
n
p
p
p
p
zcal
11. t-test
One sample t-test:
It is used to compare the estimate of a sample with a
hypothesized population mean to see if the sample is
significantly different.
Assumptions which should be fulfilled before we use this
method:
• The dependent variable is normally distributed within the
population
• The data are independent (scores of one participant are not
dependent on scores of the other)
12. T-test cont…
Hypothesis: Ho: μ = μo Vs HA: μ≠ μo ,
Where μo is the hypothesized mean value
The test statistics is : tcalc = (x
̄ – μ)/(s/√n)
We compare the calculated test statistics (tcalc) with the
tabulated value (ttab) at n-1 degree of freedom
13. No Distance in
miles
Drug use No Distance in
miles
Drug
use
1 14.5 no 10 18.4 yes
2 13.4 no 11 16.9 yes
3 14.8 yes 12 12.6 not
4 19.5 yes 13 13.4 not
5 14.5 no 14 16.3 yes
6 18.2 yes 15 17.1 yes
7 16.3 no 16 11.8 not
8 14.8 no 17 13.3 yes
9 20.3 yes 18 14.5 not
Mean 15.59
Standard deviation 2.43
T-test cont…
E.g. Data: The distance covered by marathon runners until a
physiological stress develops and whether they used drug or not
14. T-test cont..
It is believed that the mean distance covered before
feeling physiological stress is 15 miles
Hypotheses: Ho: = μ = 15 versus HA: μ ≠ 15
Level of significance: α = 5%
= 15.59, S = 2.43,
tcalc = (x – μ)/(s/√n) = 1.03, and P-value = 0.318
At 17 degree of freedom and α = 0.05, ttab = 2.110,
Since tcal = 1.03 < 2.110 = ttab, or α = 0.05 < 0.318 =p-value
we fail to reject Ho
x
̄
15. • Students sometimes have difficulty deciding whether to use
Za/2 or t a/2 values when finding confidence intervals
15
16. Two sample t- test
• A t-distribution can be used for testing hypotheses about
differences of means for independent samples if both
populations are normal and have the same variances.
• Assesses whether the means of two samples are statistically
different from each other. This analysis is appropriate
whenever you want to compare the means of two samples/
conditions
• Assumptions of a t-test:
– from a parametric population
– not (seriously) skewed
– no outliers
– independent samples
17. right hemisphere
Left hemisphere
lesion site
12
10
8
6
95%
CI
infer
comp
t-tests….
• Compare the mean between 2 samples/ conditions
• if 2 samples are taken from the same population, then they
should have fairly similar means
if 2 means are statistically different, then the samples are
likely to be drawn from 2 different populations, ie they really
are different
Exp. 1 Exp. 2
18. T-test cont..
b. Paired t- test
Each observation in one sample has one and only one mate
in the other sample dependent to each other.
For example, the independent variable can be measurements
like:
before and after (e.g before and after an intervention), or
repeated measurement (e.g. using digital and analog
apparatus), or when the two data sources are dependent
(e.g. data from mother and father of respondent)
Hypothesis: Ho: μd = 0 Vs HA: μd ≠ 0
19. T-test cont..
Subject BP before BP after Difference (di)
1 130 110 -20
2 125 130 +5
3 140 120 -20
4 150 130 -20
5 120 110 -10
6 130 130 0
7 120 115 -5
8 135 130 -5
9 140 130 -10
10 130 120 -10
d (Average of d) -9.5
Sd (Standard deviation of d) 8.64
Example : The blood pressure (BP) of 10 mothers were measured before
and after taking a new drug.
20. T-test cont..
Hypothesis: Ho: μd = 0 Versus HA: μd ≠ 0
Set the level of significance or α = 0.05
d = -9.5, Sd = 8.64, n = 10,.
tcalc = (d – μd)/(sd/√n) = 3.48 and p-value = 0.0075,
At n-1 = 9 df and α = 0.05, ttab = 2.26
Since ttab = 2.26 < 3.48 = tcalc or p-value = 0.0075 < 0.05 = α
We reject Ho
21. T-test cont..
c. Two independent samples t-test
Used to compare two unrelated or independent groups
Assumptions include:
The variance of the dependent variable in the two
populations are equal
The dependent variable is normally distributed within
each population
The data are independent (scores of one participant are
not related systematically to the scores of the others)
Hypothesis: Ho: μt = μc Vs HA: μt ≠ μc ,
Where μt and μc are the population mean of treatment and
control (placebo) groups respectively.
22. 22
The test statistics for two sample T-test cont….
• There are three cases which depend on what is known about
the population variances.
Case1:
• Population variances are known for normal populations (or
non normal populations with both and large). In this
case the test statistic is to be :
1
n
2
n
2
2
2
1
2
1
2
1
n
n
X
X
Z
2 2
1 2
and
23. 23
Case2:
• Populations are unknown but are to be equal
in normal populations. In this case, we pool our estimates to
get the pooled two- sample variance
• And the test statistic is to be
• Which has a distribution if is true.
2
2
2
2
1
2
2
1
2
2
)
1
2
(
2
1
)
1
1
(
2
n
n
S
n
S
n
p
S
)
2
1
1
1
(
2
2
1
n
n
p
S
X
X
T
2
1 2
t n n
0
H
24. 24
• Case 3:
• and are unknown and unequal normal
populations . In this case the test statistic is given by:
which does have a known distribution. If both n1and n2 are
large (both over 30) we can assume a normal distribution
1
2
2
2
2
2
2
1
2
1
2
1
n
S
n
S
X
X
T
25. Example
Do the marathon runners grouped by their drug intake status differ
in their average distance coverage before they feel any
physiological stress?
Hypothesis: Ho: μt = μc Vs HA: μt ≠ μc, where μt and μc are for drug
users and non-users respectively
Set the level of significance, α = 5%,
xc = 13.98, sc = 1.33, xt = 17.20, st= 2.21
tcalc = (xc – xt)/√S2(nc + nt) = -3.741, and its p-value = 0.002
S2 = is the pooled (combined) variance of both groups.
At 16 df and α = 0.05, ttab = -2.12
Since tcal= -3.741 < -2.12, or P-Value = 0.002 < 0.05 = α
We reject Ho
26. T-test cont…
Here in the case of two independent sample t-test, we
have one continuous dependent variable (interval/ratio
data) and;
one nominal or ordinal independent variable with only
two categories
In this last case (i.e. two independent
sample t-test), what if there are
more than two categories for the
independent variable we have?
27. Inferences for Two or More Means
Are the birth weights of children in different geographical
regions the same?
Are the responses of patients to different medications and
placebo different?
Are people with different age groups have different
proportion of body fat?
Do people from different ethnicity have the same BMI?
28. One way-Analysis Of Variance
cont…
All the above research questions have one common
characteristic: That is each of them has two variables: one
categorical and one quantitative
Main question: Are the averages of the quantitative variable
across the groups (categories) the same?
Because there is only one categorical independent variable
which has two or more categories (groups), the name one
way ANOVA comes.
29. 29
One-way ANOVA cont…
Also called Completely Randomized Design
Experimental units (subjects) are assigned randomly
to treatments/groups. Here subjects are assumed to
be homogeneous
30. 30
One way ANOVA is a method for testing the hypothesis:
More formally, we can state hypotheses as:
H0: There is no difference among the mean of treatments effects
HA: There is difference at least between two treatments effects
or
Ho: µ1 = µ2 = µ3 =…. = µa (if there are ‘a’ groups)
HA: at least one group mean is different
There is no difference between two or more population
means (usually at least three); or there is no difference
between a number of treatments
Analysis of variance cont…
31. Why Not Just Use t-tests?
Since t-test considers two groups at a time, it will be tedious when
many groups are present
Conducting multiple t-tests can lead also to severe inflation of the
Type I error rate (false positives) and is not recommended
However, ANOVA is used to test for differences among several
means without increasing the Type I error rate
The ANOVA uses data from all groups at a time to estimate
standard errors, which can increase the power of the analysis
32. Assumptions of One Way ANOVA)
The data are normally distributed or the samples have come
from normally distributed populations and are independent.
The variance is the same in each group to be compared (equal
variance).
Moderate departures from normality may be safely ignored,
but the effect of unequal standard deviations may be serious.
In the latter case, transforming the data may be useful.
33. We test the equality of means among groups by using the
variance
The difference between variation within groups and
variation between groups may help us to compare the
means
If both are equal, it is likely that the observed difference
is due to chance and not real difference
Note that:
Total Variability = Variability between + Variability
within
Analysis of variance cont…
34. μ
G-1 G-2
Basic model: Data are deviations from
the global mean, μ:(The Linear Model)
Xij = μ + Ɛij
Sum of vertical deviations squared is
the total sum of squares = SSt
G-1 G-2
One way model: Data are deviations
from treatment means, Ais:
Xij = μ + Ai + Ɛij
Sum of vertical deviations squared = SSe
Note that ΣAi = ΣƐij = 0
A1
A2
Analysis of variance
35. 35
Decomposing the total variability
n a n a n a
Total SS = Σ Σ (xij – )2 = ΣiΣjxij
2 - (ΣiΣjxij)2 /na = SST
i=1 j=1
n a n a a n
Within SS = Σ Σ (xij – j)2 = ΣiΣjxij
2 - Σj(Σixij)2/n = SSW
i=1 j=1
n a a n
Between SS = Σ Σ ( i j – )2 = Σj(Σixij)2/n - (ΣiΣjxij)2 /na = SSB
i=1 j=1
This is assuming each of the ‘a’ groups has equal size, ‘n’.
SST = SSW + SSB
36. Data of one way ANOVA
Groups/variable
G-1 G-2 G-3 ….. G-a
X11 X12 X13 ….. X1a
X21 X22 X23 ….. X2a
X31 X32 X33 ….. X3a
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Xn1 Xn2 Xn3 …. Xna
Totals T.1 T.2 T.3 …. T.a
T= ΣiΣjxij
2 Correction Factor = CF = (ΣiΣjxij)2 /na = T2../na
A = Σj(Σixij)2/n = Σj(T.j)2/n if the groups’ (cells’) size are equal, or
A = Σj(Σixij)2/nj = Σj(T.j)2/nj ; if unequal group size
Where, Xij = ith observation in the jth group of the table
i = 1, 2, 3,…, nj, j = 1, 2, 3,…,a, Σjnj = N
Participants
Computational formula
37. Sum of squares and ANOVA Table
If there are real differences among groups’ means, the between
groups variation will be larger than the within variation
Source of
variation
df SS MS F
Between groups a-1 SSB = A - CF SSB/(a-1) MSB/MSW
Within groups na-a SSW = T - A SSW/(na –a)
Total na-1 SST = T - CF
38. Example on one-way ANOVA
The following table shows the red cell folate levels (μg/l) in three groups of
cardiac bypass patients who were given three different levels of nitrous oxide
ventilation. (Level of nitrous oxide for group I > group II’s > group III’s)
Group I
(n=8)
Group II
(n=9)
Group III
(n=5)
243
251
275
291
347
354
380
392
Total=2533
Mean =316.6
SD = 58.7
206
210
226
249
255
273
285
295
309
2308
256.4
37.1
241
258
270
293
328
1390
278.0
33.8
40. Example cont…
Ho: μ1 = μ2 = μ3
HA: Differences exist between at least two of the means
Since the P-value is less than 0.05, the null hypothesis is rejected
Source of variation df SS Mean
square
F P
Between groups
Within groups
2
19
15516
39716
7758
2090
3.71 0.044
Total 21 55232
41. Pair-wise comparisons of group means
post hoc tests or multiple comparisons
ANOVA test tells us only whether there is statistically significant
difference among groups means, but
It doesn’t tell us which particular groups are significantly
different
To identify them, we use either a priori (pre-planed) or post hoc
tests
42. Pair-wise comparisons of group means
(post hoc tests) cont…
Whether to use a priori or post hoc tests depends on whether the
researcher has previously stated the hypotheses to test.
If you have honestly stated beforehand the comparisons between
individual pairs of means which you intend to make, then you are
entitled to use a priori test such as a t-test.
In this case, only one pair of groups or few will be tested
However, when you look at the data it may seem worth
comparing all possible pairs. In this case, a post hoc test such as
Scheffe, Benferroni (modified t-test), Tuckey methods, Least
Squares Difference (LSD), etc will be employed.
43. Benferroni method or Modified t-test (Steps)
I. Find tcalc for the pairs of groups of interest (to be compared)
II. The modified t-test is based on the pooled estimate of
variance from all the groups (which is the residual variance
in the ANOVA table), not just from pair being considered.
III. If we perform k paired comparisons, then we should
multiply the P value obtained from each test by k; that is, we
calculate P' = kP with the restriction that P' cannot exceed 1.
Where, , that is the number of possible comparisons
44. Benferroni method or Modified t-test
Returning to the red cell folate data given above, the residual
standard deviation is = 45.72.
(a) Comparing groups I and II
t = (316.6 - 256.4) / (45.72 x √(1/9 +1/8)
= 2.71 on 19 degrees of freedom.
The corresponding P-value = 0.014 and the
corrected P value is P' = 0.014x3
= 0.042
Group I and II are different
45. Benferroni method or Modified t-test
(b) Comparing groups I and III
t = (316.6 - 278.0) / (45.72 x √(1/8+1/5)
= 38.6/26.06
= 1.48 on 19 degrees of freedom.
The corresponding P value = 0.1625 and
The corrected P value is P' = 0.1625x3
= 0.4875
Group I and III are not different
46. Benferroni method or Modified t-test
(c) Comparing Groups II and III
t = (278 - 256.4) / (45.72 x √(1/5+1/9)
= 21.6/25.5
= 0.85 on 19 degrees of freedom.
The corresponding P value = 0.425 and the corrected P value
is P' = 1.00
Group I and III are not different
Therefore, the main explanation for the difference between
the groups that was identified in the ANOVA is thus the
difference between groups I and II.
47. Which post hoc method Shall I use?
The post hoc tests differ from one another in how they calculate
the p value for the mean difference between groups.
Least Squares Difference (LSD) is the most liberal of the post hoc
tests and has a high Type I error rate. It is simply multiple t-tests
The Scheffé test uses the F distribution rather than the t
distribution of the LSD tests and is considered more conservative.
It has a high Type II error rate but is
considered appropriate when there are a
large number of groups to be compared.
48. Which post hoc method Shall I use? cont…
The Bonferroni approach uses a series of t tests ( that is
the LSD technique) but corrects the significance level
for multiple testing by dividing the significance levels by
the number of tests being performed
Since this test corrects for the number of comparisons
being performed, it is generally used when the number
of groups to be compared is small.
49. Which post hoc method Shall I use? Cont..
Tukey’s Honesty Significance Difference (Tukey’s HSD)
test also corrects for multiple comparisons, but it considers
the power of the study to detect differences between groups
rather than just the number of tests being carried out;
That is, it takes into account sample size as well as the
number of tests being performed.
This makes it preferable when there are a large number of
groups being compared, since it reduces the chances of a
Type I error occurring.
50. ANOVA - a recapitulation.
ANOVA is a parametric test, examining whether the
means differ between 2 or more populations.
It generates a test statistic F, which can be thought of
as a signal: noise ratio. Thus large values of F
indicate a high degree of pattern within the data and
imply rejection of Ho.
It is thus similar to the t test - in fact ANOVA on 2
groups is equivalent to a t test [F = t2 ]
51. One way ANOVA’s limitations
This technique is only applicable when there is one
treatment used.
Note that this single treatment can have 3, 4,… ,many
levels.
Thus nutrition trial on children weight gain with 4
different feeding styles could be analyzed this way,
but a trial of BOTH nutrition and mothers health
status could not