STAT603 Chapter 4 - Basic Statistical Inference
STAT603 Chapter 4 - Basic Statistical Inference
Descriptive Inferential
stats stats
The collection, • Involves using samples
organisation, to draw conclusions
summarization and about a population.
presentation of data
• Express the results in
language of probability
3
e.g. All the Population – all items
customers that with a characteristic Problems
shop at Pick n of interest (size 𝑁𝑁) • Expensive
Pay • Not practical
• Time consuming
Inferential
Generalize the statistics Census – a
findings from the study of all
sample to the e.g. 100 customers
items in the that shop at Pick n
population pop.
Pay
4
Parameter vs Statistic
A measure of A measure of
description from a description from a
Population Sample
or 𝛽𝛽̂
6
Drawing conclusions about a
Statistical Inference population parameter by using
a statistic calculated from the
sample.
8
Suppose, from a population of values, we draw a whole lot of samples of size
𝑛𝑛, and calculate a statistic for each of the obtained samples.
9
Sample: 1: {2, 2} 𝑥𝑥1̅ =2
2: {2, 4} 𝑥𝑥̅2 =3
Population values: 3: {2, 6} 𝑥𝑥̅3 =4
S = {2, 4, 6, 8} 4: {2, 8} 𝑥𝑥̅4 =5
5: {4, 2} 𝑥𝑥̅5 =3
6: {4, 4} 𝑥𝑥̅6 = 4
These are all the 7: {4, 6} 𝑥𝑥̅7 = 5 The mean of the
possible samples 8: {4, 8} 𝑥𝑥̅8 = 6 samples of size 2 has
of size 2 from the 9: {6, 2} 𝑥𝑥̅9 = 4 different values.
population of 10: {6, 4} 𝑥𝑥10
̅ =5
values above. 11: {6, 6} 𝑥𝑥11
̅ =6
12: {6, 8} 𝑥𝑥12 ̅ =7
This is the definition
13: {8, 2} 𝑥𝑥13̅ =5
of a random
14: {8, 4} 𝑥𝑥14 ̅ =6
15: {8, 6}
variable.
𝑥𝑥15 ̅ =7
16: {8, 8} 𝑥𝑥16 ̅ =8 10
For this example, our statistic of interest was the mean where:
11
Consider the previous example again:
�
Let’s denote this sample statistic of interest (the mean) by 𝑋𝑋.
(A capital letter to denote it is a random variable, with a bar above it to denote a
mean.)
The sampling distribution of 𝑋𝑋� for this example will be: 16 = total no. of
possible
2 3 4 5 6 7 8 Sum
samples/outcomes
Count 1 2 3 4 3 2 1 16
1� 2� 3� 4� 3� 2� 1� 1
16 16 16 16 16 16 16
The mean and variance of this random variable 𝑋𝑋� (the sample mean)is:
5 Found using the calculator or Excel (put all 16
� =5
E(𝑋𝑋) and � =
Var(𝑋𝑋) values of 𝑋𝑋� from the previous slide into Excel to
2
find the mean and variance)
12
Recall: the population of values were 2, 4, 6 and 8. Let’s represent these
population values by the random variable 𝑋𝑋.
∴ 𝑋𝑋 = {2, 4, 6, 8}
Now let’s compare the mean and variance of each random variable, 𝑋𝑋
and 𝑋𝑋� (based on a sample of size 𝑛𝑛 = 2)
� = 5 = E(𝑋𝑋) = 𝜇𝜇
E(𝑋𝑋) 5
� = =
Var( 𝑋𝑋) 𝜎𝜎 2
Var(𝑋𝑋)
2
=
𝑛𝑛 𝑛𝑛
13
In general, for a sample of size 𝑛𝑛 drawn from a population of values (X) that
has a population mean of 𝜇𝜇 and a population variance of 𝜎𝜎 2 , the mean
� will be as
and variance of the sampling distribution of the sample mean (𝑋𝑋),
follows:
� = 𝜇𝜇𝑋𝑋� = 𝜇𝜇
E(𝑋𝑋) (The population mean)
𝜎𝜎 2
� = 𝜎𝜎𝑋𝑋2� =
Var(𝑋𝑋) (The population variance divided by the sample
𝑛𝑛 size 𝑛𝑛)
σ
𝜎𝜎𝑋𝑋� = � known as the
(This is the standard deviation of 𝑋𝑋,
𝑛𝑛
standard error)
14
The Central Limit Theorem
15
The Central Limit Theorem (CLT):
Let 𝑋𝑋1 , 𝑋𝑋2 , … , 𝑋𝑋𝑛𝑛 be a random sample of size n drawn from a population (with
any distribution) with a population mean 𝜇𝜇 and variance 𝜎𝜎 2 .
∑𝑛𝑛𝑖𝑖=1 𝑥𝑥𝑖𝑖
Then for a sufficiently large n, the mean of the sample 𝑋𝑋� = will be
𝑛𝑛
2 𝜎𝜎 2
approximately normally distributed with a mean 𝜇𝜇𝑋𝑋� = 𝜇𝜇 and a variance 𝜎𝜎𝑋𝑋� = .
𝑛𝑛
𝜎𝜎 2
�
i.e. 𝑋𝑋~𝑁𝑁 𝜇𝜇,
𝑛𝑛
Now that we know the specific distribution of this random variable, we can
use it to calculate probabilities. Specifically, since it follows a normal
distribution, we can standardize it in order to use the standard normal table.
16
Key points on the CLT:
� will be approximately normally distributed if the
• Normality: The sample means (𝑋𝑋)
sample size is large enough, even if the population distribution is not normal.
• Sample size: Generally, a sample size of 30 or more is considered sufficient for the
CLT to hold.
• Statistical inference: The basis of many statistical inference methods (hypothesis
tests, confidence intervals, statistical models) is formed from the normal distribution.
Hence, such methods require normality.
• When the assumption of normality is not met, traditional parametric statistical
methods will not be accurate. However, there are other methods that can be
considered in this case, such as non-parametric methods.
• Many machine learning methods also do not require the assumption of normality
to be met.
17
STAT603:
Chapter 4
Basic Statistical
Inference
Section 4.3:
Confidence Intervals
4.3 Confidence Intervals
Some terminology:
• A point estimate of a parameter is a single value (point) that estimates a
parameter.
Example:
Suppose the mean time it takes to serve customers at a supermarket
checkout counter is to be estimated.
19
1) The mean service time of 100 customers of (say) 𝑥𝑥̅ = 2.283 minutes is an
example of a point estimate of the parameter µ.
2) If it is stated that we are 95% confident that the mean service time will be
from 1.637 minutes to 4.009 minutes, the interval of values (1.637, 4.009) is
an interval estimate of the parameter μ.
Since, from section 4.2, we have seen that a point estimate (a statistic) can
differ each time depending on the sample obtained, it is more appropriate
(and useful) to obtain an interval estimate for a parameter rather than just
one single value.
23
So what do confidence intervals tell us?
• Not a Probability Statement: It's important to note that the 95% confidence
level does not mean there is a 95% chance that the true value of the
population parameter is within the interval for this particular sample. The
true value is either in the interval or it is not. The confidence level reflects
the long-term reliability of the method used to construct the interval.
25
4. Robustness to Sample Size:
Confidence intervals naturally adjust for sample size. Larger samples lead to
narrower intervals (more precise estimates), while smaller samples result in wider
intervals, reflecting greater uncertainty.
5. Guiding Decision-Making:
Confidence intervals provide valuable information for decision-makers, helping
them assess the range within which the true effect or parameter might lie, and
thereby make more informed choices based on the degree of uncertainty.
6. Alternative to Hypothesis Testing:
While traditional hypothesis tests give a binary decision (reject or fail to reject a
null hypothesis – more about this next), confidence intervals offer more
nuanced information. They not only tell us whether an effect is significant but
also provide insight into the magnitude and direction of the effect.
26
Which confidence interval is better?
Out of the two 95% confidence intervals below for the average time taken for
a customer to be served at a supermarket, which would you think is more
informative?
(1.283 ; 3.283) vs (0.421 ; 8.765)
27
Example
Suppose the 95% confidence interval for the average height of a man is
given by:
95% CI: [1.76m, 1.87m]
28
What affects the width of a confidence interval?
𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸 ± 𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸
The width of the CI is affected by the error. The smaller the error, the better!
The error is made up of
• The critical value, which is dependent on the confidence level (90%, 95%, 99%) –
we can’t decrease this too much as we then will be less confident in the CI. So this
cannot change by much to obtain a narrower CI.
• The standard error which is made up of
o the standard deviation of the population. This is a fixed constant – cannot
change it.
o 𝑛𝑛, the sample size – we can change this (as much as resources allow).
As 𝑛𝑛 increases, the standard error decreases which in turn decreases the error and the
CI becomes narrower (this is why we prefer to obtain as large a sample as possible).
29
Example
Consider the two confidence intervals below for the average height of a
man, which have each been calculated using the same level of
confidence (95%):
30
Example
Suppose a 95% confidence interval for the difference in the average height
of a man and woman is given by:
31
Example
Suppose a 95% confidence interval for the difference in the average IQ of a
man and woman is given by:
32
Other use-cases of confidence intervals
33
STAT603:
Chapter 4
Basic Statistical
Inference
Section 4.4:
One-sample
Hypothesis Tests
4.4 One-sample Hypothesis Tests
Introduction and Terminology
• We now know what a confidence interval is and how it can aid us in
answering research questions.
• However, no information/knowledge is known about the possible value of
the parameter before the confidence interval is constructed.
Now we look at methods for carrying out hypothesis tests concerning claims
made about the possible value (or values) of the population parameter.
• Therefore, in these sections, some knowledge about the specific value (or
range of values) of the parameter is known/assumed.
35
• Hypothesis testing is a fundamental concept in statistics that allows us to
make decisions or inferences about a population based on sample data.
• It is widely used in research, business, medicine, and many other fields to
test assumptions or claims about population parameters (such as means,
proportions, or variances).
Statistical Hypothesis:
• A statistical hypothesis is an assertion (claim) made about the value(s) of a
population parameter.
36
Purpose of a Statistical Hypothesis:
• The purpose of testing of hypotheses is to determine whether a claim that is
made could be true.
• The conclusion about the truth of such a claim is not stated with absolute
certainty, but rather in terms of the language of probability.
Alternative hypothesis:
A statement concerning the possible range of values of the population
parameter 𝜃𝜃 that is believed to be true if 𝐻𝐻0 is not true.
For this example, the alternative hypothesis 𝐻𝐻1 represents the claim that is
being made (the mean is less than 1).
However, the null hypothesis still specifies that the mean is exactly equal to 1.
39
2) An electrical firm manufacturing light bulbs claims that the average lifetime
(in hours) of their light bulbs is more than 780 hours.
For this example, the alternative hypothesis 𝐻𝐻1 once again represents the
claim that is being made.
40
3) A construction company believes that the average compressive strength
of its concrete is at the required level of 4000psi.
42
Two-sided Alternative:
This is a hypothesis that specifies the alternative values (to the null hypothesis)
in directions that can be either less than or more than that specified by the
null hypothesis. (No specific direction is given)
43
Due to the results of a hypothesis test being based on a sample (which may
not be representative of the population, i.e. it may be bias) there is always
some probability associated with making an error/incorrect decision.
Types of Errors:
Type I Error
A type I error is made when the null hypothesis is rejected when in reality it is
actually true.
Type II Error
A type II error is made when the null hypothesis NOT is rejected when in reality
it is actually false.
44
H0: Not pregnant
45
Table summarizing the errors:
Conclusion of hypothesis test
True situation\
𝑯𝑯𝟎𝟎 not rejected 𝑯𝑯𝟎𝟎 rejected
Conclusion
47
Procedure of Hypothesis Testing
• Hypothesis tests are carried out by using a set level of significance (𝛼𝛼) and
by assuming the null hypothesis is true.
• We then need to use the collected sample to try and prove it is impossible
for 𝐻𝐻0 to be true (in other words, we need to see if we have enough
evidence to prove that 𝐻𝐻0 is false).
• Thus, the conclusions for the hypothesis test are expressed as follows:
• When 𝐻𝐻0 is rejected: We have sufficient evidence to conclude 𝐻𝐻1 (the
alternative hypothesis).
• When 𝐻𝐻0 is not rejected: We do NOT have sufficient evidence to
conclude 𝐻𝐻1 , however, we do NOT accept 𝐻𝐻0 .
The absence of evidence is not evidence of absence
48
Critical value approach:
• A test statistic is calculated from the sample data and represents how far
the observed data from the sample diverges from the null hypothesis (𝐻𝐻0 ).
• A large test statistic means the sample data is far from what is expected
under 𝐻𝐻0 , making it more likely to reject 𝐻𝐻0 .
• A small test statistic means the data is close to what is expected under 𝐻𝐻0 ,
making it less likely to reject 𝐻𝐻0 .
• But how do we know when the test statistic is large or small?
It is compared to a critical value
• A critical value is a threshold derived from the theoretical distribution
(standard normal distribution, t-distribution, Chi-square etc.) of the test
statistic under the assumption that the null hypothesis is true.
49
Critical value approach…
• The critical value corresponds to the chosen significance level (𝛼𝛼 – usually
1%, 5% or 10%) and marks the boundary of the rejection region.
• If the test statistic lies in the rejection region, the null hypothesis is rejected,
suggesting that the alternative hypothesis (𝐻𝐻1 ) is more plausible.
• Conversely, if the test statistic lies outside of this rejection region (as defined
by the critical value), we fail to reject 𝐻𝐻0 , indicating insufficient evidence
against it.
• If the test statistic falls far enough away from the expected value under 𝐻𝐻0
(i.e., it exceeds the critical value), it indicates that the observed data is
unlikely to have occurred by random chance under the null hypothesis.
50
Types of hypothesis tests for population means
One-sample tests: 𝐻𝐻0 : 𝜇𝜇 = 𝜇𝜇0
• Purpose: Tests whether the mean of a single sample differs from a known or
hypothesized population mean.
• Example: Testing if the average height of a group of students is different from
the national average height.
Two-sample tests (Independent samples): 𝐻𝐻0 : 𝜇𝜇1 = 𝜇𝜇2 𝐻𝐻0 : 𝜇𝜇1 − 𝜇𝜇2 = 0
• Purpose: Compares the means of two independent groups to see if they are
significantly different from each other. (more on this in section 4.5)
• Example: A retail company wants to compare the average sales between
two of its store locations to determine if one store is outperforming the other.
51
Paired t-Test: 𝐻𝐻0 : 𝜇𝜇𝑑𝑑 = 0
• Purpose: Compares the means of two related groups (e.g., before-and-after
measurements) to see if there is a significant change.
• Example: Testing the effect of a training program by comparing the test
scores of participants before and after the program.
52
P-value approach:
• This method involves comparing a p-value to the specified level of
significance (𝛼𝛼).
• A p-value is the probability, when assuming the null hypothesis is true, of
obtaining by chance a result as or more extreme than that observed in the
sample.
For example, if we want to test:
𝐻𝐻0 : 𝜇𝜇 = 15
𝐻𝐻1 : 𝜇𝜇 < 15
53
𝐻𝐻0 : 𝜇𝜇 = 15 𝑣𝑣𝑣𝑣 𝐻𝐻1 : 𝜇𝜇 < 15
Suppose we have obtained a sample such that the sample mean is 𝑥𝑥̅ = 8. We
know there are two possibilities:
54
• For small P-values, we can conclude there is a small chance of outcome 1
occurring if the null hypothesis is true (i.e. a small chance of getting such a
sample if the null hypothesis is true, and therefore is cannot possibly be true),
and thus we can reject the null hypothesis.
55
• The calculation of the P-value depends on the distribution of the test
statistic as well as the alternative hypothesis.
• More specifically, it depends on whether the alternative is a one-sided or
two-sided alternative.
• The P-value for a two-sided alternative is always double that of a one-sided
test.
56
One-sample tests for population means
Z-Test for One Sample Mean:
When
• The population standard deviation (𝜎𝜎) is known.
• The sample size is large (𝑛𝑛 ≥ 30) OR the population is normally distributed.
The test statistic follows a standard normal (Z) distribution. Therefore, the critical
value(s) and p-values are based on this distribution. This is known as a Z-test.
58
3. Significance Level ( 𝛼𝛼 ): The threshold for rejecting the null hypothesis.
Lowering 𝛼𝛼 (making the test more stringent in declaring significance)
reduces power, whereas increasing 𝛼𝛼 (accepting more risk of a Type I error)
increases power.
4. Variability in the Data: Less variability (noise) in the data increases the
power, as it makes true effects more discernible against the background of
random fluctuations.
Optimally, researchers aim for high power (typically 0.8 or 80%) to be confident
in their ability to detect meaningful effects, recognizing that increasing power
often involves trade-offs, such as needing larger sample sizes or accepting a
higher risk of Type I errors.
59
• It's important to note that while large sample sizes can make it easier to find
statistically significant results, this does not necessarily mean those results
are practically significant or meaningful.
• Very small differences may not be of practical importance, even if they are
statistically significant.
• This highlights the importance of considering both statistical significance (p-
value) and effect size (the magnitude of the difference or relationship)
when interpreting research findings.
60
Significance of Test
• Recall: Statistical significance is a mathematical concept that measures the
probability that an observed difference or relationship between variables in
a study is due to chance.
• It's usually assessed using a p-value or other statistical tests. A result is typically
considered statistically significant if the p-value is below a predetermined
threshold, commonly 0.05. This means there is less than a 5% probability that
the observed results occurred by chance, assuming the null hypothesis (no
effect or no difference) is true.
• When a result is significant statistically, practical or biological significance
should also be considered.
61
• Biological significance refers to the practical importance or relevance of the
findings in a real-world biological context.
• It considers whether the magnitude of the effect observed in a study is large
enough to have a noticeable impact on organisms, populations, or
ecosystems.
• In clinical research, the term "clinical significance" is used to denote whether
the difference or effect observed has a meaningful impact on patient
health, treatment outcomes, or medical practice.
• While statistical significance helps to understand the reliability of the findings
from a mathematical perspective, biological significance addresses the
practical importance of these findings in the real world. Both are crucial for
interpreting research results and making informed decisions based on
scientific evidence.
62
STAT603:
Chapter 4
Basic Statistical
Inference
Section 4.5:
Two-sample
Hypothesis Tests
• Discussed hypothesis tests concerning the
Section 4.4: parameter 𝜇𝜇 (population mean) of a single
population.
• These hypothesis tests were based on one
random sample drawn from a single population
of interest.
For example: Are the mean salaries the same for males and females with the
same educational qualifications and work experience?
64
4.5 Two-sample Hypothesis Tests
Theses hypotheses
Null Hypothesis: can be represented
𝐻𝐻0 : 𝜇𝜇1 = 𝜇𝜇2 𝐻𝐻0 : 𝜇𝜇1 − 𝜇𝜇2 = 0 in the general form
of 𝐻𝐻0 : 𝜃𝜃 = 𝜃𝜃0 …
Alternative Hypotheses:
𝐻𝐻1𝑎𝑎 : 𝜇𝜇1 < 𝜇𝜇2 𝐻𝐻1𝑎𝑎 : 𝜇𝜇1 − 𝜇𝜇2 < 0 (left-tailed)
parameter specified
𝜃𝜃 = 𝜇𝜇1 − 𝜇𝜇2 value 𝜃𝜃0 = 0
65
There are a four cases when testing 𝑯𝑯𝟎𝟎 : 𝝁𝝁𝟏𝟏 − 𝝁𝝁𝟐𝟐 = 𝟎𝟎:
𝑍𝑍-test Case A
𝑛𝑛1 AND 𝑛𝑛2 ≥ 30 𝑛𝑛1 and/or 𝑛𝑛2 < 30
The cases on the previous slide assume that 𝜇𝜇1 and 𝜇𝜇2 are independent.
The last case that will be considered (Case D) is when 𝜇𝜇1 and 𝜇𝜇2 are NOT
independent.
Examples
A group of patients going on a diet is weighed before going on the diet and
again after having been on the diet for one month. A test to determine
whether the diet has reduced their weight is to be performed.
The aptitudes of boys and girls for mathematics are to be compared. In order
to eliminate the effect of social factors, pairs of brothers and sisters are used
in the comparison. Each (brother, sister) pair is given the same test and the
mean marks of boys and girls compared.
67
In each of the examples on the previous slide, the two samples cannot be
regarded as independent.
In the first example, two readings (before and after readings) are
made on the same subject.
In the second example the two samples are matched via a common
factor (family connection).
The development of the test statistics in the previous cases were based on
the fact that the two populations being studied are independent.
When this independency is violated, the same statistical theory that is used
to develop the test statistics cannot be used.
One way to overcome the violation in the case of studying
paired/dependent populations, is to ‘transform’ the two data sets (two
samples collected) into one.
68
This is done by finding the difference of each paired observation.
This ‘difference’ then becomes the new data set, which has been reduced
to one sample.
Using this new data set (of size 𝑛𝑛) made up of the differences (𝑑𝑑𝑖𝑖 ’s) the
mean and the standard deviation of this sample can be calculated,
denoted by 𝑑𝑑̅ and 𝑆𝑆𝑑𝑑 , respectively.
69
The mean of the paired differences of the (𝑥𝑥, 𝑦𝑦) values of the two dependent
populations is defined as 𝜇𝜇𝑑𝑑 = 𝜇𝜇1 − 𝜇𝜇2 .
Under the assumption that the differences are sampled from a normal
population, hypotheses concerning the mean of the differences 𝜇𝜇𝑑𝑑 can be
tested by performing a one sample t-test.
The hypothesis tests for all 4 cases are performed in the same manner as
that for a one-sample test ⇒ compare a test statistic
⇒ compare a P-value to 𝛼𝛼 (level of significance)
70
Confidence interval for 𝜇𝜇1 − 𝜇𝜇2
Recall from section 4.3: the general form of a confidence interval for the mean
(𝜇𝜇) is:
Point estimate ± error
Made up of a 𝑍𝑍 -value or
𝑡𝑡 -value (“critical value”)
multiplied by the standard
error of the point estimate.
• A confidence interval for 𝜇𝜇1 − 𝜇𝜇2 takes on the same form.
• The value of the standard error and whether a 𝑍𝑍 or 𝑡𝑡-value is used is based
on which case is being considered (case A, B, C or D).
71
Interpretation of a confidence interval for 𝜇𝜇1 − 𝜇𝜇2
Case B Case C
• Question: But how do we know if 𝜎𝜎12 = 𝜎𝜎22 ?
• Answer: a) We either know from past studies or research.
b) Or we can perform a hypothesis test to determine if 𝜎𝜎12 = 𝜎𝜎22 .
73
Therefore, this section presents methods for carrying out a hypothesis test to
determine if two population variances are equal.
Null Hypothesis:
𝐻𝐻0 : 𝜎𝜎12 = 𝜎𝜎22
Alternative Hypothesis:
𝐻𝐻1 : 𝜎𝜎12 ≠ 𝜎𝜎22 (two-tailed test)
Note: We can test the other one-sided alternatives 𝐻𝐻1 : 𝜎𝜎12 < 𝜎𝜎22 or 𝐻𝐻1 : 𝜎𝜎12 > 𝜎𝜎22 ,
however for this course, we are only interested in the testing of population
means. Thus, we only use this test to determine if we use case B or case C to
test the difference in two population means. Therefore, we only use the two-
sided alternative above.
74
Recall: The general form of representing the null hypothesis is 𝐻𝐻0 : 𝜃𝜃 = 𝜃𝜃0 …
𝜎𝜎12
𝐻𝐻0 : 𝜎𝜎12 = 𝜎𝜎22 𝐻𝐻0 : 2 = 1
𝜎𝜎2
75
Important:
• N.B. the purpose of this test is to determine which case (B or C) is used when
testing 𝐻𝐻0 : 𝜇𝜇1 = 𝜇𝜇2 where the population variances are unknown.
• Statistical software (such as SAS) automatically produces the results of both
cases as well as that for the test of equality of population variances.
• Based on the test of equal variances, we then consider the results of case B
or case C accordingly in order to test 𝐻𝐻0 : 𝜇𝜇1 = 𝜇𝜇2 :
Section 4.6:
ANOVA
(Part 1)
One-Way Analysis of Variance
• Recall: We can carry out hypothesis tests for a single population mean
using a single sample (𝐻𝐻𝑜𝑜 : 𝜇𝜇 = 𝜇𝜇0 ) – referred to as a one-sample test.
• We can also carry out hypothesis tests for comparing population means
of two groups (𝐻𝐻𝑜𝑜 : 𝜇𝜇1 = 𝜇𝜇2 ) – referred to as a two-sample test.
• An Analysis of Variance (ANOVA) is a statistical method of comparing
two or more groups of population means:
𝐻𝐻0: 𝜇𝜇1 = 𝜇𝜇2 = ⋯ = 𝜇𝜇𝑘𝑘 (The mean responses of 𝑘𝑘 groups are all equal)
78
For a one-way ANOVA, you have the following:
• one continuous dependent/response variable.
• one categorical independent variable (also called a predictor or
explanatory variable). This is known as a factor.
Assumptions of an ANOVA:
The following conditions must be satisfied in order to use an ANOVA:
Each sample must be randomly selected from a normal or approximately
normal population.
The samples must be independent of each other (results of one sample
do not affect those of other samples).
Each population must have the same variance (constant variance).
79
One-way ANOVA
An ANOVA consists of drawing 𝒌𝒌 independent samples from 𝒌𝒌 populations:
Population 1 Population 2 Population 𝒌𝒌
Do people treated with one of two new drugs have higher Factor = The drug type
average T-cell counts than people in the control group?
Treatments: Placebo, treatment 1,
treatment 2
Treatment 2
Factor = Profession
Treatments: Teacher, accountant
• If you analyze the difference between two means using ANOVA, you reach the same
conclusions as you reach using a pooled, two-sample t-test (Case B).
83
Experimental Designs
• An ANOVA is commonly used in the analysis of data generated from an
experiment.
• In such an experiment, we have to ensure that the maximum information
is obtained from the data that was generated at the lowest possible cost.
• This process is called an experimental design.
Terminology:
Experiment: is the means of getting an answer to a question. It can either
be observational or designed.
E.g. Decide which of the several pain relieving drugs are most effective.
Compare different methods of teaching.
84
Terminology…
Treatment: Different procedures under comparison in an experiment are
different treatments. Also known as factor levels.
E.g: In agriculture, different varieties of a crop or different fertilizers are
treatments.
In a medical experiment, different diets or medicines are the treatments.
85
• There are different types of experimental designs ranging in complexity.
• We will consider only two experimental designs:
A completely randomized design (CRD) and
A randomized block design (RBD).
• Both experimental designs make use of an ANOVA in the analysis of the
data and both study the effect of one factor (whose factor levels make
up the different treatments) on the response variable.
87
Assumptions of a CRD:
o As the analysis of the data from a CRD is done using an ANOVA, the
assumptions of an ANOVA hold (from slide 79):
Samples are independent and random (results of one sample do not
affect those of other samples).
Samples are obtained from a population of values that are normally
distributed with each population having the same variance 𝝈𝝈𝟐𝟐 .
o In addition to the assumptions above, the following also pertain to a CRD:
The experimental units are identical w.r.t. their characteristics that can
affect the response of interest.
There are no external variables that can affect the response of
interest.
88
o The last two assumptions of a CRD are very important because if there
are differences in the experimental units, or if there are other external
factors that affect the response variable, then we cannot attribute the
differences we are seeing in the mean responses of the treatments
groups to the different treatments that are being applied.
For example, suppose you are researching how exercise can change a
person’s weight.
• Exercise is your factor of interest (let’s say it consists of 3 treatments: no
exercise, little exercise and regular exercise)
• The change in weight is your response variable.
• Let’s say you test 200 volunteers that randomly get assigned a
treatment (exercise regime).
89
What are the experimental units?
The individuals
What assumptions must be satisfied in order for this to be a CRD?
The individuals (the experimental units) are all as similar as possible with
regards to characteristics that can affect weight change:
They are all the same gender and a similar age.
They all have a similar starting weight.
They all have a similar diet.
There are no external factors that can affect their weight change.
These assumptions ensure us that the differences we see in the weight
change are ONLY due to the treatments (exercise regime).
90
New Terminology
𝑌𝑌 is the response variable, and its values are responses.
𝑌𝑌𝑖𝑖𝑖𝑖 refers to the 𝑗𝑗𝑡𝑡𝑡 observation/response in the sample from the 𝑖𝑖𝑡𝑡𝑡
treatment group.
E.g. 𝑌𝑌35 is the 5th observation of the sample from the 3rd treatment group.
𝑖𝑖 = 1, 2, … , 𝑘𝑘 ; 𝑗𝑗 = 1, 2, … , 𝑛𝑛𝑖𝑖
93
Statistical Model for a CRD:
The general linear statistical model for a CRD has the form:
𝑌𝑌𝑖𝑖𝑖𝑖 = 𝜇𝜇 + 𝜏𝜏𝑖𝑖 + 𝜀𝜀𝑖𝑖𝑖𝑖
This is also known as
= 𝜇𝜇𝑖𝑖 + 𝜀𝜀𝑖𝑖𝑖𝑖 an ANOVA model
Where
• 𝜇𝜇 is the overall population mean (constant);
• 𝜏𝜏𝑖𝑖 (the Greek symbol Tau) is the effect of the 𝑖𝑖𝑡𝑡𝑡 treatment;
• 𝜇𝜇𝑖𝑖 = 𝜇𝜇 + 𝜏𝜏𝑖𝑖 is the mean of the 𝑖𝑖𝑡𝑡𝑡 treatment;
• 𝜀𝜀𝑖𝑖𝑖𝑖 is the random error for the 𝑗𝑗𝑡𝑡𝑡 response in the 𝑖𝑖𝑡𝑡𝑡 treatment. These
errors are assumed to be independent and normally distributed with a
mean of 0 and a variance of 𝜎𝜎 2 , i.e: 𝜀𝜀𝑖𝑖𝑖𝑖 ~𝑁𝑁(0, 𝜎𝜎 2 )
• 𝜇𝜇, 𝜏𝜏𝑖𝑖 and 𝜎𝜎 2 are the parameters of the model that are to be estimated.
The hypotheses above are for that of any ANOVA, which is why the analysis
of data from a CRD can be done using an ANOVA.
These hypotheses can be tested by carrying out tests on the parameters in
the statistical model…
95
Hypotheses for a CRD:
Recall: 𝑌𝑌𝑖𝑖𝑖𝑖 = 𝜇𝜇 + 𝜏𝜏𝑖𝑖 + 𝜀𝜀𝑖𝑖𝑖𝑖
= 𝜇𝜇𝑖𝑖 + 𝜀𝜀𝑖𝑖𝑖𝑖
If there is no significant different in the mean responses for the groups, then
𝜇𝜇1 = 𝜇𝜇2 = ⋯ = 𝜇𝜇𝑘𝑘 (all means equal). This also means that 𝜏𝜏1 = 𝜏𝜏2 = ⋯ = 𝜏𝜏𝑘𝑘 = 0
(the treatment effects are 0).
Therefore, the we can test: Notice this tests if
the treatment
𝐻𝐻0 : 𝜏𝜏1 = 𝜏𝜏2 = … = 𝜏𝜏𝑘𝑘 = 0
effects equal zero
𝐻𝐻1 : Not all 𝜏𝜏𝑖𝑖′ s are equal to zero
The mean for each treatment group (mean of all responses for a
treatment) is 𝜇𝜇𝑖𝑖 = 𝜇𝜇 + 𝜏𝜏𝑖𝑖
Notice in this example (the data in the table on slide 19), even with the
exact same fertilizer being used under the same conditions, the yield of
crop in each of the 10 subplots of land varied
In general, the exact same experiment doesn’t always obtain the exact
same results. This is known as measurement error or random variation. This
random variation is represented by the 𝜀𝜀𝑖𝑖𝑖𝑖 term in the statistical model.
99
Logic Behind the Analysis of Variance
Even though we are comparing means, the ANOVA test procedure
considers the variation (differences) in the observations.
Briefly speaking, if there is a large variation in the observations between
the treatment groups, then we can conclude that the treatment means
differ.
The test procedure of an ANOVA is based on a comparison of two sources
of variation:
Variation attributed to the differences among the observations between
the treatment groups (i.e. due to the effect of the treatments)
Variation attributed to the differences among the observations within the
treatment groups (i.e. due to random error or random variation/
measurement error)
100
Logic Behind the Analysis of Variance…
If these two sources of variation are in proportion (i.e. if their ratio is
close to 1), then it can be concluded there are no differences in the
treatment means.
However, if the variation between the treatment groups is much larger
than the variation within the treatment groups, then it can be
concluded the treatment means differ.
For example:
Scores of 22 children taught by 3 different methods A, B, C are obtained.
Test at a 5% level of significance that the mean scores for the 3 methods
are equal.
Because one independent variable is being studied (method of
teaching), the process is called one-way analysis of variance.
𝐻𝐻0: 𝜇𝜇1 = 𝜇𝜇2 = 𝜇𝜇3 𝐻𝐻1: At least two means differ
101
Logic Behind the Analysis of Variance…
Variation between samples
A B C
116 132 108
117 137 96
Variation within samples
102
Logic Behind the Analysis of Variance…
The totals, sample A B C
sizes and sample 𝑻𝑻𝟏𝟏 = 1098 𝑻𝑻𝟐𝟐 = 889 𝑻𝑻𝟑𝟑 = 702
means of each 𝒏𝒏𝟏𝟏 = 9 𝒏𝒏𝟐𝟐 = 7 𝒏𝒏𝟑𝟑 = 6
group:
�𝟏𝟏 = 122
𝑻𝑻 �𝟐𝟐 = 127
𝑻𝑻 �𝟑𝟑 = 117
𝑻𝑻
o If we examine the means of three samples, we see variability BETWEEN
means.
o This variability is due to the combined effect of the natural differences
and possible treatment differences between the groups (differences due
to the different treatments being applied).
o So our problem is to decide whether the differences among sample
means are due to chance or if they occur because the three
populations/treatments are actually different.
103
Logic Behind the Analysis of Variance…
Consider two situations showing the sample mean of each treatment
group with the individual observations around the mean.
Which situation shows evidence to suggest there is a difference among the
four population means? Situation 2
Situation 1 shows little variation/difference between the treatment group
means compared to the variation within each group, whereas situation 2
shows a larger variation between the means compared to within the
groups.
104
Logic Behind the Analysis of Variance…
Variation within samples < variation between samples Reject Ho
We can use statistical software to check the above assumptions for our data.
105
One-way ANOVA Test Procedure
𝐻𝐻0: 𝜇𝜇1 = 𝜇𝜇2 = ⋯ = 𝜇𝜇𝑘𝑘 𝐻𝐻1: At least two 𝜇𝜇𝑖𝑖′ 𝑠𝑠 differ (𝑖𝑖 = 1, 2, … , 𝑘𝑘)
A measure of
Variation between samples variability in an
Test Statistic =
Variation within samples ANOVA is a MEAN
SUM OF SQUARES
Mean Sum of Squares Between
𝐹𝐹 calc =
Mean Sum of Square Within 𝜶𝜶 = Level of significance
Where 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 is the TOTAL sum of squares: 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 = � � 𝑌𝑌𝑖𝑖𝑖𝑖2 − 𝐶𝐶𝐶𝐶 (FYI)
𝑖𝑖=1 𝑗𝑗=1
Notice how values in the table add up: The corresponding P-value = .3795
…323.86 + 3026 = 3349.86 (obtained from software)
2 + 19 = 21 ∴ since P-value > 0.05, 𝐻𝐻0 is NOT rejected at a
323.86 ÷ 2 = 161.93 5% level of significance.
13026 ÷ 19 = 159.26 Thus, there is insufficient evidence to conclude
161.93 ÷ 159.26 = 1.02 that the mean responses of at least two
treatments differ. 111
Completely Randomized Designs Recap……
Assumptions:
INDEPENDENT; RANDOM; NORMALLY DISTRIBUTED POP; SAME VARIANCE
A B C
Replication
116 132 108
117 137 96
Treatment 1 2 . . 𝒏𝒏𝒊𝒊 Total Mean
138 131 131
100 108 130
1 𝑌𝑌11 𝑌𝑌12 . . 𝑌𝑌1𝑛𝑛𝑖𝑖 𝑇𝑇1 𝑇𝑇�1
125 111 111
2 𝑌𝑌21 𝑌𝑌22 . . 𝑌𝑌2𝑛𝑛𝑖𝑖 𝑇𝑇2 𝑇𝑇�2 130 130 126
. . . . . . . 134 140
124
𝒌𝒌 𝑌𝑌𝑘𝑘𝑘 𝑌𝑌𝑘𝑘𝑘 . . 𝑌𝑌𝑘𝑘𝑛𝑛𝑖𝑖 𝑇𝑇𝑘𝑘 𝑇𝑇�𝑘𝑘
114
𝐻𝐻0: 𝜇𝜇1 = 𝜇𝜇2 = ⋯ = 𝜇𝜇𝑘𝑘 𝐻𝐻1: At least two 𝜇𝜇𝑖𝑖′ 𝑠𝑠 differ (𝑖𝑖 = 1, 2, … , 𝑘𝑘)
𝑛𝑛𝑖𝑖 → 𝑛𝑛
Variation between samples 𝐹𝐹 calc
Test Statistic = 𝑇𝑇𝑖𝑖 → 𝑔𝑔𝑔𝑔𝑔𝑔𝑔𝑔𝑔𝑔 𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡𝑡
Variation within samples
Section 4.6:
ANOVA
(Part 2)
Randomized Block Designs
o Recall: the assumptions of a CRD require the experimental units to be
homogeneous with no external factors affecting the response variable.
o However, it is not always possible to design an experiment under such
assumptions.
o If these assumptions are not satisfied, then there is an extra source of
variation in the response variable due to the differences in the
experimental units/or due to an external factor.
o It is possible to control for this extra source of variation by ‘blocking’ for it
(isolating it).
o This is done by introducing a blocking factor into the design, and such a
design is referred to as a randomized block design (RBD).
Randomized Block Designs…
o E.g. consider the example of how exercise affects a person’s weight
Suppose 100 men and 100 women were randomly assigned to a
treatment (exercise regime)
o In this case, the individuals who are the experimental units are not
homogenous as their gender differs.
o Thus, gender would be included as a blocking factor (in addition to the
main factor of interest – the exercise regime). This would then result in a
randomized block design.
o It is possible to include additional blocking factors (for example age as
well), however in this course we will only be considering a RBD with one
blocking factor.
Structure and Notation of a RBD:
𝑘𝑘 treatments and 𝑏𝑏 blocks each. (N.B: The rows and columns
Treatment can be interchanged.)
𝐻𝐻0 : 𝜏𝜏1 = 𝜏𝜏2 = … = 𝜏𝜏𝑘𝑘 = 𝟎𝟎 versus 𝐻𝐻1 : Not all 𝜏𝜏𝑖𝑖′ s are equal to zero
Or equivalently
𝐻𝐻0 : 𝜇𝜇1. = 𝜇𝜇2. = … = 𝜇𝜇𝑘𝑘. versus 𝐻𝐻1 : At least two 𝜇𝜇𝑖𝑖.′ s differ
Or equivalently
𝐻𝐻0 : 𝜇𝜇.1 = 𝜇𝜇.2 = … = 𝜇𝜇.𝑏𝑏 versus 𝐻𝐻1 : At least two 𝜇𝜇.𝑗𝑗′ s differ
Assumptions of an RBD:
o As in the case of a CRD, the analysis of the data from a RBD is done using
an ANOVA,
o Therefore, the assumptions of an ANOVA hold:
Samples are independent and random (results of one sample do not
affect those of other samples).
Samples are obtained from a population of values that are normally
distributed with each population having the same variance 𝝈𝝈𝟐𝟐 .
o In the statistical model for a RBD, it is assumed there are no joint effects
(interactions) between the treatments and blocks.
Analysis of an RBD:
o An ANOVA is used to analyze the data from a RBD.
o Recall from part 1 of this chapter, the total sum of squares 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 is
partitioned into the various sources of variation.
o The same procedure is applied in an ANOVA for a RBD, where there are
now 3 sources of variation:
1. Variation due to the treatments
2. Variation due to the blocks
3. Variation due to random error (natural variation)
o Thus, the total sum of squares is partitioned into 3 components:
𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 = 𝑆𝑆𝑆𝑆𝑆𝑆 + 𝑆𝑆𝑆𝑆𝑆𝑆 + 𝑆𝑆𝑆𝑆𝑆𝑆
Where 𝑆𝑆𝑆𝑆𝑆𝑆 = 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 is the block sum of squares (𝑆𝑆𝑆𝑆𝑆𝑆 & 𝑆𝑆𝑆𝑆𝑆𝑆 are the same
from a CRD)
The degrees of freedom can be obtained for each sum of squares:
𝑑𝑑𝑑𝑑 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 = 𝑏𝑏𝑏𝑏 − 1 (total number of observations less 1)
= 𝑏𝑏𝑏𝑏 − 1 − 𝑘𝑘 − 1 − (𝑏𝑏 − 1)
= (𝑏𝑏 − 1)(𝑘𝑘 − 1)
The mean sum of squares can now be obtained for each source of variation:
𝑆𝑆𝑆𝑆𝑆𝑆 𝑆𝑆𝑆𝑆𝑆𝑆𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙 𝑆𝑆𝑆𝑆𝑆𝑆
𝑀𝑀𝑀𝑀𝑀𝑀 = 𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀 = 𝑀𝑀𝑀𝑀𝑀𝑀 =
𝑑𝑑𝑑𝑑(𝑆𝑆𝑆𝑆𝑆𝑆) 𝑑𝑑𝑑𝑑(𝑆𝑆𝑆𝑆𝑆𝑆) 𝑑𝑑𝑑𝑑(𝑆𝑆𝑆𝑆𝑆𝑆)
Hypothesis Tests for a RBD:
Since we are now considering two factors in a RBD (the treatments and
the blocks), we can now perform two hypothesis tests:
The test procedure for each hypothesis test above is similar to that of a CRD
or one-factor ANOVA (compare the P-value to 𝛼𝛼).
ANOVA Table for a RBD:
Source of Sum of
𝑑𝑑𝑑𝑑 Mean sum of squares F-statistic
Variation Squares
𝑆𝑆𝑆𝑆𝑆𝑆 𝑀𝑀𝑀𝑀𝑀𝑀
Treatments 𝑆𝑆𝑆𝑆𝑆𝑆 𝑘𝑘 − 1 𝑀𝑀𝑀𝑀𝑀𝑀 = 𝐹𝐹𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 =
𝑘𝑘 − 1 𝑀𝑀𝑀𝑀𝑀𝑀
𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀
Blocks 𝑆𝑆𝑆𝑆𝐵𝐵 𝑏𝑏 − 1 𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀 = 𝐹𝐹𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 =
𝑏𝑏 − 1 𝑀𝑀𝑀𝑀𝑀𝑀
𝑆𝑆𝑆𝑆𝑆𝑆
Error 𝑆𝑆𝑆𝑆𝑆𝑆 (𝑏𝑏 − 1)(𝑘𝑘 − 1) 𝑀𝑀𝑀𝑀𝑀𝑀 =
(𝑏𝑏 − 1)(𝑘𝑘 − 1)
Total 𝑆𝑆𝑆𝑆𝑆𝑆𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜 𝑏𝑏𝑏𝑏 − 1
Example 1:
The cellphone industry is involved in a battle for customers, each with its
own pricing plan for customers. A consumer watchdog group decides to
compare the average cost of data for 4 cellphone companies using 3
different usage levels as blocks. Results are given in the table.
1. Construct the ANOVA table for this experiment.
Company Treatments
Usage Level A B C D 𝑘𝑘 = 4
𝑏𝑏 = 3 Low 27 24 31 23
Blocks Middle 68 76 65 67
High 308 326 312 300
The usage level can affect the price of data, therefore it must be blocked for (the more
data you buy, the cheaper it is.
The statistical model we wish to fit to this RBD:
𝑌𝑌𝑖𝑖𝑖𝑖 = cost of data for the 𝑖𝑖𝑡𝑡𝑡 cellular company and the 𝑗𝑗𝑡𝑡𝑡 usage level.
𝜏𝜏𝑖𝑖 = effect of cellular company 𝑖𝑖 on the cost of data
𝛽𝛽𝑗𝑗 = effect of usage level 𝑗𝑗 on the cost of data
𝜀𝜀𝑖𝑖𝑖𝑖 = the random error for the response of the 𝑖𝑖𝑡𝑡𝑡 cellular company in the
𝑗𝑗𝑡𝑡𝑡 usage level.
The ANOVA Table:
Thus, there is insufficient evidence to conclude that the average cost differs
for at least two companies.
2. Do the data provide sufficient evidence to indicate a difference in the
block means (average cost due to level of usage)?
Thus, there is sufficient evidence to conclude that the average cost differs for
at least two usage levels (the mean of at least two blocks differ)
Randomized Block Designs Recap……
Source of Sum of
𝑑𝑑𝑑𝑑 Mean sum of squares F-statistic
Variation Squares
𝑆𝑆𝑆𝑆𝑆𝑆 𝑀𝑀𝑀𝑀𝑀𝑀
Treatments 𝑆𝑆𝑆𝑆𝑆𝑆 𝑘𝑘 − 1 𝑀𝑀𝑀𝑀𝑀𝑀 = 𝐹𝐹𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 =
𝑘𝑘 − 1 𝑀𝑀𝑀𝑀𝑀𝑀
𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀
Blocks 𝑆𝑆𝑆𝑆𝐵𝐵 𝑏𝑏 − 1 𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀𝑀 = 𝐹𝐹𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐 =
𝑏𝑏 − 1 𝑀𝑀𝑀𝑀𝑀𝑀
𝑆𝑆𝑆𝑆𝑆𝑆
Error 𝑆𝑆𝑆𝑆𝑆𝑆 (𝑏𝑏 − 1)(𝑘𝑘 − 1) 𝑀𝑀𝑀𝑀𝑀𝑀 =
(𝑏𝑏 − 1)(𝑘𝑘 − 1)
Total 𝑆𝑆𝑆𝑆𝑆𝑆𝑜𝑜𝑜𝑜𝑜𝑜𝑜𝑜 𝑏𝑏𝑏𝑏 − 1
Questions:
1
2
Questions:
1
2
3
True or false?
3
True or false?
4
Calculate a to g
4
Section 4.6:
ANOVA
(Part 3)
Two-way ANOVA
o So far we have considered a one-way ANOVA, where the effect of one
factor (independent categorical variable) on the continuous response
variable is of interest.
o We considered this under two different types of experimental designs: a
completely randomized design (CRD) and a randomized block design
(RBD).
o Even though the analysis of a RBD included two factors, one of the factors
was a the blocking factor which controlled for differences in the
experimental units or external factors affecting the response variable.
o The effect of the blocking factor on the response variable was also not the
main interest in a RBD.
o Furthermore, no joint effects or interactions were allowed in a RBD
between the factor of interest and the blocking factor.
141
Two-Way ANOVA
o Now, in a two-way ANOVA, we are interested in the effects of TWO
factors/categorical variables (each consisting of at least two
categories/levels) on the continuous response variable.
o These two factors are allowed to have joint effects or interactions.
o Interaction effects occur when the effect of one factor on the response
depends on the value or level of another factor.
o However, interaction effects do not occur if the two variables/factors
are independent of each other.
o A two-way ANOVA can be carried out in a CRD as well as a RBD (i.e.
the same assumptions would hold in these experimental designs as the
one-way ANOVA. A blocking factor can also be introduced which
results in a RBD).
o A two-way ANOVA is also known as a factorial design.
142
Treatments in a Two-Way ANOVA
o The primary objective of a two-way ANOVA is to study the effects of the
combination of the levels of the factors that are of interest.
o The treatment groups in a two-way ANOVA are formed by making all
possible combinations of the levels/categories of the two factors.
o For example, if the first factor has 3 levels and the second factor has 2
levels, then there will be 3x2=6 different treatment groups.
o Question: if there are two main factors of interest, factors A and B with 𝑎𝑎
and 𝑏𝑏 levels, respectively, then how many treatments (factor level
combinations) will be applied/investigated in the experiment?
Answer: 𝑎𝑎𝑎𝑎 treatments in total.
o The treatment effects are made up of the effects of factor A, the effects of
factor B and the effects of the interaction between factor A and factor B (if
there is an interaction between the factors).
143
Structure and Notation of a two-way ANOVA (CRD):
Factor B
𝐵𝐵1 𝐵𝐵2 … 𝐵𝐵𝑏𝑏
𝐴𝐴1 𝑌𝑌111 , 𝑌𝑌112 , … , 𝑌𝑌11𝑟𝑟 𝑌𝑌121 , 𝑌𝑌122 , … , 𝑌𝑌12𝑟𝑟 … 𝑌𝑌1𝑏𝑏𝑏 , 𝑌𝑌1𝑏𝑏𝑏 , … , 𝑌𝑌1𝑏𝑏𝑏𝑏
Factor A
𝐴𝐴2 𝑌𝑌211 , 𝑌𝑌212 , … , 𝑌𝑌21𝑟𝑟 𝑌𝑌221 , 𝑌𝑌222 , … , 𝑌𝑌22𝑟𝑟 … 𝑌𝑌2𝑏𝑏𝑏 , 𝑌𝑌2𝑏𝑏𝑏 , … , 𝑌𝑌2𝑏𝑏𝑏𝑏
⋮ ⋮ … ⋮
𝐴𝐴𝑎𝑎 𝑌𝑌𝑎𝑎𝑎𝑎 , 𝑌𝑌𝑎𝑎𝑎𝑎 , … , 𝑌𝑌𝑎𝑎𝑎𝑎𝑎 𝑌𝑌𝑎𝑎𝑎𝑎 , 𝑌𝑌𝑎𝑎𝑎𝑎 , … , 𝑌𝑌𝑎𝑎𝑎𝑎𝑎 … 𝑌𝑌𝑎𝑎𝑎𝑎𝑎 , 𝑌𝑌𝑎𝑎𝑎𝑎𝑎 , … , 𝑌𝑌𝑎𝑎𝑎𝑎𝑎𝑎
𝐴𝐴1 𝑌𝑌111 , 𝑌𝑌112 , … , 𝑌𝑌11𝑟𝑟 𝑌𝑌121 , 𝑌𝑌122 , … , 𝑌𝑌12𝑟𝑟 … 𝑌𝑌1𝑏𝑏𝑏 , 𝑌𝑌1𝑏𝑏𝑏 , … , 𝑌𝑌1𝑏𝑏𝑏𝑏
Factor A
𝐴𝐴2 𝑌𝑌211 , 𝑌𝑌212 , … , 𝑌𝑌21𝑟𝑟 𝑌𝑌221 , 𝑌𝑌222 , … , 𝑌𝑌22𝑟𝑟 … 𝑌𝑌2𝑏𝑏𝑏 , 𝑌𝑌2𝑏𝑏𝑏 , … , 𝑌𝑌2𝑏𝑏𝑏𝑏
⋮ ⋮ … ⋮
𝐴𝐴𝑎𝑎 𝑌𝑌𝑎𝑎𝑎𝑎 , 𝑌𝑌𝑎𝑎𝑎𝑎 , … , 𝑌𝑌𝑎𝑎𝑎𝑎𝑎 𝑌𝑌𝑎𝑎𝑎𝑎 , 𝑌𝑌𝑎𝑎𝑎𝑎 , … , 𝑌𝑌𝑎𝑎𝑎𝑎𝑎 … 𝑌𝑌𝑎𝑎𝑎𝑎𝑎 , 𝑌𝑌𝑎𝑎𝑎𝑎𝑎 , … , 𝑌𝑌𝑎𝑎𝑎𝑎𝑎𝑎
The cells in the body of the table each contain responses corresponding to one
treatment group.
These are the responses in treatment group 1 (when factor A is at level 1 and
factor B is at level 1)
Each treatment group is made up of 𝑟𝑟 responses known as replications.
Factor A consists of 𝑎𝑎 categories/levels and factor B of 𝑏𝑏 categories/levels.
Statistical Model for a two-way ANOVA (CRD):
𝑌𝑌𝑖𝑖𝑖𝑖𝑖𝑖 = 𝜇𝜇 + 𝛼𝛼𝑖𝑖 +𝛽𝛽𝑗𝑗 + 𝛼𝛼𝛼𝛼𝑖𝑖𝑖𝑖 + 𝜀𝜀𝑖𝑖𝑖𝑖𝑖𝑖 Note: If there is only 1
replicate per treatment
= 𝜇𝜇𝑖𝑖𝑖𝑖 + 𝜖𝜖𝑖𝑖𝑖𝑖𝑖𝑖 group, then 𝑟𝑟 = 1 and
sometimes the subscript 𝑘𝑘
𝜇𝜇 is the usual overall population mean; falls away.
𝛼𝛼𝑖𝑖 is the effect of the 𝑖𝑖 𝑡𝑡𝑡 level of factor A (known as the main effect of factor A);
𝛽𝛽𝑗𝑗 is the effect of the 𝑗𝑗𝑡𝑡𝑡 level of factor B (known as the main effect of factor B);
𝛼𝛼𝛼𝛼𝑖𝑖𝑖𝑖 = 𝛼𝛼𝛼𝛼 𝑖𝑖𝑖𝑖 is the interaction effect of the 𝑖𝑖 𝑡𝑡𝑡 level of factor A and 𝑗𝑗𝑡𝑡𝑡 level of
factor B;
𝜇𝜇𝑖𝑖𝑖𝑖 is the mean of the combination of the 𝑖𝑖 𝑡𝑡𝑡 level of factor A and the 𝑗𝑗𝑡𝑡𝑡 level of
factor B, i.e., the 𝐴𝐴𝑖𝑖 𝐵𝐵𝑗𝑗 treatment mean;
′
The 𝜀𝜀𝑖𝑖𝑖𝑖𝑖𝑖 𝑠𝑠 are the random error terms which are assumed to be independently
and normally distributed with a mean of 0 and constant variance 𝜎𝜎 2 , i.e:
𝜀𝜀𝑖𝑖𝑖𝑖𝑘𝑘 ~𝑁𝑁(0, 𝜎𝜎 2 )
Hypotheses for a Two-way ANOVA (CRD):
Because the two-way ANOVA considers the effect of two categorical
factors and their interaction effect, there are three pairs of null or
alternative hypotheses for the two-way ANOVA:
The first two hypotheses above are the same as testing the effects of each
factor:
𝐻𝐻0 : There are no main effects of factor A
𝐻𝐻0 : There are no main effects of factor B
These hypotheses can also be represented in terms of the parameters of
the statistical model…
147
Hypotheses for a Two-way ANOVA (CRD):
𝑌𝑌𝑖𝑖𝑖𝑖𝑖𝑖 = 𝜇𝜇 + 𝛼𝛼𝑖𝑖 + 𝛽𝛽𝑗𝑗 + 𝛼𝛼𝛽𝛽𝑖𝑖𝑖𝑖 + 𝜀𝜀𝑖𝑖𝑖𝑖𝑖𝑖
𝐻𝐻0 : 𝛽𝛽1 = 𝛽𝛽2 = … = 𝛽𝛽𝑏𝑏 = 0 versus 𝐻𝐻1 : Not all 𝛽𝛽𝑗𝑗′ s are equal to zero
148
Assumptions of a Two-way ANOVA (CRD):
149
Analysis of a Two-way ANOVA:
o As usual in an ANOVA, the total sum of squares 𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆𝑆 is partitioned into
the various sources of variation.
o The same procedure is applied in a two-way ANOVA for a CRD, where
there are still two sources of variation:
1. Variation due to the treatments
2. Variation due to random error (natural variation)
o However, since the treatments are made up of a combination of
effects of factors A and B, the variation due to the treatments can be
partitioned as follows:
The main effects of factor A
The main effects of factor B
The interaction effects between factor A and factor B
150
o Therefore, the total sum of squares is partitioned into 4 components:
As usual, the critical value corresponding to each F-statistic will have a
degrees of freedom of 𝑑𝑑𝑑𝑑1 = the numerator df and 𝑑𝑑𝑑𝑑2 = 𝑎𝑎𝑎𝑎(𝑟𝑟 − 1) = the
df of 𝑀𝑀𝑀𝑀𝑀𝑀.
Each null hypothesis is rejected if the respective calculated F-statistic is
greater than the corresponding critical value, or if the P-value is less than
the level of significance.
152
A table for a two-way ANOVA CRD:
153
Example:
The yield of a chemical process is being studied. The two most important variables that
are thought to affect the yield of the chemical process are the pressure and the
temperature. Three levels of each factor are selected and a factorial experiment in a
CRD with two replications is performed. The yield data follow. The numbers in ( ) are the
cell totals. Pressure
200 215 230
𝑎𝑎 = 3 ; 𝑏𝑏 = 3 ; 𝑟𝑟 = 2 𝑖𝑖 = 1,2, 3 ; 𝑗𝑗 = 1, 2 , 3 ; 𝑘𝑘 = 1, 2
𝑛𝑛 = 𝑎𝑎𝑎𝑎𝑎𝑎 = 3 × 3 × 2 = 18 is the total number of observations
154
NOTE:
The analysis of a two-way ANOVA usually begins by checking the
presence of a factor A by factor B interaction (or B by A interaction)
using a graph of the average responses versus the levels of the factors.
We can do this by plotting the average response of a treatment for
each level of factor B according to factor A (or visa versa).
Let’s do this for the pressure and temperature example from the previous
slide. The average response was calculated for each treatment as
follows: Pressure
200 215 230
Pressure
90.40
200 215 230
Average Response
91.00
Temp = 40
Pressure
90.80
200 215 230
90.60
20 90.30 90.65 90.30
Temperature 30 90.20 90.55 90.00 90.40
Temp = 20
40 90.60 90.85 90.25
90.20
Temp = 30
90.00
200 215 230
Pressure
157
From this plot, we can see that there is possibly a pressure by temperature
interaction effect.
i.e. the treatments for temperature =
Average Response 40 perform the best, except when
91.00 pressure is at 230.
Temp = 40
Thus, the performance of a treatment
90.80
at a particular temperature may be
90.60
dependent on the pressure – which is
due to the interaction between
Temp = 20 temperature and pressure.
90.40
Pressure 158
If no interaction was present, the lines for each temperature would be parallel
(never intersecting). For example:
90.40 Temp = 20
90.20 Temp = 30
90.00
200 215 230
Pressure
159
Let’s specify the statistical model for this example (specific to the question):
NOTE: When you specify the statistical model, you must also indicate the ranges
of the subscripts, i.e. 𝑖𝑖, 𝑗𝑗, 𝑘𝑘
2 0.301 𝑀𝑀𝑀𝑀𝑀𝑀𝑒𝑒𝑒𝑒𝑒𝑒
Temperature 0.301 = 0.151 𝐹𝐹 = = 8.389
2 𝑀𝑀𝑀𝑀𝑀𝑀
0.768 𝑀𝑀𝑀𝑀𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃
Pressure 0.768 2 = 0.384 𝐹𝐹 = = 21.333
2 𝑀𝑀𝑀𝑀𝑀𝑀
0.069 𝑀𝑀𝑀𝑀𝑀𝑀𝑒𝑒𝑒𝑒𝑒𝑒 ∗ 𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃𝑃
Temp*Press 0.069 4 = 0.017 𝐹𝐹 = = 0.944
4 𝑀𝑀𝑀𝑀𝑀𝑀
0.160
Error 0.160 9 = 0.018
9
Total 1.298 17
161
Before carrying out a hypothesis test concerning the main effects of each
factor, we first need to determine if there is a significant interaction effect
between the factors:
′
𝐻𝐻0 : All the 𝛼𝛼𝛽𝛽𝑖𝑖𝑖𝑖 𝑠𝑠 equal zero (there are no interaction effects)
′
𝐻𝐻1 : Not all the 𝛼𝛼𝛽𝛽𝑖𝑖𝑖𝑖 𝑠𝑠 equal zero (there are interaction effects)
162
For the interaction effects (using a 5% level of significance):
𝐻𝐻0 : All the 𝛼𝛼𝑖𝑖 ′𝑠𝑠 equal zero (The temperature has no effect on the response)
𝐻𝐻1 : Not all the 𝛼𝛼𝑖𝑖 ′𝑠𝑠 equal zero (The temperature has a significant effect on
the response)
164
Main effects of factor B (Pressure):
𝐻𝐻0 : All the 𝛽𝛽𝑗𝑗 ′𝑠𝑠 equal zero (The pressure has no effect on the response)
𝐻𝐻1 : Not all the 𝛽𝛽𝑗𝑗 ′𝑠𝑠 equal zero (The pressure has a significant effect on the
response)
165
Which Treatment Means Differ?
Recall from an ANOVA test:
𝐻𝐻0: 𝜇𝜇1 = 𝜇𝜇2 = ⋯ = 𝜇𝜇𝑘𝑘 (The mean responses of 𝑘𝑘 groups are all equal)
Independence Assumption
• Based on the domain of study, the researcher can ensure they are not
working with samples that are dependent. For example data from siblings.
• In addition, when observations are collected at successive time points, the
errors in the responses may become related through time.
Independence Assumption…