Professional Documents
Culture Documents
Comparing Means and Proportions Measures of Association
Comparing Means and Proportions Measures of Association
Measures of Association
11/7/2022 1
Contents
11/7/2022 2
Comparing means of 2 independent samples
11/7/2022 3
Comparing two independent groups
Equal variances
11/7/2022 4
Comparing two independent groups:
Equal variances
H 0 : 1 =2 or 1 - 2 0
HA :1 2 or 1 - 2 0
To carry out the test, begin by calculating the pooled
estimate of the variance
(n -1)s 2
(n -1)s 2
s 2p 1 1 2 2
n1 n2 -2
(9 -1)(5.9)2 (13-1)(6.3)2
37.74
9 13 - 2
11/7/2022 5
Comparing two independent groups
Equal variances
Next, calculate the test statistic
Degrees of freedom n1 + n2 – 2 = 20
11/7/2022 6
7
7
Comparing two independent groups:
Equal variances
11/7/2022 8
Comparing two independent groups:
Unequal variances
State the null and alternative hypothesis and perform the test.
11/7/2022 9
Comparing two independent groups:
Unequal variances
H0 : 1 = 2 or 1 - 2 0
HA : 1 2 or 1 - 2 0
Now, we calculate the test statistic
11/7/2022 10
Comparing two independent groups
Unequal variances
We don’t need to calculate the pooled variance, but need to
calculate the approximate degrees of freedom.
11/7/2022 11
How to Determine Equal or Unequal
Variance in t-tests
2) Perform an F-test.
11/7/2022 12
How to Determine Equal or Unequal
Variance in t-tests
11/7/2022 13
How to Determine Equal or Unequal
Variance in t-tests
2) Perform an F-test.
• An F-test is a formal statistical test that uses the following null and
alternative hypotheses:
H0: The samples have equal variances.
HA: The samples do not have equal variances.
• The test statistic is calculated as follows:
F = s12 / s22
where s12 and s22 are the sample variances.
• If the p-value that corresponds to the test statistic is less than a
significance level (like 0.05), then we have sufficient evidence to say
that the samples do not have equal variances.
11/7/2022 14
How to Determine Equal or Unequal
Variance in t-tests
11/7/2022 15
Comparing means
Two groups:
Paired t-test
Two sample t-test
More than two groups?
13
12
11
10
9
days
A B P
treatment
11/7/2022 17
Comparing means of > 2 groups
Multiple t-tests?
• Using t-tests, we would have to do 1 vs. 2, 1 vs. 3, and 2 vs. 3.
• Each time we do a t-test, the type I error rate is equal to
• As the number of comparisons increases, the probability of making at
least 1 Type-I error increases rapidly:
P(Making at least 1 error in n tests) = 1 - (1 – α)n
Where:
P(Making an error) = α, P(Not making an error) = 1 – α,
P(Not making an error in n tests) = (1 - α)n
• Note: A type I error is made if we reject the null hypothesis
11/7/2022 18
One way Analysis of Variance: ANOVA
Allows for the mean comparison of more than just two groups.
Example: that if you set α = 0.05 for each of the three sub-
analyses then the overall alpha value is 0.14
11/7/2022 19
One way Analysis of Variance: ANOVA
11/7/2022 20
Hypotheses of one-way ANOVA
H0: μ1 = μ2 = μ3 = = k
HA : Not al μi are the same
μ1 μ2 μ3
11/7/2022 21
Hypotheses of one-way ANOVA
H0: μ1 = μ2 = μ3 = = μk
HA: Not all μi are the same
At least one mean is different:
The Null Hypothesis is NOT true (Treatment effect is present)
or
μ1 μ2 μ3 μ1 μ2 μ3
11/7/2022 22
Assumptions of ANOVA
11/7/2022 23
Normality Check
11/7/2022 24
Standard Deviation Check
11/7/2022 25
Notation For ANOVA
Group i has
• ni = # of individuals in group i
• xij = value for individual j in group i
• 𝑥ҧ i = mean for group i
• si = standard deviation for group i
11/7/2022 26
How ANOVA works
ANOVA measures two sources of variation in the data and
compares their relative sizes.
Variation BETWEEN groups
◼ for each data value, look at the difference between its
group mean and the overall mean
xi - x 2
Variation WITHIN groups
◼ for each data value, look at the difference between
that value and the mean of its group
xij - xi2
11/7/2022 27
How ANOVA works
k = number of groups
11/7/2022 29
Variable treatment N Mean Median StDev
days A 8 7.250 7.000 1.669
B 8 8.875 9.000 1.458
P 9 10.111 10.000 1.764
Conclude:
• Not all of the population
7(1.669) 7(1.458) 8(1.764) 59.26
2 2 2
means are equal
• At least one population
mean is different
p 0.05 reject H0 • There is a treatment effect
31
CLT for the Proportion
11/7/2022 33
CLT for the Proportion
11/7/2022 34
Comparing two proportions
11/7/2022 35
Example
11/7/2022 36
Example
11/7/2022 37
The z-table: Pr(z ≤ zstatistic)
z 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09
-1 0.15865 0.15625 0.15386 0.1515 0.14917 0.14686 0.14457 0.14231 0.14007 0.13786
-0.9 0.18406 0.18141 0.17878 0.17618 0.17361 0.17105 0.16853 0.16602 0.16354 0.16109
-0.8 0.21185 0.20897 0.20611 0.20327 0.20045 0.19766 0.19489 0.19215 0.18943 0.18673
-0.7 0.24196 0.23885 0.23576 0.23269 0.22965 0.22663 0.22363 0.22065 0.21769 0.21476
-0.6 0.27425 0.27093 0.26763 0.26434 0.26108 0.25784 0.25462 0.25143 0.24825 0.24509
-0.5 0.30853 0.30502 0.30153 0.29805 0.2946 0.29116 0.28774 0.28434 0.28095 0.27759
-0.4 0.34457 0.3409 0.33724 0.33359 0.32997 0.32635 0.32276 0.31917 0.31561 0.31206
-0.3 0.38209 0.37828 0.37448 0.3707 0.36692 0.36317 0.35942 0.35569 0.35197 0.34826
-0.2 0.42074 0.41683 0.41293 0.40904 0.40516 0.40129 0.39743 0.39358 0.38974 0.3859
-0.1 0.46017 0.4562 0.45224 0.44828 0.44433 0.44038 0.43644 0.4325 0.42857 0.42465
0 0.5 0.49601 0.49202 0.48803 0.48404 0.48006 0.47607 0.47209 0.46811 0.46414
The z-table: Pr(z ≤ zstatistic)
z 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09
-1 0.15865 0.15625 0.15386 0.1515 0.14917 0.14686 0.14457 0.14231 0.14007 0.13786
-0.9 0.18406 0.18141 0.17878 0.17618 0.17361 0.17105 0.16853 0.16602 0.16354 0.16109
-0.8 0.21185 0.20897 0.20611 0.20327 0.20045 0.19766 0.19489 0.19215 0.18943 0.18673
-0.7 0.24196 0.23885 0.23576 0.23269 0.22965 0.22663 0.22363 0.22065 0.21769 0.21476
-0.6 0.27425 0.27093 0.26763 0.26434 0.26108 0.25784 0.25462 0.25143 0.24825 0.24509
-0.5 0.30853 0.30502 0.30153 0.29805 0.2946 0.29116 0.28774 0.28434 0.28095 0.27759
-0.4 0.34457 0.3409 0.33724 0.33359 0.32997 0.32635 0.32276 0.31917 0.31561 0.31206
-0.3 0.38209 0.37828 0.37448 0.3707 0.36692 0.36317 0.35942 0.35569 0.35197 0.34826
-0.2 0.42074 0.41683 0.41293 0.40904 0.40516 0.40129 0.39743 0.39358 0.38974 0.3859
-0.1 0.46017 0.4562 0.45224 0.44828 0.44433 0.44038 0.43644 0.4325 0.42857 0.42465
0 0.5 0.49601 0.49202 0.48803 0.48404 0.48006 0.47607 0.47209 0.46811 0.46414
Example
11/7/2022 41
Comparing proportions of ≥ 2 groups:
Chi-square test
We can ignore the two separate categories and treat all 413
children as a single sample.
In this sample:
11/7/2022 43
How Chi-square test works
11/7/2022 45
How Chi-square test works
11/7/2022 46
How Chi-square test works
Calculate
Df = (2-1)(2-1) = 1
Using chi-square distribution table, p-value is somewhere
between 0.25 and 0.5
p-value = 0.325 (p-value calculator) > 0.05
Do not reject H0
11/7/2022 47
48
Chi-square test limitation
11/7/2022 49
Measures of association
Odds ratio
11/7/2022 50
Risk difference
11/7/2022 51
Example
A randomized, double-blinded, placebo controlled trial of the efficacy
and safety of zidovudine (AZT) in reducing the risk of maternal-infant
HIV transmission. 363 HIV infected pregnant women were randomized
to AZT or placebo.
Results
Of the 180 women randomized to AZT group, 13 gave birth to
children who tested positive for HIV within 18 months of birth.
Of the 183 women randomized to the placebo group, 40 gave birth
to children who tested positive for HIV within 18 months of birth.
Note: A double-blind study is one in which neither the participants nor the
experimenters know who is receiving a particular treatment.
11/7/2022 52
HIV Drug group Total
Transmission AZT Placebo
Risk difference
Yes 13 40 53
No 167 143 310
Total 180 183 363
The risk of HIV transmission with AZT is about 1/3 the risk of HIV
transmission with placebo.
Interpretation: An HIV positive pregnant woman could reduce her
personal risk of giving birth to an HIV positive child by nearly 70% if
she takes AZT during her pregnancy.
11/7/2022 54
Relative risk (Risk ratio)
11/7/2022 55
Risk difference vs. Relative risk
11/7/2022 56
What is an Odds?
11/7/2022 57
What is an Odds?
11/7/2022 58
Odds Ratio
The estimated odds ratio of an HIV birth with AZT relative to placebo
The odds of HIV transmission with AZT is 0.28 (about 1/3) the odds of
transmission with placebo.
Interpretation: AZT is associated with an estimated 72% (estimated OR
= 0.28) reduction in odds of giving birth to an HIV infected child among
HIV infected pregnant women.
11/7/2022 59