Statistics Overview
Statistics Overview
STATISTICS OVERVIEW
2. PROBABILITY 10
5) Overview of Probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5).1 Elements of Probability: Sample Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
5).2 Elements of Probability: Event . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
6) Set Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
7) Complementary Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
7).1 DeMorgan’s Law . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
8) Kolmogorov Axioms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
8).1 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
9) Equiprobability Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
10) Interpretation of Probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
11) Counting Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
12) Permutation and Combination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
12).1 Permutation: Ordered Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
12).2 Combinations: Unordered Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
12).3 Relationship . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
13) Conditional Probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
14) Independence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
15) Partition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
16) The Law of Total Probability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
17) Bayes Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
ii
18).3 Probability Mass Functions of Discrete Variables . . . . . . . . . . . . . . . . . . . . . . 22
18).4 Cumulative Distribution Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
18).5 Expected Value of a Random Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
18).6 Expectation and Mean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
18).7 Variance and Standard deviation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
19) Bernoulli Trial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
19).1 Expectiation and Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
20) Binomial Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
20).1 Expectation and Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
20).2 Binomial R function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
21) Geometric Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
21).1 The pmf of Geometric Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
21).2 Mean and Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
21).3 Geometric Distribution in a Different View . . . . . . . . . . . . . . . . . . . . . . . . . . 30
21).4 Geometric Distribution pmf & cdf R Code . . . . . . . . . . . . . . . . . . . . . . . . . . 31
22) Negative Binomial Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
22).1 Mean and Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
22).2 Negative Binomial Distribution (Textbook Version) . . . . . . . . . . . . . . . . . . . . 31
22).3 Negative Binomial Distribution pmf & cdf R Code . . . . . . . . . . . . . . . . . . . . . 32
23) Hypergeometric Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
23).1 Mean and Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
23).2 Hypergeometric Distribution in R Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
24) Poisson Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
24).1 Poisson Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
24).2 Poisson Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
24).3 Poisson Distribution in R Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
24).4 Conditions for a Poisson Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
24).5 Relationship Between Binomial and Poisson . . . . . . . . . . . . . . . . . . . . . . . . . 36
iii
34) Skewness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
34).1 Types of Skewness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
34).2 Tests of Skewness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
34).3 Interpretation of Skewness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
34).4 Magnitude of Skewness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
34).5 Handling skewness in data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
34).6 Difference between Dispersion and Skewness . . . . . . . . . . . . . . . . . . . . . . . . 52
35) Exponential Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
35).1 Mean, Median and Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
35).2 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
35).3 Memoryless Property . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
36) Gamma Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
36).1 Mean and Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
37) Weibull Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
37).1 cdf of Weibull Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
37).2 Mean and Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
37).3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
38) Chi-squared Distribution (χ2 Distribution) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
iv
6. POINT ESTIMATION 69
53) Point estimators and Sampling distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
53).1 Terminology: Sampling Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
53).2 Evaluate an Estimator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
54) The Methods of Moment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
55) Maximum Likelihood Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
55).1 The Invariance Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
v
71) Inference on µ1 and µ2 assuming known σ12 and σ22 . . . . . . . . . . . . . . . . . . . . . . . . . 103
71).1 Confidence Interval (CI) assuming known σ12 and σ22 . . . . . . . . . . . . . . . . . . . 103
71).2 Hypothesis Testing for µ1 and µ2 assuming known σ12 and σ22 . . . . . . . . . . . . . 103
72) Inference on µ1 and µ2 assuming unknown σ12 and σ22 : σ12 = σ22 . . . . . . . . . . . . . . . . 107
72).1 Confidence Interval (CI) assuming unknown σ12 and σ22 : σ12 = σ22 . . . . . . . . . . . 107
72).2 Hypothesis Testing for µ1 and µ2 assuming unknown σ12 and σ22 : σ12 = σ22 . . . . . 108
73) Inference on µ1 and µ2 assuming unknown σ12 and σ22 : σ12 ̸= σ22 . . . . . . . . . . . . . . . . 112
73).1 Confidence Interval (CI) assuming unknown σ12 and σ22 : σ12 ̸= σ22 . . . . . . . . . . . 112
73).2 Hypothesis Testing for µ1 and µ2 assuming unknown σ12 and σ22 : σ12 ̸= σ22 . . . . . 112
74) Inference on p1 and p2 : Independent samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
74).1 Confidence Interval (CI) of p1 and p2 : Independent samples . . . . . . . . . . . . . . . 116
74).2 Hypothesis Testing for p1 and p2 : Independent samples . . . . . . . . . . . . . . . . . 117
75) F Distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
75).1 Definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
75).2 Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
75).3 F Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
76) Inference on ratio of population variances σ22 /σ12 : Independent samples . . . . . . . . . . . 121
76).1 Confidence Interval (CI) σ22 /σ12 : Independent samples . . . . . . . . . . . . . . . . . . . 121
76).2 Hypothesis Testing for σ22 /σ12 : Independent samples . . . . . . . . . . . . . . . . . . . 122
77) Inference on µ1 and µ2 : Dependent samples (Matched-pairs) . . . . . . . . . . . . . . . . . . 125
77).1 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
77).2 Hypothesis Testing for µ1 and µ2 : Dependent samples (Matched-pairs) . . . . . . . 127
78) One-way analysis of variance (ANOVA) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
vi
List of Tables
vii
STATISTICS OVERVIEW
Page 1 of 160
STATISTICS OVERVIEW
A statistical table can be used to display data graphically as a data distribution, consists of Class, Class Frequency,
Relative Frequency or Percentage.
For qualitative data, three measurements are available for the list of categories:
− the frequency, or number of measurements
− the relative frequency, or proportion = frequency / Total number of observations
− the percentage
A pie chart is the familiar circular graph that shows how the measurements are distributed among the categories.
A bar chart shows the same distribution of measurements in categories, with the height of the bar measuring how
Page 2 of 160
STATISTICS OVERVIEW
Example: The following Table lists the prices (in dollars) of 19 different brands of walking shoes.
Construct a tem and leaf plot to display the distribution of the data.
90 70 70 70 75 70
65 68 60 74 70 95
75 70 68 65 40 65
70 70 68 65 40 65
Solution
Page 3 of 160
STATISTICS OVERVIEW
We can use stem and leaf diagrams to calculate averages like the median, the mode and the mean, and to calculate
measures of spread like the range and the interquartile range.
Comparing data sets is simplified by using a dual stem and leaf diagram which have two sets of data represented
back to back.
Example: Two sets of data showing test scores of 20 males and 20 females.
Solution
Female Male
0 6 7 0 1 4 5
1 2 4 8 8 9 1 0 2 3 4 4 8
2 4 5 5 5 6 6 2 2 7 7 9
3 0 1 2 3 3 3 6 3 0 0 0 3 6 8
4 4 0
By combining them together to form one dual stem and leaf diagram, we can directly compare the two sets of
data.
Female Male
7 6 0 1 4 5
9 8 8 4 2 1 0 2 3 4 4 8
6 6 5 5 5 4 2 2 7 7 9
5 3 3 3 2 1 0 3 0 0 0 3 6 8
4 0
The data must be closely related for it to be compared effectively on the diagram.
Note
The digits in the leaf for Females is still in ascending order but from right to left, rather than left to right. Also,
the key represents the data values for each side of the stem and leaf diagram.
2).2 Histogram
A histogram for a quantitative data set is a graph that describes the relative frequency (or frequency) of the variable in
which the possible values of the variable are divided into a few groups (classes, or intervals), the relative frequency (or
frequency) is represented by a rectangle with the height representing the proportion or relative frequency of occurrence
for a particular class (or group) of the variable being measured. And these rectangles should touch each other.
On the X axis: The class, (or group) of the variable are plotted along the x axis.
On the Y -axis: The relative frequency or frequency of observations within the class is the height on the Y axis.
Page 4 of 160
STATISTICS OVERVIEW
Note
Different methods may be used in different software. Some may use right inclusion. Some may add an addi-
tional decimal place for the class boundary.
5. Construct a statistical table containing the classes, their boundaries, and their relative frequencies
6. Construct the histogram like a bar graph with the rectangle height = relative frequency of the class / class width
Example: The following Table lists the prices (in dollars) of 19 different brands of walking shoes.
Construct a relative histogram to display the distribution of the data.
90 70 70 70 75 70 65 68 60 74 70 95 75 70 68 65 40 65 70
Solution
Page 5 of 160
STATISTICS OVERVIEW
A parameter is a descriptive measure of a population. In most real world cases, the population parameter is not
known. For example, the average gas price in the whole nation.
A statistic is a descriptive measure of a sample. We use statistic to estimate the corresponding parameter. For example,
Average gas price of the nation is not known. However, we can take a random sample of 100 stations and compute the
sample average gas price, then use the sample average to estimate the unknown population average.
The population mean, is computed using all the individuals in a population, the total number of all individuals is N .
The population mean is a parameter
P
x1 + x2 + .... + xN xi
µ= = (1..1)
N N
Note
In real world applications, population mean µ is usually not known, and is estimated by using sample mean x̄
Solution
The median of a variable is the value that lies in the middle of the data when arranged in ascending order. That is, half
the data is below the median and half the data is above the median. We use m to represent the median.
Page 6 of 160
STATISTICS OVERVIEW
n+1
If is NOT an integer ⇒ n is EVEN: the median is the average of the two data values on either side of the
2
n+1
observations that lies in the position.
2
The mode of a variable is the most frequent observation of the variable that occurs in the data set
If there are two values that occur with the most frequency, we say the data has is bimodal.
Example: Find the median and the mode of the following pulse rate data
80 76 65 68 72 73 65 80 100
Solution
1. Arrange the data in ascending order:
65 65 68 72 73 76 80 80 100
2. Number of observations n = 9 ⇒ n is odd
n+1 9+1
3. Position of median = = = 5 ⇒ median = 73
2 2
Modes are 65 and 80
Qualitative data:
− Cannot add or order them … the mean and median do not exist
− The mode is the only one of these three measurements that exists
3).1 Comparison of Mean, Median, and Mode for different shapes of distributions
3).2 Percentiles
The pth percentile of a data set is a value such that at least p percent of the items take on this value or less and at least
(100 − p) percent of the items take on this value or more.
p
i=( )n (1..3)
100
3. If i is NOT an integer, round up. The pth percentile is the value in the ith position.
4. If i is an integer, the pth percentile is the average of the values in positions i and i + 1.
Page 7 of 160
STATISTICS OVERVIEW
3).3 Quartiles
Quartiles are specific percentiles.
First Quartile = 25th Percentile
Second Quartile = 50th Percentile = Median
Third Quartile = 75th Percentile
4) Measure of Variability
Five different measures of variability: Range, Variance, Standard Deviation (σ), Interquartile Range (IQR), Coeffi-
cient of Variation
Measures of variability measure the degree that the data values spread. The larger the data values spread, the larger
the variation of the data values.
Note
The divider (n − 1) is called the Degrees of Freedom.
The population variance is symbolically represented by lower case Greek sigma squared.
Page 8 of 160
STATISTICS OVERVIEW
possible outlier.
If the distribution is mounded-shaped, there is less than 1% of chance to have z-score outside [−3, 3], Therefore, it is
probably an outlier
Page 9 of 160
STATISTICS OVERVIEW
2. PROBABILITY
5) Overview of Probability
6) Set Theory
The union The intersection Mutually exclusive
Characteristics The union of two events A The set of all outcome ω in Mutually exclusive events
and B is the set of all both events. cannot occur at the same
outcomes ω in either event or time.
both.
Notation A∪B = {ω : ω ∈ A∨ω ∈ B} A∩B = {ω : ω ∈ A∧ω ∈ B} A∩B =∅
Venn diagram
7) Complementary Events
The complement of an event is the set of the outcomes not included in the event, but still part of the sample space
The complement of A is denoted by A or AC or A′ :
AC = {ω : ω ∈
/ A ∧ ω ∈ S}
Page 10 of 160
STATISTICS OVERVIEW
(A ∪ B)C = AC ∩ B C
(2..1)
(A ∩ B)C = AC ∪ B C
8) Kolmogorov Axioms
Note
8).1 Properties
These three properties are usually referred to as the Axioms of Probability. Any function P satisfies the Axioms of
Probability is called a probability function. Other nice properties can be derived simply by using them.
P (∅)= 0
If A ⊆ B ⇒ P (A) ≤ P (B)
P (A) = 1 − P (AC )
Additive law: If events A and B intersect, you have to subtract out the “double count”
Page 11 of 160
STATISTICS OVERVIEW
9) Equiprobability Model
Suppose that a sample space S contains nS < ∞ outcomes, each of which is equally likely. If the event A contains
nA outcomes, then
nA
P (A) = (2..5)
nS
WARNING: If the outcomes in S are not equally likely, then this result is not applicable.
For equal likelihood probability model, the probability of event A depends on the size of A, i.e., the number of ele-
ments in A, which is denoted by nA .
Recall that if an experiment can result in any one of N different, but equally likely, outcomes and if exactly n of these
outcomes corresponds to event A, then the probability of event A is
nA n
P (A) = = (2..6)
nS N
Consider selecting an element from a set having m elements and selecting another from a set having n elements. Then
there are m × n possible pairs that could be selected.
Example: There are 5 processes needed to manufacture the side panel for a car: clean, press, cut, paint, polish. Our
plant has 6 cleaning stations, 3 pressing stations, 8 cutting stations, 5 painting stations, and 8 polishing stations.
(a) How many possible different “pathways” through the manufacturing exist?
(b) What is the number of “pathways” that include a particular pressing station?
(c) Assuming stations are chosen randomly, what is the probability that a panel follows any particular path?
(d) Assuming stations are chosen randomly, what is the probability that a panel goes through pressing station 1?
Solution
Page 12 of 160
STATISTICS OVERVIEW
n!
n Pr = Prn = Pr,n = n × (n − 1) × (n − 2) × ... × (n − r + 1) = (2..7)
(n − r)!
Solution
n! 10! 10!
Number of arrangements = P610 = = = = (10)(9)(8)(7)(6)(5) = 151200
(n − r)! (10 − 6)! 4!
Example: Let there be 10 people and suppose we want to obtain a sample of size 5 from this group, with the order in
which they are included not important. How many number of possible samples?
Solution
12).3 Relationship
n!
n Pr =
(n − r)!
n!
n Cr =
r!(n − r)!
=⇒n Cr × r! =n Pr
Reason: Once we have chosen r objects, there are r! ways to permute those r objects
Example: Counting Methods
9 out of 100 computer chips are defective. We choose a random sample of n = 3
(a) How many different samples of 3 are possible?
(b) How many of the samples of 3 contain exactly 1 defective chip?
(c) What is the probability of choosing exactly 1 defective chip in a random sample of 3? (This is called hypergeometric
distribution later).
(d) What is the probability of choosing at least 1 defective chip in a random sample of 3? (Hint: it is easier to calculate
the probability of choosing no defective chip.)
Solution
Page 13 of 160
STATISTICS OVERVIEW
9 (91)(90)
↔ n1 = × = 36855
1 (2)(1)
(c) X = number of defective chip in a random sample of 3
C 9 × C 91 n1 36855 351
P (X = 1) = 1 100 2 = = = ≈ 0.23
C3 N 161700 1540
C 91 121485 1157
(d) P (X = 0) = 3 = =
N 161700 1540
1157 383
⇒ P (X ≥ 1) = 1 − P (X = 0) = 1 − = ≈ 0.25
1540 1540
Example: What is the probability of getting 4 or 5 heads when tossing a fair coin 10 times?
This problem will be solved using binomial distribution (*)
Solution
1
Probability of getting heads: p =
2
X = number of heads
! when tossing a fair coin
10 1 10 10! 1 10! 1 (10)(9)(8)(7) 1
P (X = 4) = ( ) = × ( )10 = × ( )10 = × ( )10 ≈ 0.205
4 2 4!(10 − 4)! 2 4!6! 2 (4)(3)(2)(1) 2
!
10
10 1 10! 1 10! 1 (10)(9)(8)(7)(6) 1
P (X = 5) = ( ) = × ( )10 = × ( )10 = × ( )10 ≈ 0.246
5 2 5!(10 − 5)! 2 5!5! 2 (5)(4)(3)(2)(1) 2
⇒ P (X = 4 ∪ X = 5) = P (X = 4) + P (X = 5) − P (X = 4 ∩ X = 5)
Since P (X = 4) and P (X = 5) are mutually exclusive ⇒ P (X = 4 ∩ X = 5) = 0
⇒ P (X = 4 ∪ X = 5) = P (X = 4) + P (X = 5) = 0.205 + 0.246 = 0.451
Example: A university warehouse has received a shipment of 25 printers, of which 10 are laser printers and 15 are
inkjet models. If 6 of these 25 are selected randomly to be checked by a technician, what is the probability that exactly
3 of those selected are laser printers?
Solution
10! 15!
×
C310 × C315 3!(10 − 3)! 3!(15 − 3)! 78
X = number of chosen laser printers ⇒ P (X = 3) = = = ≈ 0.31
C625 25! 253
6!(25 − 6)!
A conditional probability is the probability that an event will occur, when another event is known to occur or to have
occurred
Definition: Let A and B be events in a sample space S with P (B) > 0. The conditional probability of A, given that B
has occurred, is
P (A ∩ B)
P (A|B) = (2..9)
P (B)
The Venn diagram representation:
Page 14 of 160
STATISTICS OVERVIEW
Multiplication rule:
P (A ∩ B) = P (A|B) × P (B) (2..10)
P (A ∩ S) P (A) P (A)
P (A|B) = P (A|S) = = = = P (A) (2..11)
P (S) P (S) 1
If B ̸= S, then we can understand the conditional probability in this informal way: we are only interested in the
probability of event A when event B has occurred. So, we manually “shrink” the sample space S to be B so that we can
calculate the probability of A in the restricted space with the scale of B.
Example: In a company, 36 percent of the employees have a degree from a SEC university, 22 percent of the employees
that have a degree from the SEC are also engineers, and 30 percent of the employees are engineers. An employee is
selected at random.
(a) Compute the probability that an employee is an engineer and is from the SEC.
(b) Compute the conditional probability that an employee is from the SEC, given that s/he is an engineer.
Solution
Solution
Page 15 of 160
STATISTICS OVERVIEW
In both examples, the conditional probability P (B|A) and the unconditional probability P (B) are NOT equal. In other
words, knowledge that A “has occurred” has changed the likelihood that B occurs.
In other situations, it might be that the occurrence (or non-occurrence) of a companion event has no effect on the prob-
ability of the event of interest. This leads us to the definition of independence
14) Independence
Definition: Two events are independent if any one of the following equivalent statement is true:
P (A|B) = P (A)
P (B|A) = P (B)
P (A ∩ B) = P (A)P (B)
Example: An electronics store sells three different brands of DVD players. Of its DVD player sales, 50% are brand
1 (the least expensive), 30% are brand 2, and 20% are brand 3. Each manufacturer offers a 1-year warranty on parts
and labor. It is known that 25% of brand 1’s DVD players require warranty repair work, whereas the corresponding
percentages for brands 2 and 3 are 20% and 10%, respectively.
(a) What is the probability that a randomly selected purchaser has bought a brand 1 DVD player that will need repair
while under warranty?
(b) What is the probability that a randomly selected purchaser has a DVD player that will need repair while under
warranty?
(c) If a customer returns to the store with a DVD player that needs warranty repair work, what is the probability that it
is a brand 1 DVD player? A brand 2 DVD player? A brand 3 DVD player?
Solution
Page 16 of 160
STATISTICS OVERVIEW
Example: It is known that 30% of a certain company’s washing machines require service while under warranty, whereas
only 10% of its dryers need such service. If someone purchases both a washer and a dryer made by this company, what
is the probability that both machines will need warranty service?
Solution
Let A = washing machine require service while under warranty ⇒ P (A) = 0.3
B = dryer need service while under warranty ⇒ P (B) = 0.1
Since A and B are independent events ⇒ P (A ∩ B) = P (A)P (B) = 0.3 × 0.1 = 0.03
Solution
Note
15) Partition
Definition: For some positive integer k, the collection of sets {B1 , B2 , ..., Bk } forms “a” partition of S if:
(i)S = B1 ∪ B2 ∪ ... ∪ Bk
(2..12)
(ii)Bi ∩ Bj = ∅, for i ̸= j
Note
For any subset A of S and any partition {B1 , B2 , ..., Bk } of S, we can decompose A as:
Page 17 of 160
STATISTICS OVERVIEW
A = A ∪ S = A ∪ (B1 ∪ B2 ∪ ... ∪ Bk )
A = A ∪ S = (A ∩ B1 ) ∪ (A ∩ B2 ) ∪ ... ∪ (A ∩ Bk )
A = A ∪ S = P (A ∩ B1 ) + P (A ∩ B2 ) + ... + P (A ∩ Bk )
A = A ∪ S = P (A|B1 )P (B1 ) + P (A|B2 )P (B2 ) + ... + P (A|Bk )P (Bk )
Pk
A=A∪S = i=1 P (A|Bi )P (Bi )
Solution
Example:
(a) We purchase 30% of our parts from Vendor A. Vendor A’s defective rate is 5%. What is the probability that a randomly
chosen part is a defective part from Vendor A? (b) We are manufacturing widgets. 50% are red and 30% are white. What
is the probability that a randomly chosen widget will not be white?
Solution
Example: When a computer goes down, there is a 75% chance that it is due to overload and a 15% chance that it is
due to a software problem. There is an 85% chance that it is due to an overload or a software problem. What is the
probability that both of these problems are at fault?
Solution
Example: It has been found that 80% of all accidents at foundries involve human error and 40% involve equipment
malfunction. 35% involve both problems. If an accident involves an equipment malfunction, what is the probability
that there was also human error?
Solution
Page 18 of 160
STATISTICS OVERVIEW
Example: Consider the following electrical circuit: The probability on the components is their reliability (probability
that they will operate). Components are independent of each other. What is the probability that the circuit will not
operate when the switch is thrown?
Solution
P (circuit) = P (A ∩ B ∩ C)
Since A, B and C are independent ⇒ P (A ∩ B ∩ C) = P (A)P (B)P (C)
If the circuit doesn’t operate ⇒ P (circuit fails) = P (AC )P (B C )P (C C ) = (1 − 0.95)(1 − 0.95)(1 − 0.95) =
0.000125
Note
The probability of each component operating (reliability) and Components are independent.
The probability of the circuit not operating is the complement of the probability of the circuit operating.
In a series circuit, all components must operate for the circuit to operate.
1. Define the probability of a component failing
The probability of a component failing is 1 minus the probability of it operating.
Let pi be the probability of component i operating.
The probability of component i failing is 1 − pi .
2. Calculate the probability of all components failing
Since the components are independent, the probability of all components failing is the product of their individual
probabilities of failing.
If there are n components, the probability of all failing is: P (circuit fails) = P (all components fail)
The probability that the circuit will not operate is equal to the probability that all components fail
n
Y
P (circuit fails) = (1 − pi ) (2..16)
i=1
Example: Consider the electrical circuit below. Probabilities on the components are reliabilities and all components
are independent. What is the probability that the circuit will work when the switch is thrown?
Solution
Page 19 of 160
STATISTICS OVERVIEW
Note
The circuit works if either the upper or lower branch works (or both).
Example: An insurance company classifies people as ‘accident-prone’ and ‘nonaccident-prone’. For a fixed year, the
probability that an accident-prone person has an accident is 0.4, and the probability that a non-accident-prone person
has an accident is 0.2. The population is estimated to be 30 percent accident-prone. Define the events
A = {policy holder has an accident}
B = {policy holder is accident-prone}
We are given that P (B) = 0.3, P (A|B) = 0.4, and P (A|B C ) = 0.2.
(a) What is the probability that a new policy-holder will have an accident?
(b) Suppose that the policy-holder does have an accident. What is the probability that s/he is ‘accident-prone’?
Solution
(a) Law of Total Probability: P (A) = P (A|B)P (B) + P (A|B C )P (B C ) = P (A|B)P (B) + P (A|B C )[1 − P (B)]
⇒ P (A) = (0.4)(0.3) + (0.2)(1 − 0.3) = 0.26
P (B ∩ A) P (A|B)P (B) (0.4)(0.3)
(b) P (B|A) = = = ≈ 0.462
P (A) P (A) 0.26
Solution
It seems that there are two different ways to calculate with R. One code may result in an error.
1 > choose ( 3 6 5 , 48) ∗ f a c t o r i a l ( 4 8 ) / 365ˆ48
2 > f a c t o r i a l (365) / (365ˆ48 ∗ f a c t o r i a l (365 −48) )
Page 20 of 160
STATISTICS OVERVIEW
Definition: A random variable is a function from a sample space S into the real numbers. We usually denote ran-
dom variables with uppercase letters, e.g., X, Y, ...
X:S→R
Examples:
Experiment: toss a coin 2 times, Random variable: X = number of heads in 2 tosses
Experiment: toss 10 dice, Random variable: X = sum of the numbers
Experiment: apply different amounts of fertilizer to corn plants, Random variable: X = yield/acre
Note
Page 21 of 160
STATISTICS OVERVIEW
FY (y) = P (Y ≤ y) (3..2)
FY (y) = P (Y ≤ y) is read, ‘the probability that the random variable Y is less than or equal to the value y.’
limy→−∞ FY (y) = 0
limy→∞ FY (y) = 1
Right continuous limy→a+ FY (y) = FY (a)
Non-decreasing y1 ≤ y2 =⇒FY (y1 ) ≤ FY (y2 )
Solution
Page 22 of 160
STATISTICS OVERVIEW
S1 S2 S3 S1 S2 S3 S1 S2 S3 S1 S2 S3 S1 S2 S3 S1 S2 S3 S1 S2 S3 S1 S2 S3
0.84645 0.00045 0.00095 0.00495 0.00855 0.04455 0.09405 0.00005
Let Y = Number of components within specification in a randomly chosen assembly
(a) Probability Mass Function (pmf):
P (Y = 0) = P (S1 S2 S3 ) = 0.00005
P (Y = 1) = P (S1 S2 S3 ) + P (S1 S2 S3 ) + P (S1 S2 S3 ) = 0.00045 + 0.00095 + 0.00495 = 0.00635
P (Y = 2) = P (S1 S2 S3 ) + P (S1 S2 S3 ) + P (S1 S2 S3 ) = 0.00855 + 0.04455 + 0.09405 = 0.14715
P (Y = 3) = P (S1 S2 S3 ) = 0.84645
Y 0 1 2 3
P (Y = y) 0.00005 0.00635 0.14715 0.84645
(b) Cummulative Distribution Function (cdf):
FY (y) = P (Y ≤ 0) = P (Y = 0) = 0.00005, when y ≤ 0
FY (y) = P (Y ≤ 1) = P (Y = 0) + P (Y = 1) = 0.00005 + 0.00635 = 0.0064, when 0 < y ≤ 1
FY (y) = P (Y ≤ 2) = P (Y = 0) + P (Y = 1) + P (Y = 2) = 0.00005 + 0.00635 + 0.14715 = 0.15355, when
1<y≤2
FY (y) = P (Y ≤ 3) = P (Y = 0) + P (Y = 1) + P (Y = 2) + P (Y = 3) = 0.00005 + 0.00635 + 0.14715 +
0.84645 = 1 when y > 3
Y 0 1 2 3
P (Y ≤ y) 0.00005 0.0064 0.15355 1
Example: Consider whether the next person buying a computer at a certain electronics store buys a laptop or a desktop
model. We denote X = 1 if the customer purchases a desktop and X = 0 if the customer purchases a laptop. Suppose
that 20% of all purchases during that week select a desktop
Specify the pmf and cdf of X
Solution
P (X = 1) = 0.2
P (X = 0) + P (X = 1) = 1 ↔ P (X = 0) = 1 − P (X = 1) = 0.8
0.8, if x = 0
Probability mass function: pX (x) = P (X = x) =
0.2, if x = 1
0.8, if x ≥ 0
Cummulative distribution function: FX (x) = P (X ≤ x) =
1, if 0 < x ≤ 1
Page 23 of 160
STATISTICS OVERVIEW
The expected value for a discrete random variable Y is simply a weighted average of the possible values of Y . Each
value y is weighted by its probability pY (y).
In statistical applications, µ = E(Y ) is commonly called the population mean
Note
X is symmetry about µ
Note
The expected value can be interpreted as the long-run average
Solution
The pmf of Y :
Y 0 1 2 3
P (Y = y) 0.00005 0.00635 0.14715 0.84645
The expected value of Y is:
P
µ = E(Y ) = all y ypY (y) = 0(0.00005) + 1(0.00635) + 2(0.14715) + 3(0.84645) = 2.84
If we randomly choose an assembly, and record the number of components within specification. Over the long
run, the average of these Y observation would be close (converge) to 2.84.
Theorem: Let Y be a discrete random variable with pmf pY (y). Let g be a real-valued function defined on the range of
Y . The expected value or expectation of g(Y ) is defined as
X
E[g(Y )] = g(y)PY (y) (3..6)
all y
Interpretation: The expectation E[g(Y )] could be viewed as the weighted average of the function g when evaluated
at the random variable Y
Properties of Expectation
Let Y be a discrete random variable with pmf pY (y). Suppose that g1 , g2 , ..., gk are real-valued functions, and let c be a
real constant. The expectation of Y satisfies the following properties:
Page 24 of 160
STATISTICS OVERVIEW
E(c) = c (c = constant)
E(cY ) = cE(Y )
Pk Pk
Linearity: E{ j=1 gj (Y )} = j=1 E{gj (Y )}
Note
The 2nd and 3rd rule together imply that
Xk k
X
E{ cj gj (Y )} = cj E{gj (Y )} for constant cj (3..7)
j=1 j=1
Solution
The pmf of Y :
Y 0 1 2 3
P (Y = y) 0.00005 0.00635 0.14715 0.84645
2 2
g(Y ) = (3 − Y ) = Y − 6Y + 9
The expected cost: E[g(Y )] = E[Y 2 − 6Y + 9] = E[Y 2 ] − 6E[Y ] + 9
The expected value of Y 2 : E(Y 2 ) = all y y 2 pY (y) = (02 )(0.00005)+(12 )(0.00635)+(22 )(0.14715)+(32 )(0.84645)
P
⇒ E(Y 2 ) = 8.213
⇒ The expected cost: E[g(Y )] = E[Y 2 ] − 6E[Y ] + 9 = 8.213 − 6(2.84) + 9 = 0.173
⇒ On average, the repair cost on each assembly is $0.173
Project A B C
Probability of accept 0.30 0.80 0.10
Probabilty of reject 0.70 0.20 0.90
Y 0 1 2 3
pY (y) 0.126
Solution
(a) Since the projects are independent of one another ⇒ P (Y = 3) = P (A ∩ B ∩ C) = P (A)P (B)P (C)
↔ P (Y = 3) = (0.30)(0.80)(0.10) = 0.024
(b) Since the projects are independent of one another ⇒ P (Y = 0) = P (Ā ∩ B̄ ∩ C̄) = P (Ā) ∩ P (B̄) ∩ P (C̄)
↔ P (Y = 0) = (0.7)(0.2)(0.9) = 0.126
P (Y ≥ 1) = 1 − P (Y = 0) = 1 − 0.126 = 0.874
Page 25 of 160
STATISTICS OVERVIEW
(c) P (Y = 1) = P (A)P (B̄)P (C̄) + P (Ā)P (B)P (C̄) + P (Ā)P (B̄)P (C)
⇒ P (Y = 1) = (0.30)(0.20)(0.90) + (0.70)(0.80)(0.90) + (0.70)(0.20)(0.10) = 0.572
P (Y = 2) = P (A)P (B)P (C̄) + P (A)P (B̄)P (C) + P (Ā)P (B)P (C)
⇒ P (Y = 2) = (0.30)(0.80)(0.90) + (0.30)(0.20)(0.10) + (0.70)(0.80)(0.10) = 0.278
Y 0 1 2 3
pY (y) 0.126 0.572 0.278 0.024
Expected number of project accepted: E(Y ) = 0(0.126) + 1(0.572) + 2(0.278) + 3(0.024) = 1.2
Note
Definition: The standard deviation of Y is the positive square root of the variance:
√
(3..9)
p
σ= σ2 = var(Y )
Note
Properties
Suppose X and Y are random variable with finite variance. Let c be a constant.
var(c) = 0
var(cX) = c2 var(X)
Suppose X and Y are independent, then
Example: The pmf of the number X of DVD’s checked out was given p(X = 1) = 0.3, p(X = 2) = 0.25, p(X = 3) =
0.15, p(X = 4) = 0.05, p(X = 5) = 0.1, and p(X = 6) = 0.15.
Compute E(X) and var(X).
Solution
P
E(X) = all x xPX (x) = 1(0.3) + 2(0.25) + 3(0.15) + 4(0.05) + 5(0.1) + 6(0.15) = 2.85
E(X 2 ) = all x x2 PX (x) = (12 )(0.3) + (22 )(0.25) + (32 )(0.15) + (42 )(0.05) + (52 )(0.1) + (62 )(0.15) = 11.35
P
Page 26 of 160
STATISTICS OVERVIEW
Definition: Many experiments can be envisioned as consisting of a sequence of “trials,” a trial is called Bernoulli trial if
a trial results in a “success” (1) or “failure” (0)
trials are independent
the probability of a “success” in each trial, denoted as p, 0 < p < 1, is the same on every trial, i.e., identical.
Example: Each sample of water has a 10% chance of containing a particular organic pollutant. Assume that the samples
are independent with regard to the presence of the pollutant.
Solution
Example: Ninety-eight percent of all air traffic radar signals are correctly interpreted the first time they are transmitted.
Solution
Example: When circuit boards used in the manufacture of Blue Ray players are tested, the long-run percentage of
defective boards is 5 percent.
Solution
Variance:
var(X) = p(1 − p) = pq (3..13)
Page 27 of 160
STATISTICS OVERVIEW
Notation: Y ∼ B(n, p)
The pmf of Y :
n
py (1 − p)n−y , for y = 0, 1, 2, ..., n
p(y) = y (3..14)
otherwise
0,
!
n
Recall that is the number of ways to choose r distinct unordered objects from n distinct objects
y
!
n n!
=
y r!(n − r)!
Solution
X = number of defective
! filters !
n 5 5!
(a) P (X = 0) = py (1 − p)n−y = (0.05)0 (1 − 0.05)5−0 = (0.95)5 = 0.7738
y 0 0!(5 − 0)!
! !
n 5 5!
(b) P (X = 1) = py (1 − p)n−y = (0.05)1 (1 − 0.05)5−1 = (0.05)(0.95)4 = 0.2036
y 1 1!(5 − 1)!
! !
n 5 5!
(c) P (X = 2) = py (1 − p)n−y = (0.05)2 (1 − 0.05)5−2 = (0.0025)(0.95)3 = 0.0214
y 2 2!(5 − 2)!
Variance:
var(Y ) = np(1 − p) = npq (3..16)
Page 28 of 160
STATISTICS OVERVIEW
recommended?
Solution
1
E(Y ) = (3..18)
p
Page 29 of 160
STATISTICS OVERVIEW
The variance of Y is
1−p
var(Y ) = (3..19)
p2
Example: Wafer
The probability that a wafer contains a large particle of contamination is 0.01. It is assumed that the wafers are inde-
pendent.
(a) What is the probability that exactly 125 wafers need to be analyzed until a large particle is detected?
(b) How many wafers need to be analyzed until a large particle is detected on average?
Solution
1 > dgeom ( 1 2 5 , 0 . 0 1 )
2 [1] 0.002847078
Solution
1 > dgeom ( 4 , 0 . 2 5 )
2 [1] 0.07910156
3 > pgeom ( 2 , 0 . 2 5 )
4 [1] 0.578125
Page 30 of 160
STATISTICS OVERVIEW
The negative binomial distribution also arises in experiments involving Bernoulli trial:
each trial results in a “success” or “failure”;
the trials are independent;
the probability of a “success” in each trial, denoted as p, 0 < p < 1, is the same on every trial.
Definition: Suppose that Bernoulli trials are continually observed
Y = the number of trials to observe the r-th success.
We say that Y has a negative binomial distribution with waiting parameter r and success probability p.
Notation: Y ∼ N B(r, p). The negative binomial distribution is a generalization of the geometric distribution.
If r = 1, then N B(1, p) = geom(p)
If Y ∼ N B(r, p), then the probability mass function of Y is given by
y − 1
pr (1 − p)y−r , y = r, r + 1, r + 2, ...
pY (y) = r−1 (3..22)
otherwise
0
Solution
y−1 r 10−1 9! 9!
pY (y) = Cr−1 p (1 − p)y−r = C3−1 (0.25)3 (1 − 0.25)10−3 (0.25)3 (0.75)7 = (0.25)3 (0.75)7 =
2!(9 − 2)! 2!7!
0.075
1 > dnbinom ( 7 , 3 , 0 . 2 5 )
2 [1] 0.07508469
Page 31 of 160
STATISTICS OVERVIEW
Solution
x+r−1 r 7+3−1 9!
pX (x) = Cr−1 p (1 − p)x = C7−1 (0.25)3 (1 − 0.25)7 = (0.25)3 (1 − 0.25)7 = 0.075
2!(9 − 2)!
1 > dnbinom ( 7 , 3 , 0 . 2 5 )
2 [1] 0.07508469
Suppose we have a bowl containing N balls, r of which are red and N − r of which are black. We draw n(< N )
balls out (without replacement). Our random variable of interest Y is the number of sampled balls that are red. Then Y
has a hypergeometric distribution. Define
Y = the number of success (out of the n selected)
We say that Y has a hypergeometric distribution and write Y ∼ hyper(N, n, r).
The pmf of Y :
r N − r
y n − y N −r
Cry × Cn−y
, 0 ≤ y ≤ r, 0 ≤ n − y ≤ N − r where y = 0, 1, 2, , ...n
=
p(y) = N CnN (3..26)
n
otherwise
0,
Page 32 of 160
STATISTICS OVERVIEW
Solution
100! 200!
C4100 C0200 ( )( )
(a) pY (y) = P (Y = 4) = = 4!96! 200! = 0.0119
C4300 300!
4!296!
100! 200! 100! 200!
C0100 C4200 C1100 C3200 ( )( )+( )( )
(b) pY (y) = P (Y < 2) = P (Y = 0)+P (Y = 1) = + = 0!100! 4!196! 1!99! 3!197!
C4300 C4300 300!
4!296!
⇒ pY (y) = P (Y < 2) = 0.593
⇒ pY (y) = P (Y ≥ 2) = 1 − P (X < 2) = 1 − 0.593 = 0.407
Example: Generator
If a shipment of 100 generators contains 5 faulty generators, what is the probability that we select 10 generators from
the shipment and get a faulty one?
Solution
5! 95!
C15 C995 ( )( )
pY (y) = P (Y = 1) = = 1!4! 9!86! = 0.339
100
C10 100!
10!90!
Example: Five individuals from an animal population thought to be near extinction in a certain region have been
caught, tagged, and released to mix into the population. After they have had an opportunity to mix, a random sample of
10 of these animals is selected. Let X be the number of tagged animals in the second sample. Suppose there are actually
25 animals of this type in the region.
What is the probability that exactly two of the animals in the second are tagged
Solution
5! 20!
C25 C820 ( )( )
pX (x) = P (X = 2) = = 2!3! 8!12! = 0.385
C1025 25!
10!15!
Page 33 of 160
STATISTICS OVERVIEW
2 [1] 0.01185408
What is the probability that two or more parts in the sample are from the local supplier?
P (X ≥ 2) = 1 − P (X ≤ 1) = 1 − 0.593, where P (X ≤ 1) can be computed via R:
1 > phyper ( 1 , 1 0 0 , 2 0 0 , 4 )
2 [1] 0.5925943
Variance:
var(Y ) = λ (3..31)
Solution
Page 34 of 160
STATISTICS OVERVIEW
Example:
(a) Suppose we average 5 radioactive particles passing a counter in 1 millisecond. What is the probability that exactly 3
particles will pass in one millisecond?
(b) Suppose we average 5 radioactive particles passing a counter in 1 millisecond. What is the probability that exactly
10 particles will pass in three milliseconds?
Solution
λ3 e−λ 53 e−5
(a) P (X = 3) = = = 0.14
3! 3!
(b) 1 millisecond: λ = 5
3 milliseconds: λ = 15
λ10 e−λ 1510 e−15
P (X = 10) = = = 0.0486
10! 10!
1 > dpois ( 3 , 5 )
2 [1] 0.1403739
3 > dpois (10 , 15)
4 [1] 0.04861075
Example: Let X denote the number of traps in a particular type of metal oxide semiconductor transistor, and suppose
it has a Poisson distribution with λ = 2.
(a) What is the probability that there are exactly three traps?
(b) What is the probability that there are at most three traps?
Solution
λ3 e−λ 23 e−2
(a) P (X = 3) = = = 0.18
3! 3!
λ0 e−λ λ1 e−λ λ2 e−λ λ3 e−λ
(b) P (X ≤ 3) = P (X = 0) + P (X = 1) + P (X = 2) + P (X = 3) = + + +
0! 1! 2! 3!
20 e−2 21 e−2 22 e−2 23 e−2
⇒ P (X ≤ 3) = + + + = 0.857
0! 1! 2! 3!
1 > dpois (3 , 2)
2 [1] 0.180447
3 > dpois (0 , 2) + dpois (1 , 2) + dpois (2 , 2) + dpois (3 , 2)
4 [1] 0.8571235
Page 35 of 160
STATISTICS OVERVIEW
Page 36 of 160
STATISTICS OVERVIEW
A continuous random variable is one with an interval (either finite or infinite) of real numbers for its range
Example:
Let X = length in meter.
Let X = temperature in ◦ F .
Let X = time in seconds
Because the number of possible values of X is uncountably infinite, the probability mass function (pmf) is no longer
suitable.
For a continuous random variable, P (X = x) = 0, the reason for that will become clear shortly.
For a continuous random variable, we are interested in probabilities of intervals, such as P (a ≤ X ≤ b), where a and b
are real numbers.
We will introduce the probability density function (pdf) to calculate probabilities, such as P (a ≤ X ≤ b).
Every continuous random variable X has a probability density function (pdf), denoted by fX (x).
Probability density function fX (x) is a function such that
fX (x) ≥ 0 for in x ∈ R
R∞
−∞ fX (x) dx = 1
Rb
P (a ≤ X ≤ b) = a fX (x) dx which represents the area under fX (x) from a to b for any b > a
If x0 is a specific value, then P (X = x0 ) = 0. We assign 0 to area under a point
Let x0 be a specific value of interest, the cumulative distribution function (CDF) is defined via
Z x0
FX (x0 ) = P (X ≤ x0 ) = fX (x)dx (4..1)
−∞
Note
Page 37 of 160
STATISTICS OVERVIEW
Solution
10
R x2 R 10
P (0 ≤ X ≤ 10) = x1
f (x)dx = 0
0.05dx = 0.05x = (0.05)(10) − (0.05)(0) = 0.5
0
P (0 ≤ X ≤ 10) = P (0 ≤ X < 10) = 0.5
Solution
y
Ry y3
(a) For 0 < y < 1: fY (y) = 0
3y 2 dy = 3 = (y)3 − (0)3 = y 3
3 0
y ≤ 0 ⇒ fY (y) = 0
y ≥ 1 ⇒ fY (y) =
1
0 y≤0
⇒ CDF: FY (y) = y 3 0 < y < 1
1 y ≥ 1
0.3
R 0.3
(b) P (Y < 0.3) = P (0 < Y < 0.3) = 0
3y 2 dy = y 3 = (0.3)3 − 03 = 0.027
0
0.8
R 0.8
(c) P (0.3 ≤ Y ≤ 0.8) = 0.3
2
3y dy = y 3
= (0.8) − (0.3)3 = 0.485
3
0.3
Example: “Time headway” in traffic flow is the elapsed time between the time that one car finishes passing a fixed point
and the instant that the next car begins to pass that point. Let X denote the time headway for two randomly chosen
consecutive cars on a freeway during a period ofheavy flow. The pdf of X is
0.15e−0.15(x−0.5) x ≥ 0.5
fX (x) =
0 otherwise
What is the probability that headway time is at most 5 seconds?
Solution
R5
P (0.5 ≤ X ≤ 5) = 0.5
0.15e−0.15(x−0.5) dx
R5
u = −0.15(x − 0.5) ⇒ P (0.5 ≤ X ≤ 5) = − 0.5
0.15eu du = −e−0.15(x−0.5) − (−e−0.15(0.5−0.5) ) ≈ 0.491
Page 38 of 160
STATISTICS OVERVIEW
The mean (expectation) and variance can also be defined for a continuous random variable. Integration replaces sum-
mation in the calculation of expectation for a discrete random variable.
Recall that for a discrete random variable Y . The mean of Y is defined as
X
E(Y ) = µY = ypY (y)
all y
For a continuous random variable X. The mean of X is defined as
Z +∞
E(X) = µX = xfX (x)dx (4..3)
−∞
Theorem: Let X be a continuous random variable with pdf fX (x). Suppose that g is a real-valued function. Then, g(X)
is a random variable and Z +∞
E[g(X)] = g(x)fX (x)dx (4..4)
−∞
The population standard deviation of X is the positive square root of the variance
√
σ= σ2 (4..6)
The computing formula for variance is the same as the discrete case, i.e.,
Definition: A random variable Y is continuous if its cdf FY (y) is continuous for −∞ < y < ∞.
Suppose Y is a continuous random variable with cdf FY (y). Then pdf of Y is
d
fY (y) = FY (y) (4..8)
dy
Page 39 of 160
STATISTICS OVERVIEW
30) Percentiles
Definition: Let p be a number in [0, 1]. The 100p-th percentile of the distribution of a continuous random variable
Y , denoted by η(p), is defined by
Z η(p)
p = F {η(p)} = f (y)dy (4..10)
−∞
Definition: A continuous random variable X is said to have a uniform distribution on the interval [a, b] if the pdf
of X is 1
a≤x≤b
fX (x) = b − a (4..12)
0 otherwise
fX (x) = 2
0 otherwise
(a) What is the cdf of X?
(b) What is the median?
Solution
x
Rx 3 3 t3 3 x3 3 03 3 x3
(a) FX (x) = 0 2
(1 − t2
)dt = (t − ) = (x − ) − (0 − ) = x −
2 3 0 2 3 2 3 2 2
3 m 3
Rm 3 1 3 x 1 3 m 3 03 1
(b) Median F (m) = 0 (1 − x2 )dx = ⇒ (x − ) = ⇔ (m − ) − (0 − ) =
2 2 2 3 0 2 2 3 2 3 2
3 m3 1 3m − m3 1
⇒ m− = ⇔ = ⇒ 3m − m3 = 1 ⇒ −m3 + 3m − 1 = 0
2
2 2 2 2
m = −1.879
⇒ m = 1.532
m = 0.3473
Since 0 ≤ x ≤ 1 ⇒ 0 ≤ m ≤ 1 ⇒ m = 0.3473
fX (x) = 2
0 otherwise
Compute E(X) and var(X)
Page 40 of 160
STATISTICS OVERVIEW
Solution
1
3 1 3 x2 x4 3 12 14 3 02 04
Z
R1 3 2 3 3
E(X) = 0 2
x(1 − x )dx = x − x dx = ( − ) = ( − ) − ( − )=
2 0 2 2 4 0 2 2 4 2 2 4 8
Z 1 Z 1 3 5 1 3 5 3 5
3 3 3 x x 3 1 1 3 0 0 1
E(X 2 ) = x2 (1 − x2 )dx = x2 − x4 dx = ( − ) = ( − ) − ( − ) =
0 2 2 0 2 3 5 0 2 3 5 2 3 5 5
1 3 19
var(X) = E(X 2 ) − [E(X)]2 = − ( )2 = ≈ 0.0594
5 8 320
(x − µ)2
1 −
f (x) = √ e 2σ 2 , −∞ < x < ∞
2πσ
is a normal random variable with parameters µ and σ, where ∞ < µ < ∞ and σ > 0. Also
E(X) = µ
var(X) = σ 2
We use X ∼ N (µ, σ 2 ) to denote the distribution. If X ∼ N (0, 1), it is called the standard normal distribution.
Now our objective is to calculate probabilities (of intervals) for a normal random variable through R or normal proba-
bility table.
The plot of the pdfs of normal distributions with different parameter values:
CDF: The cdf of a normal random variable does not exist in closed form. Probabilities involving normal random variables
and normal quantiles can be computed numerically
Page 41 of 160
STATISTICS OVERVIEW
Inflection points at µ ± σ
Example: Strip of Wire
Assume that the current measurements in a strip of wire follow a normal distribution with a mean of 10 milliamperes
and a variance of 4 (milliamperes)2 . What is the probability that a measurement exceeds 13 milliamperes?
Solution
p √
σ = var(X) = 4 = 2
X −µ 13 − 10
Z= = = 1.5
σ 2
P (X > 13) = 1 − P (Z ≤ 13) = 1 − 0.9332 = 0.0668
Solution
(a) 5.7 = 6.2−0.5 = µ−σ ⇒ P (X > 5.7) = P (X > µ−σ) = 1−(X ≤ µ−σ) = 1−0.135−0.235−0.15 = 0.84
(b) 6.7 = 6.2 + 0.5 = µ − σ ⇒ P (X > 6.7) = P (X > µ + σ) = 0.16
X −µ
Z= (4..15)
σ
is a normal random variable with E(Z) = 0 and var(Z) = 1. That is, Z is called the standard normal random
variable
Creating a new random variable by this transformation is referred to as standardizing
Z is traditionally used as the symbol for a standard normal random variable
Φ(z) is commonly used to stand for the cdf of Z.
Page 42 of 160
STATISTICS OVERVIEW
Table entry for z is the area under the standard normal curve to the left of z
0.5 0.6915 0.6950 0.6985 0.7019 0.7054 0.7088 0.7123 0.7157 0.7190 0.7224
0.6 0.7257 0.7291 0.7324 0.7357 0.7389 0.7422 0.7454 0.7486 0.7517 0.7549
0.7 0.7580 0.7611 0.7642 0.7673 0.7704 0.7734 0.7764 0.7794 0.7823 0.7852
0.8 0.7881 0.7910 0.7939 0.7967 0.7995 0.8023 0.8051 0.8078 0.8106 0.8133
0.9 0.8159 0.8186 0.8212 0.8238 0.8264 0.8289 0.8315 0.8340 0.8365 0.8389
1.0 0.8413 0.8438 0.8461 0.8485 0.8508 0.8531 0.8554 0.8577 0.8599 0.8621
1.1 0.8643 0.8665 0.8686 0.8708 0.8729 0.8749 0.8770 0.8790 0.8810 0.8830
1.2 0.8849 0.8869 0.8888 0.8907 0.8925 0.8944 0.8962 0.8980 0.8997 0.9015
1.3 0.9032 0.9049 0.9066 0.9082 0.9099 0.9115 0.9131 0.9147 0.9162 0.9177
1.4 0.9192 0.9207 0.9222 0.9236 0.9251 0.9265 0.9279 0.9292 0.9306 0.9319
1.5 0.9332 0.9345 0.9357 0.9370 0.9382 0.9394 0.9406 0.9418 0.9429 0.9441
1.6 0.9452 0.9452 0.9474 0.9484 0.9495 0.9505 0.9515 0.9525 0.9535 0.9545
1.7 0.9554 0.9564 0.9573 0.9582 0.9591 0.9599 0.9608 0.9616 0.9625 0.9633
1.8 0.9641 0.9649 0.9656 0.9664 0.9671 0.9678 0.9686 0.9693 0.9699 0.9706
1.9 0.9713 0.9719 0.9726 0.9732 0.9738 0.9744 0.9750 0.9756 0.9761 0.9767
2.0 0.9772 0.9778 0.9783 0.9788 0.9793 0.9798 0.9803 0.9808 0.9812 0.9817
2.1 0.9821 0.9826 0.9830 0.9834 0.9838 0.9842 0.9846 0.9850 0.9854 0.9857
2.2 0.9861 0.9864 0.9868 0.9871 0.9875 0.9878 0.9881 0.9884 0.9887 0.9890
2.3 0.9893 0.9896 0.9898 0.9901 0.9904 0.9906 0.9909 0.9911 0.9913 0.9916
2.4 0.9918 0.9920 0.9922 0.9925 0.9927 0.9929 0.9931 0.9932 0.9934 0.9936
2.5 0.9938 0.9940 0.9941 0.9943 0.9945 0.9946 0.9948 0.9949 0.9951 0.9952
2.6 0.9953 0.9955 0.9956 0.9957 0.9959 0.9960 0.9961 0.9962 0.9963 0.9964
2.7 0.9965 0.9966 0.9967 0.9968 0.9969 0.9970 0.9971 0.9972 0.9973 0.9974
2.8 0.9974 0.9975 0.9976 0.9977 0.9977 0.9978 0.9979 0.9979 0.9980 0.9981
2.9 0.9981 0.9982 0.9982 0.9983 0.9984 0.9984 0.9985 0.9985 0.9986 0.9986
3.0 0.9987 0.9987 0.9987 0.9988 0.9988 0.9989 0.9989 0.9989 0.9990 0.9990
3.1 0.9990 0.9991 0.9991 0.9991 0.9992 0.9992 0.9992 0.9992 0.9993 0.9993
3.2 0.9993 0.9993 0.9994 0.9994 0.9994 0.9994 0.9994 0.9995 0.9995 0.9995
3.3 0.9995 0.9995 0.9995 0.9996 0.9996 0.9996 0.9996 0.9996 0.9996 0.9997
3.4 0.9997 0.9997 0.9997 0.9997 0.9997 0.9997 0.9997 0.9997 0.9997 0.9998
Page 43 of 160
STATISTICS OVERVIEW
Table entry for z is the area under the standard normal curve from the left of z
−2.9 0.0019 0.0018 0.0018 0.0017 0.0016 0.0016 0.0015 0.0015 0.0014 0.0014
−2.8 0.0026 0.0025 0.0024 0.0023 0.0023 0.0022 0.0021 0.0021 0.0020 0.0019
−2.7 0.0035 0.0034 0.0033 0.0032 0.0031 0.0030 0.0029 0.0028 0.0027 0.0026
−2.6 0.0047 0.0045 0.0044 0.0043 0.0041 0.0040 0.0039 0.0038 0.3700 0.0036
−2.5 0.0062 0.0060 0.0059 0.0057 0.0055 0.0054 0.0052 0.0051 0.0049 0.0048
−2.4 0.0082 0.0080 0.0078 0.0075 0.0073 0.0071 0.0069 0.0068 0.0066 0.0064
−2.3 0.0107 0.0104 0.0102 0.0099 0.0096 0.0094 0.0091 0.0089 0.0087 0.0084
−2.2 0.0139 0.0136 0.0132 0.0129 0.0125 0.0122 0.0119 0.0116 0.0113 0.0110
−2.1 0.0179 0.0174 0.0170 0.0166 0.0162 0.0158 0.0154 0.0150 0.0146 0.0143
−2.0 0.0228 0.0222 0.0217 0.0212 0.0207 0.0202 0.0197 0.0192 0.0188 0.0183
−1.9 0.0287 0.0281 0.0274 0.0268 0.0262 0.0256 0.0250 0.0244 0.0239 0.0233
−1.8 0.0359 0.0351 0.0344 0.0336 0.0329 0.0322 0.0314 0.0307 0.0301 0.0294
−1.7 0.0446 0.0436 0.0427 0.0418 0.0409 0.0401 0.0392 0.0384 0.0375 0.0367
−1.6 0.0548 0.0537 0.0526 0.0516 0.0505 0.0495 0.0485 0.0475 0.0465 0.0455
−1.5 0.0668 0.0655 0.0643 0.0630 0.0618 0.0606 0.0594 0.0582 0.0571 0.0559
−1.4 0.0808 0.0793 0.0778 0.0764 0.0749 0.0735 0.0721 0.0708 0.0694 0.0681
−1.3 0.0968 0.0951 0.0934 0.0918 0.0901 0.0885 0.0869 0.0853 0.0838 0.0823
−1.2 0.1151 0.1131 0.1112 0.01093 0.1075 0.1056 0.1038 0.1020 0.1003 0.0985
−1.1 0.1357 0.1335 0.1314 0.1292 0.1271 0.1251 0.1230 0.1210 0.1190 0.1170
−1.0 0.1587 0.1562 0.1539 0.1515 0.1492 0.1469 0.1446 0.1423 0.1401 0.1379
−0.9 0.1841 0.1814 0.1788 0.1762 0.1736 0.1711 0.1685 0.1660 0.1635 0.1611
−0.8 0.2119 0.2090 0.2061 0.2033 0.2005 0.1977 0.1949 0.1922 0.1894 0.1867
−0.7 0.2420 0.2389 0.2358 0.2327 0.2296 0.2266 0.2236 0.2206 0.2177 0.2148
−0.6 0.2743 0.2709 0.2676 0.2643 0.2611 0.2578 0.2546 0.2514 0.2483 0.2451
−0.5 0.3085 0.3050 0.3015 0.2981 0.2946 0.2912 0.2877 0.2843 0.2810 0.2776
−0.4 0.3446 0.3409 0.3372 0.3336 0.3300 0.3264 0.3228 0.3192 0.3156 0.3121
−0.3 0.3821 0.3783 0.3745 0.3707 0.3669 0.3632 0.3594 0.3557 0.3520 0.3483
−0.2 0.4207 0.4168 0.4129 0.4090 0.4052 0.4013 0.3974 0.3936 0.3897 0.3859
−0.1 0.4602 0.4562 0.4522 0.4483 0.4443 0.4404 0.4364 0.4325 0.4286 0.4247
−0.0 0.5000 0.4960 0.4920 0.4880 0.4840 0.4801 0.4761 0.4721 0.4681 0.4641
Example: With the help of normal probability table, we can calculate the probabilities for nonstandard normal distri-
bution through standardizing.
Suppose X ∼ N (10, 4), we want to calculate P (X > 13)
Page 44 of 160
STATISTICS OVERVIEW
P (X < 7)?
P (X > 7)?
P (5 < X < 7)?
Solution
p √
σ = var(X) = 4 = 2 ⇒ X ∼ N (10, 2)
13 − 10
(a) P (X > 13) = P (Z > = 1.5) = P (Z > 1.5) = 1 − P (X ≤ 1.5) = 1 − 0.9332 = 0.0668
2
7 − 10
(b) Z = = −1.5 ⇒ P (X < 7) = P (Z < −1.5)
2
P (Z > 1.5) + P (Z < 1.5) = 1 ⇒ P (Z > 1.5) = 1 − P (Z < 1.5) = 1 − 0.9332 = 0.0668
⇒ P (X < 7) = P (Z < −1.5) = P (Z > 1.5) = 0.0668
(c) P (Z > −1.5) + P (Z < −1.5) = 1 ⇒ P (Z > −1.5) = 1 − 0.0668 = 0.9332
⇒ P (X > 7) = P (Z > −1.5) = 0.9332
5 − 10 7 − 10
(d) P (5 < X < 7) = P ( <Z< ) = P (−2.5 < Z < −1.5) = P (Z < −1.5) − P (Z > −2.5)
2 2
⇒ P (5 < X < 7) = P (Z < −1.5) − P (Z < −2.5)
P (Z < 2.5) + P (Z > 2.5) = 1 ⇒ P (Z > 2.5) = 1 − P (Z < 2.5) = 1 − 0.9938 = 0.0062
P (Z < −2.5) = P (Z > 2.5) = 0.0062
⇒ P (5 < X < 7) = 0.0668 − 0.0062 = 0.0606
Note
Solution
9.5 − 10.0 10.5 − 10.0
P (X < 9.5 ∪ X > 10.5) = P (X < 9.5) + P (X > 10.5) = P (Z < ) + P (Z > )
0.3 0.3
⇒ P (X < 9.5 ∪ X > 10.5) = P (Z < −1.67) + P (Z > 1.67)
P (Z > 1.67) + P (Z < 1.67) = 1 ⇒ P (Z > 1.67) = 1 − 0.9525 = 0.0475
⇒ P (Z < −1.67) = P (Z > 1.67) = 0.0475
P (X < 9.5 ∪ X > 10.5) = P (Z < −1.67) + P (Z > 1.67) = 0.0475 + 0.0475 = 0.095
Page 45 of 160
STATISTICS OVERVIEW
Solution
(a) For 2.5% in the lower tail, (z ≈ −1.96).
X −µ
Z= ⇒ X = Zσ + µ = (−1.96)(0.3) + 10.0 = 9.412
σ
(b) For 1% in the upper tail, (z ≈ 2.33).
X −µ
Z= ⇒ X = Zσ + µ = (2.33)(0.3) + 10.0 = 10.699
σ
Example: Volume
The fill volume of an automatic filling machine used for filling cans of carbonated beverage is normally distributed with
a mean of 12.4 fluid ounces and a standard deviation of 0.1 fluid ounce.
(a) What is the probability that a randomly chosen can will contain between 12.3 and 12.5 ounces?
(b) 2.5% of the cans will contain less than ounces.
Solution
x + 0.5 − np
P (X ≤ x) ≈ Φ( √ ) (4..16)
npq
Page 46 of 160
STATISTICS OVERVIEW
where Φ is the cdf of the standard normal distribution. In practice, the approximation is adequate provided that both
np ≥ 10 and nq ≥ 10.
What is the constant 0.5?
− The constant 0.5 is a continuity correction factor.
− It is used because the binomial distribution is discrete, while the normal distribution is continuous.
− When approximating a discrete distribution with a continuous one, we need to adjust the boundaries.
− For example, P (X ≤ k) in the binomial distribution is approximated by P (Y ≤ k + 0.5) in the normal distribution.
Why do we need a condition like np ≥ 10 and nq ≥ 10?
− These conditions ensure that the binomial distribution is sufficiently symmetric and bell-shaped.
− If np or nq are too small, the binomial distribution will be skewed.
− The normal approximation is only accurate when the binomial distribution is close to a normal distribution.
− The conditions np ≥ 10 and nq ≥ 10 are a rule of thumb to ensure the approximation is reasonable.
Procedure for the Normal Approximation to the Binomial Distribution
Solution
√ p
µ = np = (0.25)(50) = 12.5, σ = npq = (50)(0.25)(0.75) = 3.062
(a) Approximately probability:
10.5 − 12.5
X ≤ 10 ⇒ P (X < 10 + 0.5) = P (X < 10.5) = P (Z < ) = P (Z < −0.65) = 0.2578
3.062
10
X
Exact probability: P (X ≤ 10) = Ck50 (0.25)k (0.75)50−k ≈ 0.2622
k=0
(b) Approximately probability:
4.5 − 12.5 15.5 − 12.5
5 ≤ X ≤ 15 ⇒ P (5 − 0.5 < X < 15 + 0.5) = P (4.5 < X < 15.5) = P ( <Z< )
3.062 3.062
⇒ P (4.5 < X < 15.5) = P (−2.61 < Z < 0.98) = P (Z < 0.98) − P (Z < −2.61) = 0.8365 − 0.0045 = 0.832
15
X
Exact probability: P (5 ≤ X ≤ 15) = Ck50 (0.25)k (0.75)50−k ≈ 0.8382
5
34) Skewness
Page 47 of 160
STATISTICS OVERVIEW
Skewness is a key statistical measure that shows how data is spread out in a dataset. It tells us if the data points
are skewed to the left (negative skew) or to the right (positive skew) in relation to the mean. It is important because
it helps us to understand the shape of the data distribution which is important for accurate data analysis and helps in
identifying outliers and finding the best statistical methods to use for analysis.
This is the simplest and quickest method for assessing skewness by creating a histogram or a density plot of the given
data.
If the plot has a long tail on the right, the data is positively skewed (right-skewed).
If the plot has a long tail on the left, the data is negatively skewed (left-skewed).
If the plot is roughly symmetric, the data has no skewness (zero skew).
Page 48 of 160
STATISTICS OVERVIEW
This is a numerical measure of skewness based on the relationship between the mean and mode. It helps us to find if
the data is skewed when the mean and mode are not equal.
Positive Skew: If the mean is greater than the mode, the skewness is positive.
Negative Skew: If the mean is smaller than the mode, the skewness is negative.
Zero Skew: If the mean is equal to the mode, the skewness is zero which indicates a symmetric distribution.
This method checks the distances between the quartiles to find skewness. If the quartiles are not equidistant, it suggests
skewness condition:
Q3 − M = M − Q1 ⇒ zero skew (4..18)
where:
Q3 : the third quartile (median of the second half of data)
Q2 = M : median of the whole data
Q1 L : the first quartile (median of the first half of data)
If this condition is not met, it shows either a positive or negative skew which depends on which side is longer.
Measurement of Skewness
Skewness is measured using different techniques to quantify the degree of asymmetry in a dataset’s distribution. Below
are three common methods to measure skewness:
1. Karl Pearson’s Measure
Karl Pearson’s Measure uses the mean, median and standard deviation of the given data to measure the asymmetry of
the distribution. It provides a dimensionless number that helps to quantify how skewed the data is.
With respect to Mean and Median
3(X̄ − M )
Sk = (4..19)
σ
With respect to Mean and Mode
X̄ − Mode
Sk = (4..20)
σ
where:
Sk : Karl Pearson’s skewness coefficient
X̄ : mean of the data
M : median of the data
σ : standard deviation of the data
Interpretation:
Skewness = 0: The distribution is symmetric means the mean, median and mode are equal.
Skewness > 0: The distribution is positively skewed (right-skewed) with the tail on the right side longer than the left.
Skewness < 0: The distribution is negatively skewed (left-skewed) with the tail on the left side longer than the right.
Example: Calculate Pearson’s skewness coefficient for a dataset of exam scores: 85, 88, 92, 94, 96, 98, 100, 100, 100, 100.
Solution
85 + 88 + 92 + 94 + 96 + 98 + 100 + 100 + 100 + 100 953
X̄ = = = 95.3
10 10
Page 49 of 160
STATISTICS OVERVIEW
96 + 98 194
Because n = 10 ⇒ M = = = 97
P10 2 2
(xi − X̄) 268.1 √
σ 2 = i=1 = = 26.81 ⇒ σ = 26.81 ≈ 5.18
n 10
100 is the most occurrence value in the data ⇒ Mode = 100
3(X̄ − M ) 3(95.3 − 97)
With respect to Mean and Median Sk = = = −1.02
σ 5.18
X̄ − Mode 95.3 − 100
With respect to Mean and Mode Sk = = = −0.94
σ 5.18
Conclusion: Since the skewness coefficient Sk is negative which shows a slight negative skewness in the distri-
bution of exam scores. This means that the tail of the distribution is slightly longer on the left side and most of the
scores are concentrated on the right side of the mean.
2. Bowley’s Measure
Bowley’s Skewness Coefficient is another method for calculating skewness based on quartiles (Q1 , Q2 , Q3 ). Unlike
Karl Pearson’s measure it does not rely on the mean or standard deviation which makes it useful for data that might
not follow a normal distribution. It’s calculated using the first quartile (Q1 ), the second quartile (Q2 or median) and the
third quartile (Q3 ).
Q3 + Q1 − 2Q2
B= (4..21)
Q3 − Q1
where:
Q1 = first quartile (25th percentile)
Q2 = second quartile (50th percentile)
Q3 = third quartile (75th percentile)
Interpretation:
B = 0 : The distribution is perfectly symmetric (no skewness).
B < 0 : The distribution is negatively skewed (left-skewed) with the tail on the left side longer.
B > 0 : The distribution is positively skewed (right-skewed) with the tail on the right side longer.
Example: Calculate Bowley’s Measure of Skewness for the following dataset representing the ages of a group of people
in a sample: 20, 24, 28, 32, 35, 40, 42, 45, 50.
Solution
n = 9 ⇒ Q2 = M = 35
24 + 28
First half data: 20, 24, 28, 32 ⇒ Q1 = = 26
2
42 + 45
Second half data: 40, 42, 45, 50 ⇒ Q2 = = 43.5
2
Q3 + Q1 − 2Q2 43.5 + 26 − 2(35)
B= = ≈ −0.03
Q3 − Q1 43.5 − 26
Conclusion: Since B < 0, this shows a negatively skewed (left-skewed) distribution means the tail is longer on
the left side.
3. Kelly’s Measure
Kelly’s Skewness Measure calculates skewness by comparing certain percentiles in the data which typically the 10th,
50th (median) and 90th percentiles. This measure is useful when dealing with datasets that are not normally distributed
or when other skewness measures may not be as effective.
where:
SKL > 0 : Positive skew means the right tail is longer or heavier.
SKL < 0 : Negative skew means the left tail is longer or heavier.
SKL ≈ 0 : The distribution is symmetric shows little or no skewness.
Page 50 of 160
STATISTICS OVERVIEW
Example: Calculate Kelly’s Coefficient of Skewness for the following data: 5, 7, 8, 9, 10, 12, 15, 16, 18, 20.
Solution
n = 10 ⇒ 0.1n = 1 ⇒ The 10th percentile corresponds to the value at the position 1 ⇒ P10 = 5
10 + 12
n = 10 ⇒ P50 = = 11
2
n = 10 ⇒ 0.9n = 9 ⇒ the 90th percentile corresponds to the value at the position 9 ⇒ P90 = 18
P90 + P10 − 2P50 18 + 5 − 2(11)
SKL = = ≈ 0.08
P90 + P10 18 − 5
Conclusion: Since SKL > 0, this shows a slight positive skew (right-skewed) means the distribution has a longer
tail on the right side.
Direction of Skewness
1. Negative skewness (Left skewed): If the skewness is negative, it shows that the distribution is skewed to the left.
In a left-skewed distribution:
The tail on the left side (the smaller values) is longer and contains outliers.
The majority of data points are concentrated on the right side.
The mean is less than the median.
2. Positive skewness (Right skewed): A positive skewness shows that the distribution is skewed to the right. In a
right-skewed distribution:
The tail on the right side (the larger values) is longer and may contain outliers.
Most data points are concentrated on the left side.
The mean is greater than the median
2. Zero skewness (Symmetric): A skewness value close to zero suggests a symmetric distribution where the data is
evenly distributed on both sides of the mean. This means there is no skewness.
Page 51 of 160
STATISTICS OVERVIEW
When transformations aren’t effective, consider non-parametric tests like the Mann-Whitney U Test or Kruskal-
Wallis Test which do not assume normal distribution and focus on medians rather than means.
4. Machine Learning Models
Some models handle skewed data better:
Tree-based Models: Decision trees and random forests are less sensitive to skewness.
Generalized Linear Models (GLM): Use appropriate link functions to model skewed data effectively.
Dispersion Skewness
Measures the spread of data around the central Measures the shape of the distribution and di-
value (mean, median). rection (left or right).
Variance, standard deviation, range, interquar- Pearson’s coefficient of skewness, moment
tile range (IQR). skewness, QQ plots.
Dispersion affects the mean’s interpretation but Skewness shows the relationship between the
is not directly related. mean and median.
High dispersion means data points are spread Positive skew: Right tail longer. Negative skew:
out widely Left tail longer. Zero skew: Symmetric.
Helps understand the variability of data Helps identify the shape and asymmetry of data.
Test scores spread, stock price variability, age Income distribution (right-skewed), exam
range. scores (left/right-skewed).
We have discussed Poisson distribution in the previous chapter which for example can model the number of car ac-
cidents for a given length of time t.
The waiting time between accidents is another random variable that is often of interest. We can use an exponential
distribution to model such a waiting period.
We define:
X = the waiting time between two car accidents
and
N = the number of accidents during time of length x
We know that if the mean number of accidents is λ per base unit, then the random variable N ∼ Poisson(λx).
To model the waiting time, suppose there is no accident during the time of length x. Now,
e−λx (λx)0
P (X > x) = P (N = 0) = = e−λx
0!
Page 52 of 160
STATISTICS OVERVIEW
1
E(X) = µ =
λ
1
var(X) = 2 (4..25)
λ
ln (2)
Median = = µ ln (2)
λ
35).2 Summary
Suppose that X ∼ expon(λ), then
pdf: fX (x) = λe−λx for x ≥ 0
dexp(x, λ) in R
cdf: FX (x) = P (X ≤ x) = 1 − e−λx , for x ≥ 0
P (X > x) = 1 − FX (x) = e−λx for x ≥ 0
pexp(x, λ) in R
1
Mean: E(X) =
λ
1
Variance: var(X) = 2
λ
Example: Computer Usage
Let X denote the time in hours from the start of the interval until the first log-on. Then, X has an exponential distribution
with 1 log-on per hour. We are interested in the probability that X exceeds 6 minutes. (Hint: Because λ is given in
log-ons per hour, we express all time units in hours. That is, 6 minutes = 0.1 hour)
Solution
P (X > 0.1) = e−λx = e(−1)(0.1) = 0.9048
Example: Accidents
The time between accidents at a factory follows an exponential distribution with a historical average of 1 accident every
Page 53 of 160
STATISTICS OVERVIEW
900 days.
(a) What is the probability that there will be more than 1200 days between the next two accidents?
(b) What is the probability that there will be less than 900 days between the next two accidents?
Solution
1
λ=
900
1
− (1200)
(a) P (X > 1200) = e −λx
= e 900 = 0.2636
1
− (900)
(b) P (X > 900) = e−λx = e 900 = 0.3679
⇒ P (X < 900) = 1 − P (X > 900) = 1 − 0.3679 = 0.6321
1
Example: Suppose that a random variable X follows an exponential distribution with λ = .
6
(a) What is the probability that X is at most 10?
(b) What is the probability that X is between 5 and 10?
Solution
1
(10)
−
(a) P (X ≤ 10) = 1 − e −λx
=1−e 6 = 0.8111
1
(5) −
(b) P (5 ≤ X ≤ 10) = P (X ≤ 10) − P (X ≤ 5) = 0.8111 − (1 − e ) = 0.8111 − 1 + e
λx 6 = 0.2457
Solution
Solution
Page 54 of 160
STATISTICS OVERVIEW
1 1
λ= ⇒ average number of failures in next 2000 hours = (2000) =2
1000 1000
0 −λ 0 −2
λ e (2) e
(a) P (X = 0) = = = 0.1353
0! 0!
1
− (2000)
(b) P (X > 2000) = e −λx
=e 1000 = 0.1353
1. Define the Conditional Probability: show that P (X > s + t|X > t) = P (X > s) for all s, t ≥ 0, where X is an
exponential random variable with parameter λ
P (X > s + t ∩ X > t)
2. Use the Definition of Conditional Probability: P (X > s + t|X > t) =
P (X > t)
3. Simplify the Numerator: X > s + t=⇒X > t ⇒ (X > s + t ∩ X > t) = X > s + t
⇒ P (X > s + t ∩ X > t) = P (X > s + t)
4. Use the Exponential Distribution’s Survival Function: The survival function for an exponential distribution is
P (X > x) = e( − λx)
P (X > s + t ∩ X > t) eλ(s+t)
5. Substitute and Simplify: = −λt = e−λs = P (X > s)
P (X > t) e
To understand this property of exponential distribution, let us assume X models the life time of a light bulb.
The memoryless property tells you that given the fact that the light bulb still “survives” at time t, the probability it will
last longer than additional △t amount of time (the conditional probability) equals to the probability that it will last
longer than △t amount of time from the beginning (the unconditional probability).
The exponential distribution is the only continuous distribution with the “memoryless” property.
Page 55 of 160
STATISTICS OVERVIEW
where the shape parameter α > 0 and the scale parameter β > 0.
Note
The kernel of a pdf fY (y) is the part that depends on y. The gamma pdf consists of a kernel and a “normalizing
constant.” This constant is free of y, but it forces the pdf to integrate to 1 over the support.
y y
Z ∞ −
Z ∞ −
1 α−1 β α−1 β
y e dy = 1=⇒ y e dy = Γ(α)β α
0 Γ(α)β α 0
If Y ∼ Gamma(α.β),
E(Y ) = αβ
(4..28)
var(Y ) = αβ 2
The Weibull distribution is often used to model the time until failure of many different physical systems.
The random variable X with probability density function:
x β
β x β−1 −( )
fX (x) = ( ) e δ , for x ≥ 0
δ δ
is a Weibull random variable with scale parameter δ > 0 and shape parameter β > 0.
The shorthand notation is X ∼ Weibull(β, δ).
By changing the values of β and δ, the Weibull pdf can assume many shapes. Because of this flexibility (and for other
reasons), the Weibull distribution is very popular among engineers in reliability applications.
Page 56 of 160
STATISTICS OVERVIEW
x β
−( )
FX (x) = P (X ≤ x) = 1 − e δ , for x ≥ 0 (4..29)
It follows that
x β
−( )
P (X > x) = e δ , (4..30)
Solution
Page 57 of 160
STATISTICS OVERVIEW
20 2
−( )
(a) P (T > 20) = e 10 = 0.0183
10 2
−( )
(b) P (T > 10) = e 10 = 0.3679
P (T > 20 ∩ T > 10) P (T > 20) 0.0183
P (T > 20|T > 10) = = = = 0.04974
P (T > 10) P (T > 10) 0.3679
37).3 Summary
Suppose that X ∼ Weibull(β, δ)
x β
β x β−1 −( )
pdf: fX (x) = ( ) e δ for x ≥ 0
δ δ
dweibull(x, β, δ) in R
x β
−( )
CDF: FX (x) = 1 − e δ for x ≥ 0
pweibull(x, β, δ) in R
1
Mean: E(X) = δΓ(1 + )
β
2 1
Variance: var(X) = δ 2 [Γ(1 + ) − (Γ(1 + ))2 ]
β β
where Γ is called gamma function and Γ(n) = (n − 1)! if n is a positive integer.
For any integer ≥ 1, a random variable Y has a χ2 distribution with ν degrees of freedom if Y is a gamma random
ν
variable with α = and β = 2.
2
ν
E(Y ) = αβ = (2) = 2
2 (4..33)
ν 2
var(Y ) = αβ 2 = (2 ) = 2ν
2
Page 58 of 160
STATISTICS OVERVIEW
6. 0.676 0.872 1.237 1.635 2.204 10.645 12.592 14.440 16.812 18.548
7. 0.989 1.239 1.690 2.167 2.833 12.017 14.067 16.012 18.474 20.276
8. 1.344 1.646 2.180 2.733 3.490 13.362 15.507 17.534 20.090 21.954
9. 1.735 2.088 2.700 3.325 4.168 14.684 16.919 19.022 21.665 23.587
10. 2.156 2.558 3.247 3.940 4.865 15.987 18.307 20.483 23.209 25.188
11. 2.603 3.053 3.816 4.575 5.578 17.275 19.675 21.920 24.724 26.755
12. 3.074 3.571 4.404 5.226 6.304 18.549 21.026 23.337 26.217 28.300
13. 3.565 4.107 5.009 5.892 7.042 19.812 22.362 24.736 27.688 29.819
14. 4.075 4.660 5.629 6.571 7.790 21.064 23.685 26.119 29.141 31.319
15. 4.601 5.229 6.262 7.261 8.547 22.307 24.996 27.488 30.578 32.801
16. 5.142 5.812 6.908 7.962 9.312 23.542 26.296 28.845 32.000 34.267
17. 5.697 6.408 7.564 8.672 10.085 24.769 27.587 30.191 33.409 35.718
18. 6.285 7.015 8.231 9.390 10.865 25.989 28.869 31.526 34.805 37.156
19. 6.844 7.633 8.907 10.117 11.651 27.204 30.144 32.852 36.191 38.582
20. 7.434 8.260 9.591 10.851 12.443 28.412 31.410 34.170 37.566 39.997
21. 8.034 8.897 10.283 11.591 13.240 29.615 32.671 35.489 38.932 41.401
22. 8.643 9.542 10.982 12.338 14.041 30.813 33.924 36.781 40.289 42.796
23. 9.260 10.196 11.689 13.091 14.848 32.007 35.172 38.076 41.638 44.181
24. 9.886 10.856 12.401 13.848 15.659 33.196 36.415 39.364 42.980 45.559
25. 10.520 11.524 13.120 14.611 16.473 34.382 37.652 40.646 44.314 46.928
26. 11.160 12.198 13.844 15.379 17.292 35.573 38.885 41.923 45.642 48.290
27. 11.808 12.879 14.573 16.151 18.114 36.741 40.113 43.195 46.963 49.645
28. 12.461 13.565 15.308 16.928 18.939 37.916 41.337 44.461 48.278 50.993
29. 13.121 14.256 16.047 17.708 19.768 39.087 42.557 45.722 49.588 52.336
30. 13.787 14.953 16.791 18.493 20.599 40.256 43.773 46.979 50.892 53.672
40. 20.707 22.164 24.433 26.509 29.051 51.805 55.758 59.342 63.691 66.766
50. 27.991 29.707 32.357 34.764 37.689 63.167 67.505 71.420 76.154 79.490
60. 35.534 37.485 40.482 43.188 46.459 74.397 79.082 83.298 88.379 91.962
70. 43.275 45.442 48.758 51.739 55.329 85.527 90.531 95.023 100.425 104.215
80. 51.172 53.540 57.153 60.391 64.278 96.578 101.879 106.629 112.329 116.321
90. 59.196 61.754 65.647 69.126 73.291 107.565 113.145 118.136 124.116 128.299
100. 67.328 70.065 74.222 77.929 82.358 118.498 124.342 129.561 135.807 140.169
Page 59 of 160
STATISTICS OVERVIEW
Definition: The joint probability mass function (joint pmf) of two discrete random variables Y1 and Y2 is
The joint (bivariate) pmf gives the probability that the pair (Y1 , Y2 ) takes a specific pair of values (y1 , y2 ).
If Y1 and Y2 are discrete random variables with the joint pmf f (y1 , y2 ), then:
(i) f (y1 , y2 ) ≥ 0 for all y1 , y2
X
(ii) f (y1 , y2 ) = 1 where we sum over all possible (y1 , y2 ) pairs
y1 ,y2
Example: Tornados
Tornados are natural disasters that cause millions of dollars in damage each year. An actuary determines that the annual
numbers of tornadoes in two Iowa counties (Lee and Van Buren) are jointly distributed as indicated in the table below.
Let Y1 and Y2 denote the number of tornados seen each year in Lee and Van Buren counties, respectively
f (y1 ,2 ) y2 = 0 y2 = 1 y2 = 2 y3 = 3
y1 = 0 0.12 0.06 0.05 0.02
y1 = 1 0.13 0.15 0.12 0.03
y1 = 2 0.05 0.15 0.10 0.02
(a) What is the probability that there is no more than one tornado seen in the two counties combined?
(b) What is the probability that there are two tornadoes in Lee County?
Solution
Definition: Let Y1 and Y2 be jointly continuous random variables with joint cdf F (y1 , y2 ). If there is a nonnegative
function f (y1 , y2 ) such that Z y1 Z y2
F (y1 , y2 ) = f (t1 , t2 )dt1 dt2 (5..3)
−∞ −∞
then f (y1 , y2 ) is called the joint probability density function (joint pdf) of (y1 , y2 ).
If Y1 and Y2 are continuous random variables with the joint pdf f (y1 , y2 ), then:
(i) f (y1 , y2 ) ≥ 0 for all y1 , y2
Page 60 of 160
STATISTICS OVERVIEW
Z ∞ Z ∞
(ii) f (y1 , y2 )dy1 dy2 = 1
−∞ −∞
Example: Completing Tasks
Suppose the time (in hours) to complete task 1 and task 2 for a random employee has the joint pdf:
e−(y1 +y2 ) , y > 0, y > 0
1 2
f (y1 , y2 ) =
0 otherwise
Find the probability that a random employee takes less than 2 hours on task 1 and between 1 and 3 hours on task 2.
Solution
Z 3 Z 2 Z 3 Z 3
P (0 < y1 < 2, 1 < y2 < 3) = e−(y1 +y2 ) dy1 dy2 = e−(y1 +y2 ) |20 dy2 = [e−(2+y2 ) − e−(0+y2 ) ]dy2
1 0 1 1
Z 3
⇒ P (0 < y1 < 2, 1 < y2 < 3) = [e−(2+y2 ) − e−y2 ]dy2 = e−(2+y2 ) − e−y2 |31 = [e−(2+3) − e−3 ] − [e−(2+1) − e−1 ]
1
⇒ P (0 < y1 < 2, 1 < y2 < 3) = 0.275
Definition: If Y1 , Y2 are jointly discrete random variables with joint pmf f (y1 , y2 ), then the marginal pmf of Y1 is
X
f (y1 ) = f (y1 , y2 ) (5..4)
y2
Definition: If Y1 , Y2 are jointly continuous random variables with joint pdf f (y1 , y2 ), then the marginal pdf of Y + 1
is Z ∞
f (y1 ) = f (y1 , y2 )dy2 (5..6)
−∞
Example: Suppose we model two proportions Y1 and Y2 with the joint pdf
0.4(y + 0.4y ) 0 < y < 1, 0 < y < 1
1 2 1 2
f (y1 , y2 ) =
0 elsewhere
(a) Find the marginal pdf of Y1 .
(b) Find P (Y1 > 0.3).
Solution
Z 1 Z 1
(a) f (y1 ) = 0.4(y1 + 4y2 )dy2 = 0.4 (y1 + 4y2 )dy2 = 0.4(y1 y2 + 2y22 )|10 = 0.4(y1 + 2)
0 Z 1 0
y2 12 0.32
(b) P (Y1 > 0.3) = 0.4(y1 + 2)dy1 = 0.4( 1 + 2y1 )|10.3 = 0.4[ + 2(1) − − 2(0.3)] = 0.742
0.3 2 2 2
Page 61 of 160
STATISTICS OVERVIEW
Solution
1
6 1 y3
Z Z
6 6 6 1
f (x) = (x + y 2 )dy = (x + y 2 )dy = (xy + )|10 = (x + )
5 5 0 5 3 5 3
Z 01
6 1 6 x2
Z
6 6 2 1
f (y) = (x + y 2 )dx = (x + y 2 )dx = 2 1
( + xy )|0 = (y + )
0 5 5 0 5 2 5 2
Definition: If Y1 , Y2 are jointly discrete/continuous random variables with joint pmf/pdf f (y1 , y2 ), then the condi-
tional pmf/pdf of Y1 given Y2 = y2 is:
f (y1 , y2 )
f (y1 |y2 ) = (5..8)
f (y2 )
provided that f (y2 ) > 0. Similarly, the conditional pmf/pdf of Y2 given Y1 = y1 is:
f (y1 , y2 )
f (y2 |y1 ) = (5..9)
f (y1 )
Note
Theorem: If Y1 , Y2 are jointly discrete/continuous random variables with pmf/pdf’s f1 (y1 ) and f2 (y2 ) and joint pdf
f (y1 , y2 ), then Y1 and Y2 are independent if and only if
Page 62 of 160
STATISTICS OVERVIEW
Definition: If Y1 , Y2 are jointly discrete/continuous r.v.’s with pmf/pdf f (y1 , y2 ). Then for some function g(Y1 , Y2 ):
X X
g(y1 , y2 )f (y1 , y2 ) discrete
y
E{g(Y1 , Y2 )} = Z Z
1 y2 (5..13)
g(y1 , y2 )f (y1 , y2 )dy1 dy2 continuous
Example: Suppose that the lifetime of two components are independent of one another and that the first lifetime,
1
X1 , has an exponential distribution with λ1 = , where as the second, X2 , has an exponential distribution with
1000
1
λ2 = .
1200
What is the probability that both component lifetimes are at least 1500 hours?
Solution
1 1
−λ1 x1 −λ2 x2
−( )(1500) −( )(1500)
P (X1 ≥ 1500, X2 ≥ 1500) = f1 (X1 ≥ 1500)f2 (X2 ≥ 1500) = e e =e 1000 e 1200
⇒ P (X1 ≥ 1500, X2 ≥ 1500) ≈ 0.06393
Example:
6 (x + y 2 ) 0 ≤ x ≤ 1, 0 ≤ y ≤ 1
f (x, y) = 5
0 elsewhere
(a) Compute that conditional pdf of Y given that X = 0.8.
(b) Compute the conditional mean of Y given that X = 0.8.
Solution
1 1
y3
Z Z
6 6 6 6 1
f (x) = (x + y 2 )dy = (x + y 2 )dy = (xy + )|10 = (x + )
0 5 5 0 5 3 5 3
6
f (y, 0.8) (0.8 + y 2 ) 0.8 + y 2 2.4 + 3y 2
(a) f (Y |X = 0.8) = = 5 = =
fX (0.8) 6 1 1 3.4
(0.8 + ) 0.8 +
Z 1 5 3 Z 1 3 Z 1
2.4 + 3y 2 1 5 3
(b) E(Y |X = 0.8) = yf (Y |X = 0.8)dy = y dy = (2.4y + 3y 3 )dy = (1.2y 2 + y 4 )|10 = 0.5735
0 0 3.4 3.4 0 17 4
47) Covariance
Definition: If Y1 and Y2 are random variables with respective means µ1 and µ2 , then:
Interpretation:
(i) cov(Y1 , Y2 ) > 0 =⇒Y1 and Y2 are positively linearly related.
(ii) cov(Y1 , Y2 ) < 0 =⇒Y1 and Y2 are negatively linearly related.
(iii) cov(Y1 , Y2 ) = 0 =⇒ NO linear relationship between Y1 and Y2 .
47).1 Properties
If X1 , X2 , X3 and X4 are real-valued random varaibles, a, b, c, and d are real-valued constants:
cov(X1 , a) = 0
Page 63 of 160
STATISTICS OVERVIEW
cov(X1 , X1 ) = var(X1 )
cov(X1 , X2 ) = cov(X2 , X1 )
cov(aX1 , bX2 ) = abcov(X1 , X2 )
cov(X1 + a, X2 + b) = cov(X1 , X2 )
cov(aX1 + bX2 , cX3 + dX4 ) = accov(X1 , X3 ) + adcov(X1 , X4 ) + bccov(X2 , X3 ) + bdcov(X2 , X4 )
47).2 Independence and Covariance
Theorem: If Y1 , Y2 are independent, then
cov(Y1 , Y2 ) = 0 (5..15)
Note
48) Correlation
It is hard to judge the strength of the linear association using the covariance since the covariance depends on the
scale of measurement.
We often use a standardized version called the correlation coefficient (denoted by ρ):
cov(Y1 , Y2 )
ρ= p p (5..16)
var(Y1 ) var(Y2 )
It is always true that 1 ≤ ρ ≤ 1, so values of ρ near 1 (or near −1) indicate a strong positive (or negative) linear associ-
ation.
Theorem: Consider random variables Y1 , ..., Yn and X1 , ...Xm such that E(Yi2 ) < ∞ and E(Xj2 ) < ∞ for all i, j. For
n
X n
X
constant a1 , ..., an and b1 , ...bm define U1 = ai Yi and U2 = bj Xj . Then
i=1 j=1
n
X
E(U1 ) = E(Yi ) = a1 E(Y1 ) + ... + an E(Yn )
i=1
n
X XX
var(U1 ) = a2i var(Yi ) + 2 ai aj cov(Yi , Yj )
i=1 i<j
n (5..17)
X XX
var(U1 ) = a2i var(Yi ) + ai aj cov(Yi , Yj )2
i=1 i̸=j
n X
X m
cov(U1 , U2 ) = ai bj cov(Yi , Xj )
i=1 j=1
Page 64 of 160
STATISTICS OVERVIEW
U2 = 3Y1 − 2Y2 − Y3
(a) Find E(U1 ) and var(U1 )
(b) Find cov(U1 , U2 )
Solution
Y1 ∼ N (12, 4) ⇒ µ1 = 12, σ12 = 4
Y2 ∼ N (16, 9) ⇒ µ2 = 16, σ22 = 9
Y3 ∼ N (20, 16) ⇒ µ3 = 20, σ32 = 16
Y1 and Y2 are independent ⇒ cov(Y1 , Y2 ) = 0
(a) E(U1 ) = 0.5E(Y1 ) − 2E(Y2 ) + E(Y3 ) = 0.5(12) − 2(16) + 20 = −6
var(U1 ) = (0.5)2 (4)+(−2)2 (9)+(1)2 (16)+2(0.5)(−2)cov(Y1 , Y2 )+2(0.5)(1)cov(Y1 , Y3 )+2(−2)(1)cov(Y2 , Y3 )
⇒ var(U1 ) = (0.5)2 (4) + (−2)2 (9) + (1)2 (16) + 2(0.5)(−2)(0) + 2(0.5)(1)(0.8) + 2(−2)(1)(6.7) = 27
(b) cov(U1 , U2 ) = (0.5)(3)cov(Y1 , Y1 ) + (0.5)(−2)cov(Y1 , Y2 ) + (0.5)(−1)cov(Y1 , Y3 ) + (−2)(3)cov(Y2 , Y1 )
+(−2)(−2)cov(Y2 , Y2 ) + (−2)(−1)cov(Y2 , Y3 ) + (1)(3)cov(Y3 , Y1 ) + (1)(−2)cov(Y3 , Y2 ) + (1)(−1)cov(Y3 , Y3 )
⇒ cov(U1 , U2 ) = (0.5)(3)(σ12 )+(0.5)(−2)(0)+(0.5)(−1)(0.8)+(−2)(3)(0)+(−2)(−2)(σ22 )+(−2)(−1)(6.7)+
(1)(3)(0.8) + (1)(−2)(6.7) + (1)(−1)(σ32 )
⇒ cov(U1 , U2 ) = (0.5)(3)(4) + (0.5)(−1)(0.8) + (−2)(−2)(9) + (−2)(−1)(6.7) + (1)(3)(0.8) + (1)(−2)(6.7) +
(1)(−1)(16) = 1.2
50) Revision
In Chapter 3, we learned the discrete probability distributions, including Bernoulli, Binomial, Geometric, Negative
Binomial, Hypergeometric, and Poisson.
In Chapter 4, we learned the continuous probability distributions, including Exponential, Weibull, and Normal.
In chapter 3 and 4, we always assume that we know the parameter of the distribution. For example, we know the mean
µ and variance σ 2 for a normal distributed random variable, so that we can calculate all kinds of probabilities with them.
For example, suppose we know the height of 18-year-old US male follows N (µ = 176.4, σ 2 = 9) in centimeters.
Let Y = the height of one 18-year-old US male.
P (Y > 180) = 1 − P (X ≤ 180)
1 > 1 − pnorm ( 1 8 0 , 1 7 6 . 4 , 3 ) # x = 1 8 0 , m = 1 7 6 . 4 , s d = 3
2 [1] 0.1150697
However, it is natural that we do NOT know the population mean µ and population variance σ 2 in reality. What should
we do?
⇒ use statistical inference
Statistical inference deals with making (probabilistic) statements about a population of individuals based on informa-
tion that is contained in a sample taken from the population.
Page 65 of 160
STATISTICS OVERVIEW
Sample variance:
n
1 X
s2 = (Yi − Ȳ )2 (5..19)
n − 1 i=1
Sample proportion:
n
1X
p̂ = Yi if Yi ’s are binary (5..21)
n i=1
50).5 Summary
The table below succinctly summarizes differences between a population and a sample (a parameter and a statistic):
51) Propositions
Page 66 of 160
STATISTICS OVERVIEW
Proposition: Let X1 , ..., Xn be a random sample from a distribution with mean µ and standard deviation σ. Then
E(X) = µ
σ2 (5..22)
var(X̄) =
n
n
X
We define a new random variable: Y = Xi
i=1
Proposition: Let X1 , ..., Xn be a random sample from a normal distribution with mean µ and standard deviation σ.
Then
σ2
X̄ ∼ N (µ, ) (5..23)
n
n
X
We define a new random variable: Y = Xi
i=1
Example: The amount of a particular impurity in a batch of a certain chemical product is a random variable. with mean
4.0 g and standard deviation 1.5 g. If 50 batches are independently prepared, what is the approximate probability that
the sample average of amount of impurity X is between 3.5 g and 3.8 g?
Solution
√
σ 1.5 3 2
s= √ = √ = = 0.2121
n 50 20
3.5 − 4.0 3.8 − 4.0
P (3.5 ≤ X ≤ 3.8) = P ( ≤Z≤ ) = P (−2.36 ≤ Z ≤ −0.94)
0.2121 0.2121
⇒ P (3.5 ≤ X ≤ 3.8) = P (Z ≤ −0.94) − P (Z ≤ −2.36) = 0.1736 − 0.0091 = 0.1645
σ2
Ȳ ∼ AN (µ, ) (5..24)
n
52).1 Simulation
Page 67 of 160
STATISTICS OVERVIEW
xx
Page 68 of 160
STATISTICS OVERVIEW
6. POINT ESTIMATION
Statistical inference deals with making (probabilistic) statements about a population of individuals based on informa-
tion that is contained in a sample taken from the population. We do this by
estimating unknown population parameters with sample statistics.
quantifying the uncertainty (variability) that arises in the estimation process.
Note
In general, θ̂ is a statistic, the value of θ̂ will vary from sample to sample. Because a statistic is a function of random
variable
E(θ̂) = θ (6..1)
Note
If the estimator is not unbiased, then difference E(θ̂) − θ is called the bias of the estimator θ̂
E(Ȳ ) = µ
(6..2)
E(s2 ) = σ 2
Precision: Suppose that θˆ1 and θˆ2 are unbiased estimators of θ. We would like to pick the estimator with smaller
variance, since it is more likely to produce an estimate close to the true value θ.
Page 69 of 160
STATISTICS OVERVIEW
We desire point estimators θ̂ which are unbiased (perfectly accurate) and have small variance (highly precise).
If θ̂ has minimum variance among all unbiased estimators, it is called the minimum variance unbiased estimator (MVUE)
of θ
The standard error of a point estimator θ̂ is defined as
q
se(θ̂) = var(θ̂) (6..3)
Note
Example: Of n1 randomly selected male smokers, X1 smoked filter cigarettes, whereas of n2 randomly selected female
smokers, X2 smoked filter cigarettes. Let p1 and p2 denote the probabilities that a randomly selected male and female,
respectively, smoke filter cigarettes.
X1 X2
(a) Show that − is an unbiased estimator for p1 − p2 .
n1 n2
(b) What is the standard error of the estimator above?
(c) How would you use the observed values x1 and x2 to estimate the standard error of your estimator?
(d) If n1 = n2 = 200, x1 = 127 and x2 = 176, use the estimator of part (a) to obtain an estimate of p1 − p2 .
(e) Use the result of part (c) and the data of part (d) to estimate the standard error of the estimator.
Solution
X1 X2 1 1 1 1
E(X) = E( − )= E(X1 ) − E(X2 ) = (n1 p1 ) − (n2 p2 ) = p1 − p2
n1 n2 n1 n2 n1 n2
X1 X2
⇒ − is an unbiased estimator of p1 − p2
n1 n2
X1 X2 1 1 1 1 p1 q1 p2 q2
(b) var(X) = var( − ) = ( )2 var(X1 ) + ( )2 var(X2 ) = ( )2 (n1 p1 q1 ) + ( )2 (n2 p2 q2 ) = +
n1 n
r2 n1 n2 n1 n2 n1 n2
p p1 q1 p2 q2
⇒ se(X) = var(X) = +
n1 n2
xi
(c) The values x1 and x2 can be plugged in the se(X) by replacing pi = with i = 1, 2 and qi = 1 − pi . However
ni
the values of n1 and n2 are compulsory to have. If the evaluations of n1 and n1 are lacked, it’s impossible to get a
realistic estimate. v
u X1 X1 X2 X2
u
(1 − ) (1 − )
r s
p1 q1 p2 q2 p1 (1 − p1 ) p2 (1 − p2 ) t n1
u
n1 n n2
se(X) = + = + = + 2
n1 n2 n1 n2 n1 n2
Page 70 of 160
STATISTICS OVERVIEW
v v
u X1 n1 − X12 X2 n2 − X22
u
u X1 X1 2 X2 X2 2
u
−( ) −( )
s
n21 n22 X1 n1 − X12 X2 n2 − X22
u u
t n1 n1 n2 n2 t
⇒ se(X) = + = + = +
n1 n2 n1 n2 n1 (n21 ) n2 (n2 )2
s
X1 n1 − X12 X2 n2 − X22
⇒ se(X) = +
n31 n32
X1 X2 127 176
(d) p = p1 − p2 = − = − = −0.245
s n 1 n 2 200 200
r
X1 n1 − X12 X2 n2 − X22 (127)(200) − (1272 ) (176)(200) − (176)2
(e) se(X) = 3 + 3 = + = 0.0411
n1 n2 2003 2003
E(X k ) (6..4)
Let X1 , ..., Xn be a random sample from a distribution f (x; θ1 , ..., θm ). Suppose that we want to estimate m unknown
parameters θ1 , ..., θm . The moments of moment (MOM) estimators θˆ1 , ..., θˆ2 are obtained by equating the first m sam-
ple moments to the first m population moments and solving for θ1 , ..., θm . Let u′k = E(X k ) be the k−the population
n
1X k
moment and hk =
′
X the k−the sample moment. The MOM procedure uses the following systems of m equations
n i=1 i
and m unknowns:
u′1 = h′1
u′2 = h′2
..
.
u′m = h′m
Example: Suppose X1 , ..., Xn is an iid sample from a U (0, θ) population distribution,vwhere θ > 0 is unknown.
Estimate θ using the methods of moment.
Solution
The method of moments estimator for the uniform distribution U (0, θ) is 2 times the sample mean
n
1X
The sample mean: X̄ = Xi
n i=1
Page 71 of 160
STATISTICS OVERVIEW
θ
For a uniform distribution U (0, θ), the theoretical mean is E(X) =
2
θ
The method of moments sets the sample mean equal to the theoretical mean: X̄ = ⇒ θ = 2X̄
2
⇒ the method of moments estimator for θ: θMOM = 2X̄
Example: Suppose X1 , ..., Xn is an iid sample from an exponential distribution with the parameter of λ. What is the
MOM estimator for λ?
Solution
Example: Suppose X1 , ..., Xn is a random sample from a Gamma(α, β) population distribution, where both α > 0
and β > 0 are unknown. In this population-level model, there are m = 2 parameters, so we will need 2 equations to
find the MOM estimators.
Solution
The method of maximum likelihood is the most common method to use when finding point estimators; i.e., when
estimating a population-level model. Maximum likelihood estimators are found by maximizing the likelihood function.
Suppose Y1 , ..., Yn is an iid sample from a population distribution denoted by pY (y|θ) or fY (y|θ), where θ (a scalar) is
an unknown population parameter. The likelihood function is denoted by L(θ|y) = L(θ|y1 , ..., yn ) is found as follows:
Y
In the discrete case: L(θ|y) = pY (yi |θ)
Page 72 of 160
STATISTICS OVERVIEW
n
Y
In the continuous case: L(θ|y) = fY (yi |θ)
i=1
In the discrete case, the likelihood function L(θ|y) actually provides a (joint) probability. Suppressing pY (y|θ)’s depen-
dence on θ, note that
L(θ|y) = pY (y1 ) × pY (y2 ) × ... × pY (yn ) = P (Y1 = y1 )P (Y2 = y2 )...P (Yn = yn ) = P (Y1 = y1 , Y2 = y2 , ..., Yn = yn )
In this light, a casual (but useful) interpretation of the likelihood function is that it is “the probability of the data.” There-
fore, one can think of maximum likelihood estimates as those estimates which “maximize the probability of the data.”
Suppose Y1 , ..., Yn is an iid sample from a population distribution denoted by pY (y|θ) or fY (y|θ), where θ ∈ R is an
unknown population parameter (for now, we consider the scalar case). The maximum likelihood estimator (MLE) of θ
is the value of θ that maximizes the likelihood function L(θ|y); i.e.,
θ̂ = argmaxθ L(θ|y)
Therefore, we can find the MLE of θ by writing out the likelihood function, viewing it as a function of θ (as always), and
then maximizing it as a function of θ.
How do we maximize L(θ|y)?
For many scenarios, this reduces to a calculus problem. If L(θ|y) is a differentiable function of θ, then we can take the
derivative of θ and set it equal to zero; i.e.,
∂
L(θ|y) = 0 (6..6)
∂θ
Because the natural logarithm function is increasing, the value of θ that maximizes L(θ|y) is the same as the value of θ
that maximizes ln L(θ|y); i.e.,
θ̂ = argmaxθ L(θ|y) = argmaxθ ln L(θ|y)
Therefore, we can also take the derivative of the log-likelihood function ln L(θ|y) and set it equal to zero; i.e.,
∂
ln L(θ|y) = 0 (6..7)
∂θ
Page 73 of 160
STATISTICS OVERVIEW
Solution
Page 74 of 160
STATISTICS OVERVIEW
56) Introduction
The population proportion p emerges when the characteristic we measure on each individual is categorical, or sim-
ply binary (i.e., only two possible outcomes). Here are some examples:
p : proportion of defective water filter
p : proportion of HIV positive in MD
We can connect these binary outcomes to the Bernoulli trials for each individual in the sample:
each trial results in only two possible outcomes, labeled as ”success” and ”failure”
the trials are independent
the probability of a success in each trial, denoted as p, remains constant. It follows that the probability of a failure in
each trial is 1 − p
Suppose we define Y = the number of successes out of n sampled individuals, so Y ∼ B(n, p). A natural point
estimator for p, the population proportion, is
Y
p̂ = , (7..1)
n
the sample proportion
58).1 Property of p̂
p̂ is unbiased estimator of p. That is,
E(p̂) = p
Page 75 of 160
STATISTICS OVERVIEW
i.i.d
where X ∼ Bernoulli(p).
E(Xi ) = p and var(Xi ) = p(1 − p)
n
Y X xi
It follows that p̂ = = . By the Central Limit Theorem:
n i=1
n
Y p(1 − p)
p̂ = = X̄ ∼ AN (p, ) (7..2)
n n
59).0 t Distribution
The t-distribution is a probability distribution similar to the standard normal distribution, but this one can be
done without knowing the standard deviation of the population. When comparing the normal distribution versus t-
distribution, we see that the graph t-distribution has tails which are bigger or fatter than the standard normal distribu-
tion, which means that there is a higher probability of finding a data point in one of the tails than when working with
a normal distribution. That is one reason t-distribution graphs look shorter than the normal distribution, because more
of its area is gone to the tails.
If we standardize Ȳ , we obtain
Ȳ − µ
Z= √ ∼ N (0, 1) (7..3)
σ/ n
However, population standard deviation σ is usually unknown. Replacing it with the sample standard deviation s,
we get a new sampling distribution:
Ȳ − µ
t = √ ∼ t(n − 1) (7..4)
s/ n
which is called t distribution with degrees of freedom ν = n − 1
The t distribution has the following characteristics:
It is continuous and symmetric about 0
It is indexed by a value ν called the degrees of freedom
As ν −→ ∞, t(ν) −→ N (0, 1)
When compared to the standard normal distribution, the t distribution in general, is less peaked and has more proba-
bility (area) in the tails, i.e., heavy tails
59).1 t Tables
What is t curve tail areas?
The ”tail area” of a t-curve refers to the region under the t-distribution curve that falls outside a specified range or
interval. It represents the probability of observing a t-statistic value more extreme than the specified range.
Page 76 of 160
STATISTICS OVERVIEW
Explanation:
Tails: The tails of the t-distribution are the regions on either side of the curve that extend out into the extreme ends.
These regions represent the probability of observing values that are significantly different from the mean
Tail Area: The area under the curve in the tails represents the probability of observing a t-statistic value that is more
extreme (either larger or smaller) than a specific value. This area is often used to determine the statistical significance
of a result, such as in a t-test.
How to determine the tail area?
1. Degrees of freedom: The shape of the t-distribution is determined by its degrees of freedom (df ), which is
typically related to the sample size. Smaller df values result in thicker tails.
2. Significance level (α): The significance level (α) is a threshold used to determine statistical significance. It
represents the probability of incorrectly rejecting the null hypothesis when it is true.
3. t-value: A t-value is a measure of how far a sample statistic is from the population parameter under the null
hypothesis.
4. t-distribution table: Use a t-distribution table to find the tail area corresponding to a given t-value and degrees
of freedom. The table typically provides the areas to right of a t-value
1. Determine the Degrees of Freedom (df ): Degrees of freedom depend on sample size and the type of t-test
being used (one-sample, independent samples, paired samples)
2. Choose significance level (α): α represents the probability of rejecting the null hypothesis when it’s actually
true (type I error). Common α levels are 0.05, 0.01 or 0.10
3. Locate the t-table: Most t-tables have df listed in the leftmost column and α levels in the top row
4. Find the critical t-value:
Two-tailed test: use the α level directly from the top row (e.g., 0.05)
One-tailed test: Used in only one direction (e.g., greater than or less than), find the α level had been used for a
two-tail test (e.g., 0.05/2 = 0.025, in the top row)
5. Interpret the results: Compared your calculated t-statistic to the critical t-value
If t-statistic is more extreme than the critical t-value (either larger in magnitude if the test is two-tailed, or larger
in the appropriate direction if the test is one-tailed), then your results are statistically significant.
If t-statistic is less extreme than the critical t-value, then your results are not statistically significant.
Page 77 of 160
STATISTICS OVERVIEW
t DISTRIBUTION TABLE
cum. prob. t0.50 t0.75 t0.80 t0.85 t0.90 t0.95 t0.975 t0.98 t0.99 t0.995 t0.9975 t0.999 t0.9995
one-tailed (α/2) 0.50 0.25 0.20 0.15 0.10 0.05 0.025 0.02 0.01 0.005 0.0025 0.001 0.0005
two-tailed (α) 1.00 0.50 0.40 0.30 0.20 0.10 0.05 0.04 0.02 0.01 0.005 0.002 0.001
df = n − 1
1 0.000 1.000 1.376 1.963 3.078 6.314 12.71 15.89 31.82 63.66 127.3 318.3 636.6
2 0.000 0.816 1.061 1.386 1.886 2.920 4.303 4.849 6.965 9.925 14.09 22.33 31.60
3 0.000 0.765 0.978 1.250 1.638 2.353 3.182 3.482 4.541 5.841 7.453 10.215 12.92
4 0.000 0.741 0.941 1.190 1.533 2.132 2.776 2.99 3.747 4.604 5.598 7.173 8.610
5 0.000 0.727 0.920 1.156 1.476 2.015 2.571 2.757 3.365 4.032 4.773 5.893 6.869
6 0.000 0.718 0.906 1.134 1.440 1.943 2.447 2.612 3.143 3.707 4.317 5.208 5.959
7 0.000 0.711 0.896 1.119 1.415 1.895 2.365 2.517 2.998 3.499 4.029 4.785 5.408
8 0.000 0.706 0.889 1.108 1.397 1.860 2.306 2.449 2.896 3.355 3.833 4.501 5.041
9 0.000 0.703 0.883 1.100 1.383 1.833 2.262 2.398 2.821 3.250 3.690 4.297 4.781
10 0.000 0.700 0.879 1.093 1.372 1.812 2.228 2.359 2.764 3.169 3.581 4.144 4.587
11 0.000 0.697 0.876 1.088 1.363 1.796 2.201 2.328 2.178 3.106 3.497 4.025 4.437
12 0.000 0.695 0.873 1.083 1.356 1.782 2.179 3.303 2.681 3.055 3.428 3.930 4.318
13 0.000 0.694 0.870 1.079 1.350 1.771 2.160 2.282 2.650 3.012 3.372 3.852 4.221
14 0.000 0.692 0.868 1.076 1.345 1.761 2.145 2.264 2.624 2.977 3.326 3.787 4.140
15 0.000 0.691 0.866 1.074 1.341 1.753 2.131 2.249 2.602 2.947 3.286 3.733 4.073
16 0.000 0.690 0.865 1.071 1.337 1.746 2.120 2.235 2.583 2.921 3.252 3.686 4.015
17 0.000 0.689 0.863 1.069 1.333 1.740 2.110 2.224 2.567 2.898 3.222 3.646 3.965
18 0.000 0.688 0.862 1.067 1.330 1.734 2.101 2.214 2.552 2.878 3.197 3.611 3.922
19 0.000 0.688 0.861 1.066 1.328 1.729 2.093 2.205 2.539 2.861 3.174 3.579 3.883
20 0.000 0.687 0.860 1.064 1.325 1.725 2.086 2.197 2.528 2.845 3.153 3.552 3.850
21 0.000 0.686 0.859 1.063 1.323 1.721 2.080 2.189 2.518 2.831 3.135 3.527 3.819
22 0.000 0.686 0.858 1.061 1.321 1.717 2.074 2.183 2.508 2.819 3.119 3.505 3.792
23 0.000 0.685 0.858 1.060 1.319 1.714 2.069 2.177 2.500 2.807 3.104 3.485 3.768
24 0.000 0.685 0.857 1.059 1.318 1.711 2.064 2.172 2.492 2.797 3.091 3.467 3.745
25 0.000 0.684 0.856 1.058 1.356 1.708 2.060 2.167 2.485 2.787 3.078 3.450 3.725
26 0.000 0.684 0.856 1.058 1.315 1.706 2.056 2.162 2.479 2.779 3.067 3.435 3.707
27 0.000 0.684 0.855 1.057 1.314 1.703 2.052 2.150 2.473 2.771 3.057 3.421 3.690
28 0.000 0.683 0.855 1.056 1.313 1.701 2.048 2.154 2.467 2.763 3.047 3.408 3.674
29 0.000 0.683 0.854 1.055 1.311 1.699 2.045 2.150 2.462 2.756 3.038 3.396 3.659
30 0.000 0.683 0.854 1.055 1.310 1.697 2.042 2.147 2.457 2.750 3.030 3.385 3.646
31 0.000 0.683 0.854 1.055 1.309 1.696 2.040 2.144 2.453 2.745 3.023 3.375 3.634
32 0.000 0.683 0.854 1.054 1.309 1.694 2.037 2.141 2.449 2.739 3.016 3.366 3.622
33 0.000 0.683 0.853 1.054 1.308 1.693 2.035 2.139 2.445 2.734 3.009 3.357 3.611
34 0.000 0.682 0.853 1.053 1.307 1.691 2.033 2.136 2.442 2.729 3.002 3.348 3.601
35 0.000 0.682 0.853 1.053 1.306 1.690 2.031 2.134 2.438 2.724 2.997 3.341 3.592
36 0.000 0.682 0.852 1.052 1.306 1.689 2.029 2.131 2.435 2.720 2.991 3.333 3.583
37 0.000 0.682 0.852 1.052 1.305 1.688 2.027 2.129 2.432 2.716 2.986 3.326 3.574
38 0.000 0.682 0.852 1.051 1.304 1.686 2.025 2.127 2.429 2.712 2.981 3.320 3.566
39 0.000 0.681 0.851 1.051 1.304 1.685 2.023 2.125 2.426 2.708 2.976 3.313 3.559
40 0.000 0.681 0.851 1.051 1.303 1.684 2.021 2.123 2.423 2.704 2.971 3.307 3.551
50 0.000 0.679 0.849 1.047 1.295 1.676 2.009 2.109 2.403 2.678 2.937 3.261 3.496
60 0.000 0.679 0.848 1.045 1.296 1.671 2.000 2.099 2.390 2.660 2.915 3.232 3.460
80 0.000 0.678 0.846 1.043 1.292 1.664 1.990 2.088 2.374 2.639 2.887 3.195 3.416
100 0.000 0.677 0.845 1.042 1.290 1.660 1.984 2.081 2.364 2.626 2.871 3.174 3.390
1000 0.000 0.675 0.842 1.037 1.282 1.646 1.962 2.056 2.330 2.581 2.813 3.098 3.300
∞ 0.000 0.674 0.841 1.036 1.282 1.645 1.960 2.054 2.326 2.576 2.807 3.090 3.291
(100 − α)% 0% 50% 60% 70% 80% 90% 95% 96% 98% 99% 99.5% 99.8% 99.9%
Page 78 of 160
Table 7..1: t-Distribution Table
STATISTICS OVERVIEW
Using a point estimator ignores important information: namely, how variable the estimator is
To avoid this problem (i.e., to account for the uncertainty in the sampling procedure), we therefore pursue the topic of
interval estimation (also known as confidence intervals)
The main difference between a point estimate and an interval estimate is:
a point estimate: one-shot guess at the value of the parameter; this ignores the variability in the estimate
an interval estimate (i.e., confidence interval): the interval of values. It is formed by taking the point estimate and
then adjusting it downwards and upwards to account for the point estimate’s variability
The 95% confidence comes from the fact that if we repeated this experiment over and over again, approximately, 95%
of all samples would produce a confidence interval that contains the true proportion, and only 5% of the time would
the interval be in error.
We call 100(1 − α)% the confidence level and α the significance level
Confidence level 50% 60% 70% 75% 80% 85% 90% 95% 97% 98% 99% 99.5% 99.9%
Two-tailed (α) 0.500 0.400 0.300 0.250 0.200 0.150 0.100 0.050 0.030 0.020 0.010 0.005 0.001
One-tailed (α/2) 0.250 0.200 0.150 0.125 0.100 0.075 0.050 0.025 0.015 0.010 0.005 0.0025 0.0005
z-score 0.675 0.250 1.036 1.150 1.282 1.440 1.645 1.960 2.170 2.326 2.576 2.810 3.291
Page 79 of 160
STATISTICS OVERVIEW
Solution
30
Sample proportion p̂ = = 0.12
250
Confidence level = 95% ⇒ zα/2 = 1.96
r r
p̂(1 − p̂) 0.12(1 − 0.12)
Standard error = = = 0.0205
n 250
95% confidence interval: [0.12 − 1.96(0.0205), 0.12 + 1.96(0.0205)] = (0.0798, 0.1602)
The 95% confidence interval (0.0798, 0.1602) does not include the historical flu rate of 7%
⇒ there is strong evidence to suggest that the true proportion of flu carriers in Columbia is higher than the historical
rate, indicating a potential outbreak. Since the lower bound of the confidence interval is above 7%, it’s highly likely
that the outbreak is not due to chance
Example: The fraction of defective integrated circuits produced in a photolithohraphy process is being studied. A
random sample of 300 circuits is tested, revealing 13 defectives.
(a) Calculate a 95% CI on the fraction of defective circuits.
(b) Calculate a 99% CI on the fraction of defective circuits.
Solution
13
Sample proportion: p̂ = = 0.0433
300
(a) Confidence level = 95% ⇒ zα/2 = 1.96
r r
0.0433(1 − 0.0433) 0.0433(1 − 0.0433)
95% confidence interval = (0.0433 − 1.96 , 0.0433 + 1.96 )
300 300
⇒ 95% confidence interval = (0.0203, 0.0663)
(b) Confidence level = 99% ⇒ zα/2 = 2.576
r r
0.0433(1 − 0.0433) 0.0433(1 − 0.0433)
99% confidence interval = (0.0433 − 2.576 , 0.0433 + 2.576 )
300 300
⇒ 99% confidence interval = (0.0130, 0.0736)
For a binary random variable, we have discussed how to estimate the population proportion using point estimate and
confidence interval.
Now, it’s time to move on to the case when the random variable is numerical and learn some methods to make an in-
ference for the population mean µ.
Solution
Page 80 of 160
STATISTICS OVERVIEW
σ2 0.16
var(Ȳ ) = = = 0.032
n 5 √ √
σ σ2 0.16
⇒ Distribution of sample mean Ȳ : Ȳ ∼ N (1.5, 0.032) with se(Ȳ ) = √ = √ = √ = 0.1789
n n 5
Ȳ − µ
Z= √ ∼ N (0, 1) (7..8)
σ/ n
σ σ
(ȳ − zα/2 √ , ȳ + zα/2 √ ) (7..9)
n n
Ȳ − µ
t= √ ∼ t(n − 1) (7..10)
S/ n
(n − 1)S 2
Q= ∼ χ2 (n − 1) (7..12)
σ2
Page 81 of 160
STATISTICS OVERVIEW
Proof: Let χ2n−1,α/2 denote the upper α/2 quantile and χ2n−1,1−α/2 denote the lower α/2 quantile of the χ2 (n − 1)
distribution, satisfy
P (Q > χ2n−1,α/2 ) = α/2
P (Q < χ2n−1,1−α/2 ) = α/2
Unlike the N (0, 1) and t distributions, the χ distribution is not symmetric.
2
Because Q ∼ χ2 (n − 1):
1 − α = P (χ2n−1,1−α/2 < Q < χ2n−1,α/2 )
(n − 1)S 2
⇔ 1 − α = P [χ2n−1,1−α/2 < < χ2n−1,α/2 ]
σ2
1 σ2 1
⇔ 1 − α = P[ 2 < < 2 ]
χn−1,1−α/2 (n − 1)S 2 χn−1,α/2
(n − 1)S 2 (n − 1)S 2
⇔ 1 − α = P[ 2 < σ2 < 2 ]
χn−1,α/2 χn−1,1−α/2
Note
Unlike the z and t confidence intervals for a population mean µ, the 2 interval for σ 2 (and for σ) is not robust to
departures from normality
If the underlying population distribution is non-normal (non-Guassian), then the confidence interval formulas
for σ 2 and σ are not to be used.
It is very important to “check” the normality assumption with these interval procedures (use a qq-plot)
Noting that
Ȳ − Yn+1
t= r ∼ tn−1 (7..15)
1
S 1+
n
where Yn+1 is a single future observation
Page 82 of 160
STATISTICS OVERVIEW
Solution
P25
Yi 1.296 + 1.320 + 1.311 + ... + 1.315 + 1.306 + 1.289 + 1.291 32.477
Ȳ = i=1 = = = 1.299
n 25 25
(a) Confidence level = 95% ⇒ zα/2 = 1.96
σ σ 0.02 0.02
95% confidence interval = (ȳ − zα/2 √ , ȳ + zα/2 √ ) = (1.299 − 1.96 √ , 1.299 + 1.96 √ ) = (1.291, 1.307)
n n 25 25
α
(b) 100(1 − α)% = 95% ⇒ α = 0.05 ⇒ = 0.025
2
Degree of freedom df = n − 1 = 25 − 1 = 24 ⇒ tn−1,α/2 = 2.064
P25
(yi − ȳ)2 (1.296 − 1.299)2 + ... + (1.291 − 1.299)2 0.002948
Sample variance s2 = i=1 = = = 0.0001228
n−1 √ √ 25 − 1 24
⇒ sample standard deviation s = s2 = 0.0001228 = 0.0111
S S 0.0111 0.0111
95% confidence interval = (ȳ − tn−1,α/2 √ , ȳ + tn−1,α/2 √ ) = (1.299 − 2.064 √ , 1.299 + 2.064 √ )
n n 25 25
⇒ 95% confidence interval = (1.294, 1.304)
1. On the vertical axis, we plot the observed data, ordered from low to high
2. On the horizontal axis, we plot the (ordered) theoretical quantiles from the distribution assumed for the observed
data (here, norma)
Page 83 of 160
STATISTICS OVERVIEW
In a planning stage of an experiment or investigation, it is often of interest to determine how many individuals are
needed to construct a confidence interval with a given level of confidence.
For example, we might want to construct a 95 percent confidence interval for a population mean, so that the interval
length is no more than 5 units (e.g., days, inches, dollars, etc.).
Sample size determination is also associated with the practical issues like cost, time spent in data collection, personnel
training, etc
Suppose that Y1 , Y2 , ..., Yn is a random sample from a N (µ, σ 2 ) population with σ 2 known. Recall that a 100(1α)% CI
for µ is given by
σ
Ȳ ± zα/2 √ (7..17)
n
| {z }
B
σ
where B = zα/2 √ is called the margin of error
n
It is possible to determine the sample size n once we specify these three pieces of information:
the value of σ 2 (or an educated guess at its value; e.g., from past information, etc.)
the confidence level, 100(1 − α)%
the margin of error, B.
Then we have
σ σzα/2 2
B = zα/2 ( √ ) ⇐⇒ n = ( ) (7..18)
n B
Example: In a bio-medical experiment, we would like to estimate the population mean, remaining life of healthy rats
that are given a certain dose of a toxic substance. Suppose that we would like to write a 95 percent confidence interval
with a margin of error equal to B = 2 days. From past studies, remaining rat lifetimes have been approximated by a
normal distribution with standard deviation = 8 days. How many rats should we use for the experiment?
Solution
Example: Assume that the helium porosity of coal samples taken from any particular seam is normally distributed with
true standard deviation 0.75.
(a) Compute a 95% CI for the true average porosity of a certain seam if the average porosity for 20 specimens from the
seam was 4.85.
(b) Compute a 98% CI for the true average porosity of a certain seam if the average porosity for 16 specimens from the
Page 84 of 160
STATISTICS OVERVIEW
Solution
Note
1
The margin of error = Width
2
1
B= W (7..19)
2
Example: Suppose that a researcher is interested in the mean number of movies that American adults see in the movie
theater per year. Using a random sample of 16 adults, he finds that the mean for the sample is 6 and the standard
deviation is 2. (a) Find the degrees of freedom and t-score to calculate a 99% confidence interval.
(b) Find a 99% confidence interval for the population parameter of interest.
(c) Write a thorough interpretation of the confidence interval.
(d) Based on your confidence interval, is it plausible that the mean number of movies that American adults see in the
movie theater per year is 9?
Solution
Page 85 of 160
STATISTICS OVERVIEW
There are typically three ways to test hypotheses: the confidence interval approach, the critical value approach, and the
p-value approach.
Note
Hypothesis testing using confidence interval:
Construct a 100(1α)% confidence interval for the true proportion
If the entire confidence interval lies above p0 , then the claim that Ha : p > p0 is supported.
If the confidence interval includes p0 or is entirely below p0 , then the claim is not supported
If the lower bound of this interval is greater than p0 , then the claim is supported.
Page 86 of 160
STATISTICS OVERVIEW
p(1 − p)
p̂ ∼ AN (p, ) (8..1)
n
To control the type I error, recalling that the type I error is under the assumption H0 is in fact true
So when H0 is true ⇒ p = p0 :
p0 (1 − p0 )
p̂ ∼ AN (p0 , ) (8..2)
n
Then
p̂ − p0
z0 = r ∼ AN (0, 1) (8..3)
p0 (1 − p0 )
n
Null hypothesis:
H0 : p = p 0
Alternative hypothesis:
Ha : p < p0
Ha : p > p0
Ha : p ̸= p0
The test statistics (Critical value approach)
1. Compute the test statistics:
p̂ − p0
z0 = r ∼ AN (0, 1)
p0 (1 − p0 )
n
2. Find the corresponding rejection region:
Hypothesis type Alternative hypothesis Rejection criterion
Left-tail hypothesis Ha : p < p0 z0 < −zα
Right-tail hypothesis Ha : p > p0 z0 > zα
Two-tail hypothesis Ha : p ̸= p0 z0 > zα/2 or z0 < −zα/2
p̂ − p0
z0 = r ∼ AN (0, 1)
p0 (1 − p0 )
n
2. Find the corresponding rejection region:
Hypothesis type Alternative hypothesis Rejection criterion
Left-tail hypothesis Ha : p < p0 p-value = P (z < z0 ) = Φ(z0 ) < α
Right-tail hypothesis Ha : p > p0 p-value = P (Z > z0 ) = 1 − Φ(z0 ) < α
Two-tail hypothesis Ha : p ̸= p0 p-value = 2P (Z < −|z0 |) = 2[1 − Φ(|z0 |)] < α
Example: Suppose that 500 parts are tested in manufacturing and 10 are rejected. Using both the approaches (critical
Page 87 of 160
STATISTICS OVERVIEW
value approach and P -value approach) to test the hypothesis H0 : p = 0.03 against Ha : p < 0.03 at significance level
α = 0.05.
Solution
10
Sample proportion p̂ = = 0.02
500
Null hypothesis:
H0 : p = 0.03 where p0 = 0.03
Alternative hypothesis:
Ha : p < 0.03 where p0 = 0.03
Sol 1: Critical value approach
p̂ − p0 0.02 − 0.03
Test statistics: z0 = r =r = −1.31
p0 (1 − p0 ) 0.03(1 − 0.03)
n 500
zα = z0.05 = 1.645
−1.31 > −1.645 ⇒ fail to reject H0
Conclusion: At 5% significance level, the data do not provide sufficient evidence to conclude that the real popu-
lation mean is less than 3%
Sol 2: p-value
p̂ − p0 0.02 − 0.03
Test statistics: z0 = r =r = −1.31
p0 (1 − p0 ) 0.03(1 − 0.03)
n 500
p-value = P (Z < −1.31) = 1 − Φ(1.31) = 1 − 0.9049 = 0.0951
p-value > α ⇒ fail to reject H0
Conclusion: At 5% significance level, the data do not provide sufficient evidence to conclude that the real popu-
lation mean is less than 3%
Page 88 of 160
STATISTICS OVERVIEW
Solution
H0 : p0 = 0.07
Ha : pa > 0.07
30
Sample proportion p̂ = = 0.12
250
p̂ − p0 0.12 − 0.07
Test statistics z0 = r =r = 3.10
p0 (1 − p0 ) 0.07(1 − 0.07)
n 250
Because p > p0 ⇒ p-value = P (Z > z0 ) = P (Z > 3.10) = 1 − P (Z ≤ 3.10) = 1 − Φ(3.10) = 1 − 0.9990 =
0.001
Since p-value < α ⇒ reject H0
⇒ There is sufficient evidence to conclude that there is an outbreak in Columbia
Example: Lenses
A manufacturer of inter-ocular lenses will qualify a new grinding machine if there is evidence that the percentage of
polished lenses that contain surface defects does not exceed 2%. A random sample of 250 lenses contains 6 defective
lenses
(a) Formulate and test an appropriate set of hypotheses to determine whether the machine can be qualified. Use α = 0.01.
Find the p-value.
(b) Explain how the previous question could be answered with a confidence interval.
Solution
(a)
H0 : p ≥ 0.02
Ha : p < 0.02
6
Sample proportion p̂ = = 0.024
250
Page 89 of 160
STATISTICS OVERVIEW
p̂ − p0 0.024 − 0.02
Test statistics z0 = r =r = 0.45
p0 (1 − p0 ) 0.02(1 − 0.02)
n 250
Because p < p0 ⇒ p-value = P (Z < z0 ) = Φ(z0 ) = Φ(0.45) = 0.6736
Since p-value > α ⇒ H0 is not rejected
⇒ There is not enough evidence to conclude that the percentage of defective lenses is less than 2%.
⇒ the machine cannot be qualified
(b) Construct a 99% upper confidence bound for the proportion of defective lenses. If this upper bound is less than
2%, then the machine can be qualified.
α
= 0.01 = P (Z > zα/2 ) = 1 − P (Z ≤ zα/2 ) = 1 − Φ(zα/2 ) ⇒ Φ(zα/2 ) = 0.99 ⇒ zα/2 = 2.33
2 r r
p̂(1 − p̂) p̂(1 − p̂)
99% CI = (p̂ − zα/2 p̂ − zα/2 )
nr n r
0.024(1 − 0.024) 0.024(1 − 0.024)
⇒ 99% CI = (0.024 − 2.33 , 0.024 + 2.33 )
250 250
⇒ 99% CI = (0.00145, 0.0466)
Since the upperbound of 4.66% is greater than 2% ⇒ the machine cannot be qualified
If the p-value of your test is lower than the significance level, it means your results are statistically significant and
consistent with the alternative hypothesis
If your p-value is higher than the significance level, then your results are considered statistically non-significant.
To reduce the Type I error probability, you can simply set a lower significance level.
Page 90 of 160
STATISTICS OVERVIEW
At the tail end, the shaded area represents α. It’s also called a critical region in statistics.
If your results fall in the critical region of this curve, they are considered statistically significant and the null hypothesis
is rejected.
Because this is a false positive conclusion, the H0 is actually true in this case
Note
Typically, when designing a hypothesis test one controls (or specifies) the type I error probability.
It is common to specify values of 0.10, 0.05, and 0.01 for α, but these values may not be appropriate in all situations
The risk of a Type II error is inversely related to the statistical power of a study.
The higher the statistical power, the lower the probability of making a Type II error.
These two probabilities are complementary.
Statistical power is determined by:
Size of the effect: Larger effects are more easily detected.
Measurement error: Systematic and random errors in recorded data reduce power.
Sample size: Larger samples reduce sampling error and increase power.
Significance level: Increasing the significance level increases power.
To (indirectly) reduce the risk of a Type II error, you can increase the sample size or the significance level.
Page 91 of 160
STATISTICS OVERVIEW
The Type II error rate is β, represented by the shaded area on the left side.
The remaining area under the curve represents statistical power, which is 1 − β.
Increasing the statistical power of your test directly decreases the risk of making a Type II error.
Hypothesis
Type Probability
H0 Ha
P (Type I error) = P (Z ≥ z0 )
Right-tail test H0 : µ = µ0 Ha : µ > µ0
P (Type II error) = P (Z < z0 )
P (Type I error) = P (Z < z0 )
Left-tail test H0 : µ = µ0 Ha : µ < µ0
P (Type II error) = P (Z ≥ z0 )
P (Type I error) = α
Two-tail test H0 : µ = µ0 Ha : µ ̸= µ0
P (Type II error) = 1 − Power
You are planning to hold a party for our STAT 355 class, and you want to know at 95% confidence level, whether less
than 60% of students will attend.
H0 : p = 0.6
Page 92 of 160
STATISTICS OVERVIEW
Ha : p < 0.6
(a) Describe a Type I error for this problem and the potential consequence.
(b) Describe a Type II error for this problem and the potential consequence.
Solution
Page 93 of 160
STATISTICS OVERVIEW
Note
Recall that Φ(z0 ) is the cumulative distribution function of the standard normal distribution; i.e., Φ(z) = P (Z ≤
z).
Page 94 of 160
STATISTICS OVERVIEW
i.e., the light intensity near the sign. It is believed that the mean surround luminance is 10 candela per m2 in a large
metropolitan area. The data below are n = 30 measurements of the random variable X, the surround luminance (in
candela per m2 ). The 30 measurements constitute a random sample from all the signs in the large metropolitan area in
question:
10.9 1.7 9.5 2.9 9.1 3.2 9.1 7.4 13.3 13.1
6.6 13.7 1.5 6.3 7.4 9.9 13.6 17.3 3.6 4.9
13.1 7.8 10.3 10.3 9.6 5.7 2.6 15.1 2.9 16.2
Based on past experience, the engineers assume a normal population distribution (for the population of all signs) with
known population variance σ 2 = 20. From this data what conclusions should we draw about the hypothesized mean
surround luminance, at the α = 0.05 significance level.
Solution
P
x 10.9 + 1.7 + ... + 2.9 + 16.2 258.6
x̄ = i = = = 8.62
n 10 30
Null hypothesis:
H0 : µ = µ0 where µ0 = 10
Alternative hypothesis:
Ha : µ ̸= µ0 where µ0 = 10
Sol 1: Confidence interval approach
α = 0.05 ⇒ confidence level = 95% ⇒ zα/2 = 1.960
√ √
σ σ 20 20
95% CI = (x̄ − zα/2 √ , x̄ + zα/2 √ ) = (8.62 − 1.96 √ , 8.62 + 1.96 √ ) = (7.02, 10.22)
n n 30 30
µ0 ∈ (7.02, 10.22) ⇒ fail to reject H0
Conclusion: At the 5% significance level, the data do not provide sufficient evidence to conclude that the mean
surround luminance for the specified large metropolitan area differs from 10 candela per m2 .
Sol 2: Critical value apporach
x̄ − µ0 8.62 − 10
Test statistic: z0 = √ =√ √ = −1.69
σ/ n 20/ 30
α = 0.05 ⇒ confidence level = 95% ⇒ zα/2 = 1.960
−1.69 < 1.96 and −1.69 > −1.960 ⇒ fail to reject H0
Conclusion: At the 5% significance level, the data do not provide sufficient evidence to conclude that the mean
surround luminance for the specified large metropolitan area differs from 10 candela per m2 .
Sol 3: p-value approach
x̄ − µ0 8.62 − 10
Test statistics z0 = √ =√ √ = −1.69
σ/ n 20/ 30
p-value = 2P (Z < −|z0 |) = 2[1 − Φ(z0 )] = 2[1 − Φ(1.69)] = 2[1 − 0.9545] = 0.091
p-value > α ⇒ fail to reject H0
Conclusion: At the 5% significance level, the data do not provide sufficient evidence to conclude that the mean
surround luminance for the specified large metropolitan area differs from 10 candela per m2 .
Page 95 of 160
STATISTICS OVERVIEW
H0 : µ = µ0
Alternative hypothesis:
Ha : µ < µ0
Ha : µ > µ0
Ha : µ ̸= µ0
Confidence interval approach
1. Find the right type of confidence interval.
2. Find the corresponding rejection region:
Hypothesis type Alternative hypothesis Rejection criterion
s
Left-tail hypothesis Ha : µ < µ0 x̄ + tn−1,α √ < µ0
n
s
Right-tail hypothesis Ha : µ > µ0 x̄ − tn−1,α √
n
s
Two-tail hypothesis Ha : µ ̸= µ0 µ0 ∈/ (x̄ ± tn−1,α/2 √ )
n
3. Compare: find whether or not the rejection criterion is satisfied
4. Conclusions: At α% significance level, the data (do or do not) provide sufficient evidence to conclude
that the real population mean is (less than, greater than, or differs from) .
The test statistics (Critical value approach)
1. Compute the test statistics:
x̄ − µ0
t0 = √ (8..9)
s/ n
2. Find the corresponding rejection region:
Hypothesis type Alternative hypothesis Rejection criterion
Left-tail hypothesis Ha : µ < µ0 t0 < −tn−1,α
Right-tail hypothesis Ha : µ > µ0 t0 > tn−1,α
Two-tail hypothesis Ha : µ ̸= µ0 t0 > tn−1,α/2 or t0 < −tn−1,α/2
Note
If you are working with a two-tailed test don’t forget to divide the alpha value by 2 to find the correct t-value.
Example: Civil engineers have found that the ability to see and read a sign at night depends in part on its “surround
luminance;” i.e., the light intensity near the sign. It is believed that the mean surround luminance is 10 candela per m2 in
a large metropolitan area. The data below are n = 30 measurements of the random variable X, the surround luminance
Page 96 of 160
STATISTICS OVERVIEW
(in candela per m2 ). The 30 measurements constitute a random sample from all the signs in the large metropolitan area
in question:
10.9 1.7 9.5 2.9 9.1 3.2 9.1 7.4 13.3 13.1
6.6 13.7 1.5 6.3 7.4 9.9 13.6 17.3 3.6 4.9
13.1 7.8 10.3 10.3 9.6 5.7 2.6 15.1 2.9 16.2
Based on past experience, the engineers assume a normal population distribution (for the population of all signs). From
this data what conclusions should we draw about the hypothesized mean surround luminance, at the α = 0.05 signifi-
cance level.
Solution
P
x 10.9 + 1.7 + ... + 2.9 + 16.2 258.6
x̄ = i = = = 8.62
n 10 30
2
(10.9 − 8.62) + ... + (16.2 − 8.62)2
2
P
(x − x̄)
s2 = i = = 20.43
n−1 30 − 1
tn−1,α/2 = t29,0.025 = 2.045
Null hypothesis:
H0 : µ = µ0 where µ0 = 10
Alternative hypothesis:
Ha : µ ̸= µ0 where µ0 = 10
Sol 1: Confidence interval approach
α = 0.05 ⇒ confidence level = 95%
s s
95% CI = (x̄ − tn−1,α/2 √ , x̄ + tn−1,α/2 √ )
n√ n √
20.43 20.43
↔ 95% CI = (8.62 − 2.045 √ , 8.62 + 2.045 √ ) = (6.932, 10.31)
30 30
µ0 ∈ (6.932, 10.31) ⇒ fail to reject H0
Conclusion: At the 5% significance level, the data do not provide sufficient evidence to conclude that the mean
surround luminance for the specified large metropolitan area differs from 10 candela per m2
Sol 2: Critical value approach
x̄ − µ0 8.62 − 10
Test statistics: t0 = √ =√ √ = −1.67
s/ n 20.43/ 30
Critical value = tn−1,α = 2.045
−1.67 < 2.045 and −1.67 > −2.045 ⇒ fail to reject H0
Conclusion: At the 5% significance level, the data do not provide sufficient evidence to conclude that the mean
surround luminance for the specified large metropolitan area differs from 10 candela per m2
Sol 3: p-value approach
x̄ − µ0 8.62 − 10
Test statistics: t0 = √ =√ √ = −1.67
s/ n 20.43/ 30
1.311 < |t0 | < 1.699 ⇒ 0.1 < p-value < 0.2
0.1 > 0.05 ⇒ p-value > α ⇒ fail to reject H0
Conclusion: At the 5% significance level, the data do not provide sufficient evidence to conclude that the mean
surround luminance for the specified large metropolitan area differs from 10 candela per m2
Solution
Page 97 of 160
STATISTICS OVERVIEW
H0 : µ = 1.31
P25 Ha : µ ̸= 1.31
Yi 1.296 + 1.320 + 1.311 + ... + 1.315 + 1.306 + 1.289 + 1.291 32.477
Ȳ = i=1 = = = 1.299
n 25 25
1.299 − 1.31
z0 = √ = −2.75
0.02/ 25
Because µ ̸= µ0 ⇒ p-value = 2P (Z < −|z0 |) = 2P (Z < −| − 2.5|) = 2P (Z < −2.75) = 2(0.0030) = 0.006
Since p-value < α ⇒ reject H0
⇒ There is sufficient evidence to conclude the mean pipe diameter is not 1.31 inches
Solution
H0 : µ ≥ 1.308
P25 Ha : µ < 1.308
Yi 1.296 + 1.320 + 1.311 + ... + 1.315 + 1.306 + 1.289 + 1.291 32.477
Ȳ = i=1 = = = 1.299
n P25 25 25
2 2 2
(yi − ȳ) (1.296 − 1.299) + ... + (1.291 − 1.299) 0.002948
Sample variance s2 = i=1 = = = 0.0001228
n−1 √ √ 25 − 1 24
⇒ sample standard deviation s = s2 = 0.0001228 = 0.0111
Ȳ − µ0 1.299 − 1.308
t= √ = √ = −4.05
s/ n 0.0111/ 25
Degree of freedom ν = n − 1 = 25 − 1 = 24
α
α = 0.05 ⇒ = 0.025 ⇒ tα/2 = t0.025,24 = 2.064
2
Because t < tα/2 ⇒ reject H0
⇒ There is sufficient evidence that the pipe diameter is less than 1.308
1 > t . t e s t ( p i p e s , a l t e r n a t i v e = ” l e s s ” , mu = 1 . 3 0 8 )
2 One Sample t − t e s t
3 data : pipes
4 t = − 4 . 0 2 4 3 , d f = 2 4 , p− v a l u e = 0 . 0 0 0 2 4 7 8
5 a l t e r n a t i v e h y p o t h e s i s : t r u e mean i s l e s s t h a n 1 . 3 0 8
6 95 p e r c e n t c o n f i d e n c e i n t e r v a l :
7 −Inf 1.302872
8 sample e s t i m a t e s :
9 mean o f x
10 1.29908
Example: Sales
For a long time, the monthly average sales for a product have been $30, 000. A company invests a lot of money into
new advertising for the product and then conducts a hypothesis test with a level of significance 0.05 in order to see
if monthly sales of the product have increased. The hypotheses are: H0 : µ = 30, 000 and Ha : µ > 30, 000. The
conclusion of the test is that monthly sales have increased.
(a) What is the probability of type I error for this test?
(b) Suppose in reality, monthly sales did not increase and the advertisment had no effect? What type of error occurred?
Solution
(a) The significance level α represents the probability of committing a type I error. It’s the threshold for rejecting
the null hypothesis
⇒ p = α = 0.05
Page 98 of 160
STATISTICS OVERVIEW
(b) H0 : µ = 30, 000 while the conclusion is that the monthly sales µ > 30, 000 which mean H0 is rejected
While in reality, monthly sales did not increase and the advertisement had no effect ⇒ H0 : µ = 30, 000 is true
⇒ H0 is rejected but in reality H0 is true ⇒ type I error
True or False
(a) If we reject H0 : µ = 0 in a study with α = 0.01, then we also reject it with α = 0.05.
(b) A study about the change in weight on a new diet reports p-value = 0.043 for testing H0 : µ = 0 against Ha : µ ̸= 0
under α = 0.05. If the authors report a 95% confidence interval for µ, then the interval would contain 0.
(c) A 95% C.I. for µ = population mean IQ is (96, 110). In the test of H0 : µ = 100 against Ha : µ ̸= 100, the p-value
would be greater than 0.05.
(d) When testing H0 : µ = 100 against Ha : µ ̸= 100, the probability of a Type II error decreases when the true
population mean is further away from 100.
Solution
(a) If H0 is rejected at α = 0.01 ⇒ p-value < 0.01 ⇒ p-value < 0.05 ⇒ TRUE
(b) A 95% confidence interval is equivalent to a two-sided significance test at α = 0.05
Since p-value is 0.043, H0 : µ = 0 is rejected at α = 0.05 ⇒ 0 is not one of the plausible values
⇒ it is not within the 95% confidence interval ⇒ FALSE
(c) 100 is within the 95% confidence interval, µ = 100 is plausible ⇒ H0 : µ = 100 will not be rejected (p-value
> 0.05) for a two-sided test ⇒ TRUE
(d) When the true population mean µ is further away from the hypothesized mean µ0 = 100, the difference
between the true state and the null hypothesis becomes larger
A larger difference makes it easier for the statistical test to detect this difference
⇒ the power of the test, which is the probability of correctly rejecting a false null hypothesis, increases
The probability of a Type II error, β, is given by β = 1− Power
Since the power of the test increases as the true mean moves further from the hypothesized mean, the value of 1−
Power will decrease.
⇒ the probability of a Type II error decreases ⇒ TRUE
Suppose that X1 , X2 , ..., Xn is a random sample from a N (µ, σ 2 ) distribution (normality is important in this case).
The quantity
(n − 1)S 2
Q= ∼ χ2 (n − 1) (8..11)
σ2
with χ2 (chi-squared) distribution with ν = n − 1 degrees of freedom
Null hypothesis:
H0 : σ = σ0 (or H0 : σ 2 = σ02 )
Alternative hypothesis:
Ha : σ < σ0 (or Ha : σ 2 < σ02 )
Ha : σ > σ0 (or Ha : σ 2 > σ02 )
Ha : σ ̸= σ0 (or Ha : σ 2 ̸= σ02 )
Confidence interval approach
1. Find the right type of confidence interval.
2. Find the corresponding rejection region:
Page 99 of 160
STATISTICS OVERVIEW
Note
The value of χ2n−1,α can be found via the Chi-square Distribution Table
Example: An automated filling machine is used to fill bottles with liquid detergent. A random sample of 20 bottles
results in a sample variance of fill volume of s2 = 0.0153 (fluid ounces)2 . If the variance of fill volume exceeds 0.01
(fluid ounces)2 , an unacceptable proportion of bottles will be underfilled or overfilled. Is there evidence in the sample
data to suggest that the manufacturer has a problem with underfilled or overfilled bottles? Use α = 0.05, and assume
that fill volume has a normal distribution (use both the confidence interval and critical value approaches).
Solution
Sample variance: s2 = 0.0153 (fluid ounces)2
Threshold variance: σ 2 = 0.01 (fluid ounces)2
Null hypothesis:
H0 : σ 2 ≤ 0.01 where σ02 = 0.01
Alternative hypothesis:
Ha : σ 2 > 0.01 where σ02 = 0.01
Sol 1: Confidence interval approach
(n − 1)s2 (n − 1)s2 (n − 1)s2 (n − 1)s2
α = 0.05 ⇒ 95% CI = [ 2 , 2 ]=[ 2 , 2 ]
χn−1,α χn−1,1−α χ19,0.05 χ19,0.95
(20 − 1)(0.0153) (20 − 1)(0.0153)
⇔ 95% CI = [ , ] = (0.0096, 0.029)
30.144 10.117
0.0096 < 0.01 ⇒ fail to reject H0
Conclusion: At 5% significance level, the data do not provide sufficient evidence to conclude that the real popu-
lation variance is greater than 0.01
Sol 2: Critical value approach
In practice, it is very common to compare the same characteristic (mean, proportion, variance) from two different
distributions.
Example:
the mean starting salaries of male and female engineers (compare µ1 and µ2 )
the proportion of scrap produced from two manufacturing processes (compare p1 and p2 )
the variance of sound levels from two indoor swimming pool designs (compare σ12 and σ22 ).
How do two (several) sub-populations compare? In particular, are their means the same?
Example:
Is this drug’s effectiveness the same in children and adults?
Does cig brand A have the same amount of nicotine as brand B?
Is this class of students more statistically savvy than the last?
Solution: collect samples from both (all sub-populations, and perform a two-sample test (ANOVA)
Statistically speaking, for two samples, we want to test whether µ1 − µ2 = 0 that is, whether µ1 = µ2 .
Example: Difference Between Two Population Means
Forty patients were randomly assigned to a treatment group (m = 20) or a control group (n = 20).
One patient in the treatment group and four in the control group dropped out because of complications.
The data analysis is then based on two random samples, i.e. the treatment group (m = 19) and control group (n = 16).
70).1 Basic assumptions
Suppose we have two independent samples with uneven sample sizes:
X1 , X2 , ..., Xm ∼ N (µ1 , σ12 ) is a random sample from a distribution with mean µ1 and variance σ12 (sample size n)
Y1 , Y2 , .....Yn ∼ N (µ2 , σ22 ) is a random sample from a distribution with mean µ2 and variance σ22 (sample size m)
Point estimators:
n n
1 X 1 X
X̄ = Xi = sample mean for sample X S12 = (Xi − X̄)2 = sample variance for sample
n1 i=1 n − 1 i=1
X
m m
1 X 1 X
Ȳ = Yj = sample mean for sample Y S22 = (Yi − Ȳ )2 = sample variance for sample
n1 j=1 m − 1 j=1
Y
The expected value of X̄ − Ȳ
E(X̄ − Ȳ ) = E(X̄) − E(Ȳ ) = µ1 − µ2 (9..1)
The variance of X̄ − Ȳ
σ12 σ2
2
σX̄− Ȳ = var(X̄ − Ȳ ) = var(X̄) + var(Ȳ ) = + 2 (9..2)
m n
The standard deviation of X̄ − Ȳ r
σ12 σ2
q
σX̄−Ȳ = var(X̄ − Ȳ ) = + 2 (9..3)
m n
The sample variances must be used to estimate this when population variances are unknown.
The construction of confidence intervals and hypothesis testings depend on the values of σ12 and σ22
There are three cased need to be considered:
known σ12 and σ22
unknown σ12 and σ22 : σ12 = σ22
unknown σ12 and σ22 : σ12 ̸= σ22
σ12
X̄ ∼ N (µ1 , )
n
2
σ
Ȳ ∼ N (µ2 , 2 )
m
Because of X̄ and Ȳ are normal distributions ⇒ X̄ − Ȳ are also normally distributed
σ2 σ2
=⇒ X̄ − Ȳ ∼ N (µ1 − µ2 , 1 + 2 )
n m
X̄ − Ȳ − (µ1 − µ2 )
Z= r ∼ N (0, 1) (9..4)
σ12 σ22
+
n m
71).2 Hypothesis Testing for µ1 and µ2 assuming known σ12 and σ22
In a hypothesis-testing problem, the null hypothesis (H0 ) states that µ1 − µ2 has a specified value.
If we are testing equality of the two means, then µ1 − µ2 = 0 under the null hypothesis.
σ12 σ2
Recall we have X̄ − Ȳ ∼ N (µ1 − µ2 , + 2)
n m
Null hypothesis:
H0 : µ1 − µ2 = △0
Alternative hypothesis:
Ha : µ1 − µ2 < △0
Ha : µ1 − µ2 > △0
Ha : µ1 − µ2 ̸= △0
Confidence interval approach
Hypothesis type Alternative hypothesis Reject criterion
r
σ12 σ2
Left-tail hypothesis Ha : µ1 − µ2 < △0 (x̄ − ȳ) + zα + 2 < △0
rn m
σ12 σ22
Right-tail hypothesis Ha : µ1 − µ2 > △0 (x̄ − ȳ) − zα + > △0
n rm
2
σ1 σ2
Two-tail hypothesis Ha : µ1 − µ2 ̸= △0 △0 ∈ / [(x̄ − ȳ) ± zα + 2]
n m
The test statistics (Critical value approach) Test statistics:
(x̄ − ȳ) − △0
z0 = r (9..6)
σ12 σ2
+ 2
n m
P -value approach
Test statistics:
(x̄ − ȳ) − △0
z0 = r (9..7)
σ12 σ2
+ 2
n m
Example: Analysis of a random sample consisting of 20 specimens of cold-rolled steel to determine yield strengths
resulted in a sample average strength of x̄ = 29.8 ksi
A second random sample of 25 two-sided galvanized steel specimens gave a sample average strength of ȳ = 34.7 ksi
Assuming that the two yield-strength distributions are normal with σ1 = 4.0 and σ2 = 5.0, does the data indicate that
the corresponding true average yield strengths µ1 and µ2 are different?
Let’s carry out a test at significance level α = 0.01
Solution
Null hypothesis:
H0 : µ1 − µ2 = 0 where △0 = 0
Alternative hypothesis:
Ha : µ1 − µ2 ̸= 0 where △0 = 0
Sol 1: Confidence interval approach
α = 0.01 ⇒ confidence levelr = 99% r
σ12 σ22 σ12 σ2
99% CI = [(x̄ − ȳ) − zα/2 + , (x̄ − ȳ) + zα/2 + 2]
n mr n m r
4.02 5.02 4.02 5.02
⇔ 99% CI = [(29.8 − 34.7) − 2.576 + , (29.8 − 34.7) + 2.576 + ]
20 25 20 25
Solution
y1 = 121 y2 = 112 σ1 = σ2 = σ = 8 n1 = n2 = 10
Null hypothesis:
H0 : µ1 − µ2 = 0 where △0 = 0
Alternative hypothesis:
Ha : µ1 − µ2 > 0 where △0 = 0
Sol 1: Confidence
s interval approach s r
σ2 σ2 σ2 σ2 82 82
(y1 − y2 ) − zα + = (y1 − y2 ) − z0.05 + = (121 − 112) − 1.645 + = 3.115
n1 n2 n1 n2 10 10
3.115 > 0 ⇒ reject H0
Conclusion: At 5% significance level, the data do provide sufficient evidence to conclude that the new drying
ingredient has drying time less than the standard chemistry
Sol 2: Critical value approach
y1 − y2 − △0 121 − 112 − 0
Test statistics z0 = s = r = 2.516
σ12 σ22 82 82
+ +
n1 n2 10 10
Critical z-value = zα ⇒ z0.05 = 1.645
2.516 > 1.645 ⇒ reject H0
Conclusion: At 5% significance level, the data do provide sufficient evidence to conclude that the new drying
ingredient has drying time less than the standard chemistry
Sol 3: p-value approach
y1 − y2 − △0 121 − 112 − 0
Test statistics z0 = s = r = 2.516 ≈ 2.52
σ12 2
σ2 82 82
+ +
n1 n2 10 10
z0 = 2.52 ⇒ p-value = P (Z > 2.52) = 1 − Φ(2.52) = 1 − 0.9941 = 0.0059
Location 1: 21.9 18.5 12.3 16.7 21.0 15.1 18.2 23.0 36.8 26.6
Location 2: 22.0 20.6 15.4 17.9 24.4 15.6 11.4 17.5
Solution
n = 10,
Pi m = 8
xi 21.9 + 18.5 + ... + 36.8 + 26.6
x̄ = n = = 21.01
Pin 10
y 22.0 + 20.6 + ... + 11.4 + 17.5
ȳ = m = = 18.1
m 8
(a) 100(1 − α)% = 90% ⇔ 1 − α = 0.9 ⇒ α = 0.1 ⇒ zα/2 = z0.05 = 1.645
r r
σ12 σ22 σ12 σ2
90% CI = [(x̄ − ȳ) − zα/2 + , (x̄ − ȳ) + zα/2 + 2]
n mr n m r
72 42 72 42
⇔ 90% CI = [(21.01 − 18.1) − 1.645 + , (21.01 − 18.1) + 1.645 + ]
10 8 10 8
⇔ 90% CI = (−1.411, 7.231)
(b) Null hypothesis:
µ1 − µ2 = 0 where △0 = 0
Alternative hypothesis:
µ1 − µ2 ̸= 0 where △0 = 0
Sol 1: Confidence interval approach
α = 0.05 ⇒ confidence interval
r = 95% r
σ12 σ22 σ12 σ2
95% CI = [(x̄ − ȳ) − zα/2 + , (x̄ − ȳ) + zα/2 + 2]
n mr n m r
72 42 72 42
⇔ 95% CI = [(21.01 − 18.1) − 1.960 + , (21.01 − 18.1) + 1.960 + ]
10 8 10 8
⇔ 95% CI = (−2.238, 8.058)
0 ∈ (−2.238, 8.058) ⇒ fail to reject H0
Conclusion: At 5% significance level, the data do not provide sufficient evidence to conclude that the two distri-
butions have different means
Sol 2: Critical value approach
x̄ − ȳ − △0 21.01 − 18.1
Test statistics z0 = r = r = 1.107
2 2
σ1 σ2 72 42
+ +
n n 10 8
Critical z-value = ±zα/2 ⇒ z0.025 ± 1.960
1.107 < 1.960 and 1.107 > −1.960 ⇒ fail to reject H0
Conclusion: At 5% significance level, the data do not provide sufficient evidence to conclude that the two distri-
butions have different means
72) Inference on µ1 and µ2 assuming unknown σ12 and σ22 : σ12 = σ22
Assuming the variances of the two distributions are the same, we want to test whether two populations (means) are the
same or not.
72).1 Confidence Interval (CI) assuming unknown σ12 and σ22 : σ12 = σ22
Just like inference for single proportion, single mean, and single variance, we need a sampling distribution involving
µ1 − µ2 . It can be shown that
(X̄ − Ȳ ) − (µ1 − µ2 )
T = r (9..8)
1 1
SP2 ( + )
n m
where
(n − 1)S12 + (m − 1)S22
SP2 = (9..9)
n+m−2
The statistics SP2 is called the pooled sample variance estimator of the common population variance σ 2 . Algebraically,
it is simply a weighted average of the two sample variances S12 and S22 (where the weights are functions of the sample
sizes n1 and n2 )
For this sampling distribution to hold (exactly), we need:
the two samples to be independent
the two population distributions to be normal (Gaussian)
the two population distributions to have the same variance: σ12 = σ22
The sampling distribution T ∼ t(n1 + n2 − 2) should suggest to you that confidence interval quantiles will come from
this t distribution; note that this distribution depends on the sample sizes from both samples.
In particular, because T ∼ t(n1 + n2 − 2), we can find the value tn1 +n2 −2,α/2 that satisfies
where: r
1 1
(x̄ − ȳ) ± tn+m−2,α/2 SP2 ( + )
| {z } | {z }| n m
point estimator quantile
{z }
standard error
Interpretation: We are 100(1 − α)% confident that the population mean difference µ1 − µ2 is in this interval
72).2 Hypothesis Testing for µ1 and µ2 assuming unknown σ12 and σ22 : σ12 = σ22
Null hypotehsis:
H0 : µ1 − µ2 = △0
Alternative hypothesis:
Ha : µ1 − µ2 < △0
Ha : µ1 − µ2 > △0
Ha : µ1 − µ2 < △0
Confidence interval approach
Hypothesis type Alternative hypothesis Rejection criterion
r
1 1
Left-tail hypothesis Ha : µ1 − µ2 < △0 (x̄ − ȳ) + tn+m−2,α SP2 ( + ) < △0
r n m
1 1
Right-tail hypothesis Ha : µ1 − µ2 > △0 (x̄ − ȳ) − tn+m−2,α SP2 ( + ) > △0
nrm
1 1
Two-tail hypothesis Ha : µ1 − µ2 ̸= △0 △0 ∈ / [(x̄ − ȳ) ± tn+m−2,α/2 SP2 ( + )]
n m
The test statistics (Critical value approach)
Test statistics:
(x̄ − ȳ) − △0
t0 = r (9..12)
1 1
SP2 ( + )
n m
P -value approach
Test statistics:
(x̄ − ȳ) − △0
t0 = r (9..13)
1 1
SP2 ( + )
n m
Location 1: 21.9 18.5 12.3 16.7 21.0 15.1 18.2 23.0 36.8 26.6
Location 2: 22.0 20.6 15.4 17.9 24.4 15.6 11.4 17.5
Solution
n = 10,
Pi m = 8
(xi − x̄)2
P
nx 21.9 + 18.5 + ... + 36.8 + 26.6 2
x̄ = = = 21.01 ⇒ S1 = = 47.65
Pn
i
10 Pn−1 2
y 22.0 + 20.6 + ... + 11.4 + 17.5 (yi − ȳ)
y2 = m = = 18.1 ⇒ S22 = = 17.14
m 8 m−1
2 2
(n − 1)S1 + (m − 1)S2 (10 − 1)(47.65) + (8 − 1)(17.14)
SP2 = = = 34.30
n+m−2 10 + 8 − 2
(a) 100(1 − α)% = 90% ⇔ 1 − α = 0.9 ⇒ α = 0.1
tn+m−2,α/2 = t16,0.05 = 1.746
r r
1 1 1 1
90% CI = [(x̄ − ȳ) − tn+m−2,α/2 SP2 (
+ ), (x̄ − ȳ) + tn+m−2,α/2 SP2 ( + )]
r n m nr m
1 1 1 1
⇔ 90% CI = [(21.01 − 18.1) − 1.746 34.30( + ), (21.01 − 18.1) + 1.746 34.30( + )]
10 8 10 8
⇔ 90% CI = (−1.94, 7.76)
(b) Null hypothesis:
H0 : µ1 − µ2 = 0 where △0 = 0
Alternative hypothesis:
Ha : µ1 − µ2 ̸= 0 where △0 = 0
Sol 1: Confidence interval approach
α = 0.05 ⇒ tn+m−2,α/2 = t16,0.025 = 2.120
α = 0.05 ⇒ confidence level = 95%
r r
1 1 1 1
95% CI = [(x̄ − ȳ) − tn+m−2,α/2 SP2 (
+ ), (x̄ − ȳ) + tn+m−2,α/2 SP2 ( + )]
rn m nr m
1 1 1 1
⇔ 95% CI = [(21.01 − 18.1) − 2.120 34.30( + ), (21.01 − 18.1) + 2.120 34.30( + )]
10 8 10 8
⇔ 95% CI = (−2.98, 8.80)
0 ∈ (−2.98, 8.80) ⇒ fail to reject H0
Conclusion: At 5% significance level, the data do not provide sufficient evidence to conclude that the two distri-
butions have the same means
Sol 2: Critical value approach
Note
t-scores and p-values are inversely related: a larger t-score generally corresponds to a smaller p-value, and vice
versa
Check assumptions
We start by checking normality assumption through Q-Q plots. The points are approximately around a straight line,
which indicates the normality assumption is reasonable for both populations.
In order to visually assess the equal variance assumption, we use boxplots to display the data in each sample.
1 > loc .1 = c (21.9 ,18.5 ,12.3 ,16.7 ,21.0 ,15.1 ,18.2 ,23.0 ,36.8 ,26.6)
2 > loc .2 = c (22.0 ,20.6 ,15.4 ,17.9 ,24.4 ,15.6 ,11.4 ,17.5)
3 # C r e a t e s i d e by s i d e b o x p l o t s
4 > b o x p l o t ( l o c . 1 , l o c . 2 , x l a b = ” ” , names= c ( ” L o c a t i o n 1 ” , ” L o c a t i o n 2 ” ) , y l a b = ” Weight ( i n o u n c e s ) ” , y l i m = c
( 0 , 4 0 ) , c o l =” grey ” )
3 d a t a : l o c . 1 and l o c . 2
4 t = 1 . 0 4 7 4 , d f = 1 6 , p− v a l u e = 0 . 3 1 0 5
5 a l t e r n a t i v e h y p o t h e s i s : t r u e d i f f e r e n c e i n means i s n o t e q u a l t o 0
6 90 p e r c e n t c o n f i d e n c e i n t e r v a l :
7 −1.940438 7.760438
8 sample e s t i m a t e s :
9 mean o f x mean o f y
10 21.01 18.10
Interpretation: We are 90% confident that the mean weight difference in fish for location 1 and 4 is between −1.94
and 7.76 oz.
Note that this interval includes ”0”. By the relationship between hypothesis test and confidence interval, we fail to reject
H0 : µ1 − µ2 = 0 against Ha : µ1 − µ2 ̸= 0. at α = 0.1 level.
Therefore, we do not have sufficient evidence that the population mean fish weights 1 and µ2 are different at 0.1 level
of significance.
Note
We should only use this interval if there is strong evidence that the population variances σ12 and σ22 are equal (or
at least close). Otherwise, we should use a different interval
The two sample t interval (and the unequal variance version) is robust to normality departures. This means that we
can feel comfortable with the interval even if the underlying population distributions are not perfectly normal.
73) Inference on µ1 and µ2 assuming unknown σ12 and σ22 : σ12 ̸= σ22
73).1 Confidence Interval (CI) assuming unknown σ12 and σ22 : σ12 ̸= σ22
When σ12 ̸= σ22 , the construction of a 100(1 − α)% is no longer based on the exact t distribution
We need to approximate the degrees of freedom of a t distribution, and write an approximate confidence interval
An approximate 100(1 − α)% confidence interval µ1 − µ2 is given by
r r
S12 S2 S12 S2
[(x̄ − ȳ) − tν,α/2 + 2 , (x̄ − ȳ) + tν,α/2 + 2] (9..14)
n m n m
S12 S2
+ 2 )2
(
ν= n m (9..15)
S12 2 S2
( ) ( 2 )2
n + m
n−1 m−1
Ha : µ1 − µ2 ̸= △0
Confidence interval approach
Hypothesis type Alternative hypothesis Rejection criterion
r
S12 S2
Left-tail hypothesis Ha : µ1 − µ2 < △0 (x̄ − ȳ) + tν,α + 2 < △0
rn m
S12 S22
Right-tail hypothesis Ha : µ1 − µ2 > △0 (x̄ − ȳ) − tν,α + > △0
n m
r
S12 S2
Two-tail hypothesis Ha : µ1 − µ2 ̸= △0 △0 ∈ / [(x̄ − ȳ) ± tν,α/2 + 2]
n m
P -value approach
Test statistics:
(x̄ − ȳ) − △0
t0 = r (9..16)
1 1
SP2 ( + )
n m
Note
There are two confidence intervals for µ1 − µ2 assuming unknown σ12 and σ22
σ12 = σ22 (equal variance assumption)
σ12 ̸= σ22 (unequal variance assumption)
If you are unsure about which interval to use, go with the unequal variance interval
The penalty for using it when σ12 = σ22 is much smaller than the penalty for using the equal variance interval when
σ12 ̸= σ22
Plant 1: 3.01 2.58 3.04 1.75 2.87 2.57 2.51 2.93 2.85 3.09
1.43 3.36 3.18 2.74 2.25 1.95 3.68 2.29 1.86 2.63
2.83 2.04 2.23 1.92 3.02
Plant 2: 3.79 2.08 3.66 1.53 4.07 4.31 2.62 4.52 3.80 5.30
3.41 0.82 3.03 1.95 6.45 1.86 1.87 3.78 2.74 3.81
Solution
Pi Pi
xi 3.01 + 2.58 + ... + 1.92 + 3.02 (xi − x̄)2
x̄ = n = = 2.584 ⇒ S12 = n = 0.307
Pin 25 Pi n − 1 2
yi 3.79 + 2.08 + ... + 2.74 + 3.81 (yi − x̄)
ȳ = m = = 3.27 ⇒ S22 = m = 1.881
m 20 m−1
(n − 1)S12 + (m − 1)S22 (25 − 1)(0.307) + (20 − 1)(1.881)
SP2 = = = 1.002
n+m−2 25 + 20 − 2
(S12 /n + S22 /m)2 (0.307/25 + 1.881/20)2
Degree of freedom ν = 2 2 2 2 = = 24.19 ≈ 24
(S1 /n) (S2 /m) (0.307/25)2 (1.881/20)2
+ +
n−1 m−1 25 − 1 20 − 1
Null hypothesis:
H0 : µ1 − µ2 = 0 where △0 = 0
Alternative hypothesis:
Ha : µ1 − µ2 ̸= 0 where △0 = 0
Sol 1: Confidence interval approach
α = 0.05 ⇒ t24,0.025 = 2.064
α = 0.05 ⇒ confidence level r= 95% r
S12 S22 S12 S2
95% CI = [(x̄ − ȳ) − tν,α/2 + , (x̄ − ȳ) + tν,α/2 + 2]
n m
r n m r
0.307 1.881 0.307 1.881
⇔ 95% CI = (2.584 − 3.27) − 2.064 + , (2.584 − 3.27) + 2.064 +
25 20 25 20
⇔ 95% CI = (−1.359, −0.013)
/ (−1.312, 0.032) ⇒ reject H0
0∈
Conclusion: At 5% significance level, the data provide sufficient evidence to conclude amount of white paper
discarded by employees at two plants have different means
Sol 2: p-value approach
(x̄ − ȳ) − △0 (2.584 − 3.27) − 0
Test statistics t0 = r = r = −2.28
2 1 1 1 1
SP ( + ) 1.002( + )
n m 25 20
2.172 < |t0 | < 2.492 ⇒ 0.02 < p-value < 0.04
0.04 < 0.05 ⇒ p-value < α ⇒ reject H0
Conclusion: At 5% significance level, the data provide sufficient evidence to conclude amount of white paper
discarded by employees at two plants have different means
Check assumptions
1 plant .1 = c (3.01 ,2.58 ,3.04 ,1.75 ,2.87 ,2.57 ,2.51 ,2.93 ,2.85 ,3.09 ,
2 + 1.43 ,3.36 ,3.18 ,2.74 ,2.25 ,1.95 ,3.68 ,2.29 ,1.86 ,2.63 ,
3 + 2.83 ,2.04 ,2.23 ,1.92 ,3.02)
4 plant .2 = c (3.79 ,2.08 ,3.66 ,1.53 ,4.07 ,4.31 ,2.62 ,4.52 ,3.80 ,5.30 ,
5 + 3.41 ,0.82 ,3.03 ,1.95 ,6.45 ,1.86 ,1.87 ,3.78 ,2.74 ,3.81)
6 var . t e s t ( plant . 1 , plant . 2 )
7 F t e s t t o compare two v a r i a n c e s
8 d a t a : p l a n t . 1 and p l a n t . 2
9 F = 0 . 1 6 3 5 , num d f = 2 4 , denom d f = 1 9 , p− v a l u e = 5 . 7 4 2 e −05
10 a l t e r n a t i v e h y p o t h e s i s : t r u e r a t i o of v a r i a n c e s i s not equal to 1
11 95 p e r c e n t c o n f i d e n c e i n t e r v a l :
12 0.06668721 0.38352280
13 sample e s t i m a t e s :
14 r a t i o of variances
15 0.1635384
We also can extend our confidence interval procedure for a single population proportion p to two populations. De-
fine
p1 = population proportion of ”successes” in Population 1
p2 = population proportion of ”successess” in Population 2
For example, we might want to compare the proportion of
defective circuit boards for two different suppliers
satisfied customers before and after a product design change (e.g., Facebook, etc.)
on-time payments for two classes of customers
HIV positives for individuals in two demographic classes.
Point estimators: We assume that there are two independent random samples of individuals (one sample from each
population to be compared). Define
Y1 = number of ”successes” in Sample 1 (out of n1 individuals) ∼ B(n1 , p1 )
Y2 = number of ”successes” in Sample 2 (out of n2 individuals) ∼ B(n2 , p2 )
The point estimators for p1 and p2 are the sample proportions, defined by:
Y1
pb1 =
n1
(9..17)
Y2
pb2 =
n2
A natural point estimator for p1 − p2 is given by
Y1 Y2
pb1 − pb2 = − (9..18)
n1 n2
p1 (1 − p1 )
pb1 ∼ AN (p1 , )
n1
p2 (1 − p2 )
pb2 ∼ AN (p2 , )
n2
When the sample sizes n1 and n2 are large, the sampling distribution:
For the Z sampling distribution to hold approximately (and therefore for the interval above to be useful), we need
the two samples to be independent
the sample sizes n1 and n2 to be ”large”, common rules of thumb are to require
ni pbi ≥ 5
n1 (1 − pbi ) ≥ 5
Note
The value zα/2 is the upper α/2 quantile from the N (0, 1) distribution
Null hypothesis:
H0 : p1 = p2
Alternative hypothesis:
Ha : p1 < p2
Ha : p1 > p2
Ha : p1 ̸= p2
Critical value approach
Test statistics:
pb1 − pb2
z0 = r (9..24)
1 1
p̂(1 − p̂)( + )
n1 n2
P -value approach
Test statistics:
pb1 − pb2
z0 = r (9..25)
1 1
p̂(1 − p̂)( + )
n1 n2
Example: A programmable lighting control system is being designed. The purpose of the system is to reduce electricity
consumption costs in buildings. The system eventually will entail the use of a large number of transceivers (a device
comprised of both a transmitter and a receiver). Two types of transceivers are being considered. In life testing, 200
transceivers (randomly selected) were tested for each type.
Transceiver 1: 20 failures were observed (out of 200)
Transceiver 2: 14 failures were observed (out of 200)
Define p1 (p2 ) to be the population proportion of Transceiver 1 (Transceiver 2) failures. Write a 95% confidence interval
for p1 − p2 . Is there a significant difference between the failure rates p1 and p2 ?
Solution
Y1 20
pb1 = = = 0.1
n1 200
Y2 14
pb2 = = = 0.07
n2 200
Y1 + Y2 20 + 14 34
p̂ = = = = 0.085
n1 + n2 200 + 200 400
Null hypothesis:
H0 : p1 − p2 = 0
Alternative hypothesis:
Ha : p1 − p2 ̸= 0
Sol 1: The test statistics (Critical value approach)
pb1 − pb2 0.1 − 0.07
Test statistics z0 = r =r = 1.075
1 1 1 1
p̂(1 − p̂)( + ) 0.085(1 − 0.085)( + )
n1 n2 200 200
100(1 − α)% = 95% ⇒ 1 − α = 0.95 ⇒ α = 0.05
Critical z-value = ±zα/2 ⇒ z0.025 = ±1.960
1.075 < 1.960 and 1.075 > −1.96 ⇒ fail to reject H0
Conclusion: At 5% signficance level, the data do not provide sufficient evidence to conclude failure rates p1 and
p2 have difference
Sol 2: p-value approach
pb1 − pb2 0.1 − 0.07
Test statistics z0 = r =r = 1.075 ≈ 1.08
1 1 1 1
p̂(1 − p̂)( + ) 0.085(1 − 0.085)( + )
n1 n2 200 200
z0 = 1.08 ⇒ p-value = 2P (Z < −|z0 |) = 2P (Z < −1.08) = 2[1 − Φ(1.08)] = 2(1 − 0.8599) = 0.2802
100(1 − α)% = 95% ⇒ 1 − α = 0.95 ⇒ α = 0.05
p-value > α ⇒ fail to reject H0
Conclusion: At 5% signficance level, the data do not provide sufficient evidence to conclude failure rates p1 and
p2 have difference
of the runway). When an airplane deviates from the localizer, it is sometimes referred to as an exceedence. Consider
two airlines at a large airport. During a three-week period, airline 1 had 14 exceedences out of 156 flights and airline 2
had 11 exceedences out of 198 flights.
We are interested in whether airline 1 has a significantly higher exceedence rate than airline 2 or not.
Solution
Y1 14
pb1 = = = 0.0897
n1 156
Y2 11
pb2 = = = 0.0556
n2 198
Y1 + Y2 14 + 11
p̂ = = = 0.0706
n1 + n2 156 + 198
1 > prop . t e s t ( c ( 1 4 , 1 1 ) , c ( 1 5 6 , 1 9 8 ) , a l t e r n a t i v e = ” g r e a t e r ” , c o r r e c t =F )
2 2− s a m p l e t e s t f o r e q u a l i t y o f p r o p o r t i o n s w i t h o u t c o n t i n u i t y
3 correction
4 data : c ( 1 4 , 11) out of c ( 1 5 6 , 198)
5 X− s q u a r e d = 1 . 5 5 3 8 , d f = 1 , p− v a l u e = 0 . 1 0 6 3
6 a lt er na ti ve hypothesis : greater
7 95 p e r c e n t c o n f i d e n c e i n t e r v a l :
8 −0.01200417 1.00000000
9 sample e s t i m a t e s :
10 prop 1 prop 2
11 0.08974359 0.05555556
75) F Distribution
Y1 /ν1
X= (9..26)
Y2 /ν2
where
Chi-square random variable Y1 with ν1 degree of freedom
Chi-square random variable Y2 with ν2 degree of freedom
Y1 and Y2 are independent
There is an important connection between an F variable and chi-squared variables
75).1 Definition
Let X be a continuous random variable. Let it supports be the set of positive real numbers:
RX = [0, ∞)
Let ν1 , ν2 ∈ N. We say that X has an F distribution with ν1 and ν2 degrees of freedom if and only if its probability
density function (pdf) is
cxν1 /2−1 (1 + ν1
ν2 x)
−(ν1 +ν2 )/2
if x ∈ RX
fX (x) = (9..27)
0 if x ∈
/ RX
where c is a constant:
ν1 ν1 /2 1
c=( ) ν1 ν2 (9..28)
ν2 B( 2 , 2 )
and B() is a beta function
Expected value
ν2
E[X] = (9..29)
ν2 − 2
Variance
2ν22 (ν1 + ν2 − 2)
var[X] = (9..30)
ν1 (ν2 − 2)2 (ν2 − 4))
75).2 Characteristics
The F distribution has the following characteristics:
continuous, skewed right, not symmetric and always positive
indexed by two degrees of freedom parameters ν1 and ν2 , these are usually integers and are often related to sample
sizes
75).3 F Tables
An F distribution with numerator degree of freedom ν1 = n1 − 1 and denominator degree of freedom ν2 = n2 − 1
F Distribution Table (1)
F Distribution Table (2)
You will recall that when we wrote a confidence interval for µ1 − µ2 , the difference of the population means (with
independent samples), we proposed two different intervals:
one interval that assumed σ12 = σ22
one interval that assumed σ12 ̸= σ22
S22 S2
( 2 × Fn−1,m−1,1−α/2 , 22 × Fn−1,m−1,α/2 ) (9..32)
S1 S1
Proof:
1 − α = P (Fn−1,m−1,1−α/2 ≤ R ≤ Fn−1,m−1,α/2 )
S 2 /σ 2
⇔ 1 − α = P (Fn−1,m−1,1−α/2 ≤ 12 12 ≤ Fn−1,m−1,α/2 )
S2 /σ2
S22 σ2 S2
⇔ 1 − α = P ( 2 × Fn−1,m−1,1−α/2 ≤ 22 ≤ 22 × Fn−1,m−1,α/2 )
S1 σ1 S1
Based on the relationship:
1
Fν2 ,ν1 ,α =
Fν1 ,ν2 ,1−α
σ12
A 100(1 − α)% confidence interval for
σ22
S12 1 S2 1 S2 1 S2
( 2 × , 12 × ) = ( 12 × , 12 × Fm−1,n−1,α/2 ) (9..33)
S2 Fn−1,m−1,α/2 S2 Fn−1,m−1,1−α/2 S2 Fn−1,m−1,α/2 S2
S2 q S2 q
( × Fn−1,m−1,1−α/2 , × Fn−1,m−1,α/2 ) (9..34)
S1 S1
σ1
A 100(1 − α)% confidence interval for
σ2
s s s
S1 1 S1 1 S1 1 S1 q
( × , × )=( × , × Fm−1,n−1,α/2 ) (9..35)
S2 Fn−1,m−1,α/2 S2 Fn−1,m−1,1−α/2 S2 Fn−1,m−1,α/2 S2
When H0 is true:
S12 /σ12 S12
r0 = = ∼ F (n − 1, m − 1)
S22 /σ22 S22
Null hypothesis:
H0 : σ12 = σ22
Alternative hypothesis:
Ha : σ12 < σ22
Ha : σ12 > σ22
Ha : σ12 ̸= σ22
Confidence interval approach
Hypothesis type Alternative hypothesis Rejection criterion
S2
Left-tail hypothesis σ12 < σ22 1 > 12 × Fm−1,n−1,α
S2
S2 1
Right-tail hypothesis Ha : σ12 > σ22 1 < 12 ×
S2 Fn−1,m−1,α
S12 1 S2
Two-tail hypothesis σ12 ̸= σ22 1∈/( 2× , 12 × Fm−1,n−1,α/2 )
S2 Fn−1,m−1,α/2 S2
Critical value approach
Test statistics:
s21
r0 = (9..36)
s22
Some statisticians recommend to use this “equal/unequal variance test” before deciding which confidence interval or
testing procedure to use for µ1 − µ2 . Some statisticians do not
Like the χ2 interval for single population variance σ2 , the two-sample F interval for the ratio of two variances is not
robust to departures from normality.
If the underlying population distributions are non-normal (non-Gaussian), then this interval should not be used
One easy solution, to check whether the sample is from a normal distribution or not, is the so-called ”normal qq plot”.
It plots sample quantiles against theoretical normal quantiles
If it fits well by a line, it is normal
Otherwise, non-normal
Example: We consider again the recycling project that examined the amount of white paper discarded per employee
at two large plants. The data were obtained on the amount of white paper thrown out per year by employees (data are
in hundreds of pounds). Samples of employees at each plant (n = 25 and m = 20) were randomly selected
The boxplots did suggest that the population variances may be different The normal qq plots
Plant 1: 3.01 2.58 3.04 1.75 2.87 2.57 2.51 2.93 2.85 3.09
1.43 3.36 3.18 2.74 2.25 1.95 3.68 2.29 1.86 2.63
2.83 2.04 2.23 1.92 3.02
Plant 2: 3.79 2.08 3.66 1.53 4.07 4.31 2.62 4.52 3.80 5.30
3.41 0.82 3.03 1.95 6.45 1.86 1.87 3.78 2.74 3.81
Find a 95% confidence interval for σ22 /σ12 , the ratio of the population variances. Here σ12 (σ22 ) denotes the population
variance of the amount of white paper by employees at Plant 1 (Plant 2)
Solution
Pi Pi
n xi3.01 + 2.58 + ... + 1.92 + 3.02 2 (xi − x̄)2
x̄ = = = 2.584 ⇒ S1 = n = 0.307
Pin 25 Pi n − 1 2
yi 3.79 + 2.08 + ... + 2.74 + 3.81 (yi − x̄)
ȳ = m = = 3.27 ⇒ S22 = m = 1.881
m 20 m−1
100(1 − α) = 95 ⇒ 1 − α = 0.95 ⇒ α = 0.05
Example: Creatine
Creatine is an organic acid that helps to supply energy to cells in the body, primarily muscle. Because of this, it is com-
monly used by those who are weight training to gain muscle mass. Does it really work? Suppose that we are designing
an experiment involving USC male undergraduates who exercise/lift weight regularly
Design 1 (Independent samples): Recruit 30 students who are representative of the population of USC male under-
graudates who exercise/lift weights. For a single weight training session, we will
assign 15 students to take creatine
assign 15 students an innocuous substance that looks like creatine (but has no positive/negative effect on performance)
For each student, we will record
Y = maximum bench press weight (MBPW)
We will then have two samples of data (with n = 15 and m = 15):
Sample 1 (Creatine): X1 , X2 , ..., Xn
Sample 2 (Control): Y1 , Y2 , ..., Ym
To compare the population means
µ1 = population mean MBPW for students taking creatine
µ2 = population mean MBPW for students not taking creatine
We could construct a two-sample t confidence interval for µ1 − µ2 using
r r
11 1 1
[(X̄ − Ȳ ) − tn+m−2,α/2 SP2 ( + ), (X̄ − Ȳ ) + tn+m−2,α/2 SP2 ( + )]
n m n m
or s s
S12 S2 S12 S2
[(X̄ − Ȳ ) − tν,α/2 + 2 , (X̄ − Ȳ ) + tν,α/2 + 2]
n1 n2 n1 n2
This allows you to compare the two experimental conditions (e.g., creatine/control, biodegradability treatments, opera-
tors, etc.) under more homogeneous conditions where only variation within individuals is present (that is, the variation
arising from the difference in the two experimental conditions).
Advantage: When you remove extra variability, this enables you to do a better job at comparing the two experimental
conditions (treatments). By “better job,” I mean, you can more precisely estimate the difference between the treatments
(excess variability that naturally arises among individuals is not getting in the way). This gives you a better chance of
identifying a difference between the treatments if one really exists
Note: In matched pairs experiments, it is important to randomize the order in which treatments are assigned. This may
eliminate “common patterns” that may be seen when always following, say, Treatment 1 with Treatment 2. In practice,
the experimenter could flip a fair coin to determine which treatment is applied first
77).1 Implementation
Note
Basically, you take the difference, then perform a T -test on the differences
Data from matched pairs experiments are analyzed by examining the difference in responses of the two treatments.
Specifically, compute
Dj = Xj − Yj (9..38)
for each individual j = 1, 2, ..., n. After doing this, we have essentially created a ”one sample problem”, where our data
are the so-called data differences:
D1 , D2 , ..., Dn
The one sample 100(1 − α))% confidence interval
SD SD
(D − tn−1,α/2 √ , D + tn−1,α/2 √ ) (9..39)
n n
where D and SD are the sample mean and sample standard deviation of the differnces, respectively, is an interval esti-
mate for
µD = µ1 − µ2
Null hypothesis:
H0 : µD = △0
Alternative hypothesis:
Ha : µD < △0
Ha : µD > △0
Ha : µD ̸= △0
Confidence interval approach
Hypothesis type Alternative hypothesis Rejection criterion
SD
Left-tail hypothesis Ha : µD < △0 △0 > D + tn−1,α √
n
SD
Right-tail hypothesis Ha : µD > △0 △0 < D − tn−1,α √
n
SD
Two-tail hypothesis Ha : µD ̸= △0 / (D ± tn−1,α/2 √ )
△0 ∈
n
The test statistics (Critical value approach)
Test statistics:
D − △0
t0 = √ (9..40)
SD / n
SD SD SD SD
95% CI = (D − tn−1,α/2 √ , D + tn−1,α/2 √ ) = (D − t14,0.025 √ , D + t14,0.025 √ )
n n n n
17.27 17.27
⇔ 95% CI = (6.333 − 2.145 √ , 6.333 + 2.145 √ )
15 15
⇔ 95% CI = (−3.23, 15.9)
Null hypothesis:
H0 : µD = 0 where △0 = 0
Alternative hypothesis:
Ha : µD ̸= 0 where △0 = 0
Sol 1: Confidence interval approach
0 ∈ (−3.23, 15.9) ⇒ fail to reject H0
Conclusion: At 5% significance level, the data do not provide sufficient evidence to conclude there is a difference
in mean maximum bench press weight (MBPW)
Sol 2: Critical value approach
D − △0 6.333 − 0
Test statistics t0 = √ = √ = 1.422
SD / n 17.27/ 15
α = 0.05 ⇒ t14,0.025 = ±2.145
1.422 < 2.145 and 1.422 > −2.145 ⇒ fail to reject H0
Conclusion: At 5% significance level, the data do not provide sufficient evidence to conclude there is a difference
in mean maximum bench press weight (MBPW)
Sol 3: p-value approach
D − △0 6.333 − 0
Test statistics t0 = √ = √ = 1.422
SD / n 17.27/ 15
1.345 < 1.422 < 1.761 ⇒ 0.1 < p-value < 0.2
0.1 > 0.05 ⇒ p-value > α ⇒ fail to reject H0
Conclusion: At 5% significance level, the data do not provide sufficient evidence to conclude there is a difference
in mean maximum bench press weight (MBPW)
1 > creatine = c (230 ,140 ,215 ,190 ,200 ,230 ,220 ,255 ,220 ,200 ,90 ,130 ,255 ,80 ,265)
2 > control = c (200 ,155 ,205 ,190 ,170 ,225 ,200 ,260 ,240 ,195 ,110 ,105 ,230 ,85 ,255)
3 > t . t e s t ( c r e a t i n e , c o n t r o l , c o n f . l e v e l = 0 . 9 5 , a l t e r n a t i v e = ” two . s i d e d ” , p a i r e d =TRUE )
4 Paired t − t e s t
5 d a t a : c r e a t i n e and c o n t r o l
6 t = 1 . 4 2 0 7 , d f = 1 4 , p− v a l u e = 0 . 1 7 7 3
7 a l t e r n a t i v e h y p o t h e s i s : t r u e d i f f e r e n c e i n means i s n o t e q u a l t o 0
8 95 p e r c e n t c o n f i d e n c e i n t e r v a l :
9 −3.227946 15.894612
10 sample e s t i m a t e s :
11 mean o f t h e d i f f e r e n c e s
12 6.333333
When there are two means, we have recently seen that the design of the experiment/studey completely determines
how the data are to be analyzed
When the two samples are independent, this is called a (two) independent-sample design
When the two samples are obtained on the same individuals (dependent samples), this is called a matched-pairs design
Confidence interval procedures for µ1 − µ2 depend on the design of the study
The purpose of an experiment is to investigate differences between or among two or more treatments. In a statistical
framework, we do this by comparing the population means of the responses to each treatment
In order to detect treatment mean differences, we must try to control the effects of error so that any variation we
observe can be attributed to the effects of the treatments rather than to differences among the individuals
Blocking: Designs involving meaningful grouping of individuals, that is, blocking, can help reduce the effects of ex-
perimental error by identifying systematic components of variations among individuals
The matched pairs design for comparing two treatments is an example of such a design. In this situation, individuals
themselves are treated as ”blocks”
Example: Four types of mortars: (1) ordinary cement mortar (OCM), polymer impregnated mortar (PIM), resin mortar
(RM), and (4) polymer cement mortar (PCM), were subjected to a compression test to measure strength (MPa). Here are
the strength measurements taken on different mortar specimens (36 in all)
Figure 9..6: Boxplots of strength measurements (MPa) for four mortar types
1 > ocm <− c ( 5 1 . 4 5 , 42.96 , 41.11 , 48.06 , 38.27 , 38.88 , 42.74 , 49.62)
2 > pim <− c ( 6 4 . 9 7 , 64.21 , 57.39 , 52.79 , 64.87 , 53.27 , 51.24 , 55.87 , 61.76 , 67.15)
3 > rm <− c ( 4 8 . 9 5 , 62.41 , 52.11 , 60.45 , 58.07 , 52.16 , 61.71 , 61.06 , 57.63 , 56.80)
4 > pcm <− c ( 3 5 . 2 8 , 38.59 , 48.64 , 50.99 , 51.52 , 52.85 , 46.75 , 48.3)
5 > b o x p l o t ( ocm , pim , rm , pcm , y l a b = ” S t r e n g t h ( MPa ) ” , names = c ( ”OCM” , ” PIM ” , ”RM” , ”PCM” ) , y l i m = c
(0 , 100) )
In this example:
“Treatment” = mortar type (OCM, PIM, RM, and PCM). There are t = 4 treatment groups
Individuals = mortar specimens
This is an example of an observational study; not an experiment. That is, we do not physically apply a treatment here;
instead, the mortar specimens are inherently different to begin with. We simply take random samples of each mortar
type.
Let:
t = the number of populations or treatments being compared
µ1 = the mean of population 1 or the true average response when treatment 1 is applied
.
..
µt = the mean of population t or the true average response when treatment t is applied
Assumptions: We have independent random samples from t ≥ 2 normal distributions, each of which has the same
variance (but possibly different means)
Sample 1: Y11 , Y12 , ..., Y1n1 ∼ N (µ1 , σ 2 )
Sample 2: Y21 , Y22 , ..., Y2n2 ∼ N (µ2 , σ 2 )
.. ..
. .
Sample t: Yt1 , Yt2 , ..., Ytnt ∼ N (µt , σ 2 )
The t population or treatment distributions are all normal with the same variance σ 2 . That is, each Xi,j is normally
distributed with
E(Xi,j ) = µi
(9..42)
var(Xi,j ) = σ 2
Statistical Hypothesis:
Null hypothesis:
H0 : µ1 = µ2 = ... = µt
Alternative hypothesis:
Ha : the population mean µi are not all equal
The null hypothesis H0 says that there is “no treatment difference,” that is, all treatment population means are the
same.
The alternative hypothesis Ha says that a difference among the t population means exists somewhere (but does not
specify how the means are different).
The goal is to decide which hypothesis is more supported by the observed data
Notation: Let t denote the number of treatments to be compared. Define:
Xi,j = the random variable that denotes the jth measurement taken from the i population, or the measurement taken
on the jth experimental unit that receives the ith treatment (for i = 1, 2, ..., t and j = 1, 2, ..., ni )
xi,j = the observed value of Xi,j when the experiment is performed
ni = the number of replications for treatment i
When n1 = n2 = ... = nt = n, we say the design is balanced, otherwise, the design is unbalanced
Let N = n1 + n2 + ... + nt denote the total number of individuals measured. If the design is balanced, then
N = nt (9..43)
The sample mean of all the data (across all t treatment groups) (also called the grand mean):
t ni
1 XX
X.. = Xi,j (9..46)
N i=1 j=1
Note
Rule of Thumb: If the largest s is not much more than two times the smallest, it is reasonable to assume equal
σ 2 ’s
The individual sample sizes in ANOVA are often too small for t separate plots to be informative. A single plot can be
constructed by subtracting x1 from each observation in the first sample, x2 from each observation in the second, and
so on, and then plotting these deviations against the z percentiles
Note
The straightness of the pattern gives strong support to the normality assumption.
The procedure we develop is formulated by deriving two estimators for σ 2 . These two estimators are formed by
(1) looking at the variance of the observations within samples
(2) looking at the variance of the sample means across the t samples.
”WITHIN” Estimator: To estimate σ 2 within samples, we take a weighted average (weighted by the sample size) of
the t sample variance, that is, we ”pool” all variance estimates together to form one estimate.
The residual sum of squares:
ni
t X
X
SSres = (n1 − 1)S12 + (n2 − 1)S22 + ... + (nt − 1)St2 = (Xi,j − Xi )2 (9..47)
i=1 j=1
| {z }
(ni −1)Si2
Note
M Sres is an unbiased estimator of σ 2 regardless of whether or not H0 is true.
”ACROSS” Estimator: To derive the ”across-sample” estimator, we assume a common sample size n1 = n2 = ... =
nt = n (to simplify notation). Recall that if a sample arises from a normal population, then the sample mean is also
normally distributed, i.e.,
σ2
Xi ∼ N (µi , )
n
Note
If all the treatment population means are equal, that H0 : µ1 = µ2 = ... = µt = µ is true, then
σ2
Xi ∼ N (µ, )
n
The sample variance of this ”random sample”
t
1 X
Si2 = (Xi − X.. )2 (9..50)
t − 1 i=1
t
1 X σ2
E[ (Xi − X.. )2 ] = (9..51)
t − 1 i=1 n
t
1 X
M Strt = n(Xi − X.. )2 (9..52)
t − 1 i=1
M Strt is second point estimator for σ 2 . Recall that M Strt is an unbiased estimator of σ 2 only when H0 : µ1 = µ2 = ... = µt
is true. If we have different sample sizes, we simply adjust M Strt
t
1 X
M Strt = ni (Xi − Xii )2 (9..54)
t − 1 i=1
| {z }
SStrt
Motivation:
When H0 is true (i.e., the treatment means are the same), then
E(M Strt ) = σ 2
(9..55)
E(M Sres ) = σ 2
When H0 is not true (i.e., the treatment means are different), then
M Strt
F = >1 (9..58)
M Sres
Null hypothesis:
H0 : µ1 = µ2 = ... = µt
Alternative hypothesis:
Ha : the population mean µi are not all equal
The test statistics
M Strt
F = ∼ F (t − 1, N − t) (9..59)
M Sres
The rejection criterion:
M Strt
F = > Ft−1,N −1,α (9..60)
M Sres
We ”reject H0 ” and conclude the treatment population means are different if the F statistics is far out in the right
tail of the F (t − 1, N − t) distribution. Because a large value of F is not consistent with H0 being true. Large
values of F (far out in the right tail) are more consistent with Ha
79) Introduction
IMPORTANT: A problem that arises in engineering, economics, medicine, and other areas is that investigating the
relationship betwene two (or more) variables. In such settings, the goal is to model a continuous random variable Y as
a function of one or more independent variables, say, x1 , x2 , ..., xk . Mathematically, we can express this model as
where g : Rk ⇒ R. This is called a regression model The presence of the (random) error ϵ conveys the fact that the
relationship between the depenedent variable Y and the independent variables x1 , x2 , .., xk through g is not determin-
istic. Instead, the term ϵ ”absorbs” all variation in Y that is not explained by g(x1 , x2 , ..., xk )
The form of linear models:
Y = β0 + β1 x1 + ... + βk xk +ϵ (10..2)
| {z }
g(x1 ,x2 ,...,xk )
Terminology A simple linear regression model includes only one independent variable x and is of the form:
Y = g(x) + ϵ = β0 + β1 x + ϵ
Obs x Y Obs x Y
1 125.3 77.9 11 159.5 79.9
2 98.2 76.8 12 145.8 79.0
3 201.4 81.5 13 75.1 76.7
4 147.3 79.8 14 151.4 78.2
5 145.9 78.2 15 144.2 79.5
6 124.7 78.3 16 125.0 78.1
7 112.2 77.5 17 198.8 81.5
8 120.2 77.0 18 132.5 77.0
9 161.2 80.1 19 159.6 79.0
10 178.9 80.2 20 110.7 78.6
Scatterplot is the most common graphical display for bivariate data. From the plot, we see that
the variable Y and x are positively related, that is, an increase in x tends to be associated with an increase in Y
the variable Y and x are linearly related, althought there is a large amount of variable that is unexplained
This is an example where a simple linear regression model may be adequate
1 > f i l t r a t i o n . r a t e <− c ( 1 2 5 . 3 , 9 8 . 2 , 2 0 1 . 4 , 1 4 7 . 3 , 1 4 5 . 9 , 1 2 4 . 7 , 1 1 2 . 2 , 1 2 0 . 2 , 1 6 1 . 2 , 1 7 8 . 9 , 1 5 9 . 5 ,
145.8 , 75.1 , 151.4 , 144.2 , 125.0 , 198.8 , 132.5 , 159.6 , 110.7)
2 > m o i s t u r e <− c ( 7 7 . 9 , 7 6 . 8 , 8 1 . 5 , 7 9 . 8 , 7 8 . 2 , 7 8 . 3 , 7 7 . 5 , 7 7 . 0 , 8 0 . 1 , 8 0 . 2 , 7 9 . 9 , 7 9 . 0 , 7 6 . 7 , 7 8 . 2 ,
79.5 , 78.1 , 81.5 , 77.0 , 79.0 , 78.6)
3 > p l o t ( f i l t r a t i o n . r a t e , m o i s t u r e , x l a b = ” F i l t r a t i o n r a t e ( kg −DS /m/ hr ) ” , y l a b = ” M o i s t u r e (
P e r c e n t a g e ) ” , pch = 1 9 , c o l = ” b l a c k ” )
n
X
Q(β0 , β1 ) = [Yi − (β0 + β1 x1 )]2 (10..3)
i=1
n
∂Q(β0 , β1 ) X set
= −2 (Yi − β0 − β1 xi ) = 0
∂β0 i=1
n
(10..4)
∂Q(β0 , β1 ) X set
= −2 (Yi − β0 − β1 xi )xi = 0
∂β1 i=1
c0 = Ȳ − β
β c1 x̄
Pn
(x − x̄)(Yi − Ȳ ) SSxy (10..5)
β
c1 = Pn i
i=1
2
=
i=1 (xi − x̄) SSxx
where
n
X n
X
SSxy = (xi − x̄)(Yi − Ȳ ) and SSxx = (xi − x̄)2 (10..6)
i=1 i=1
1 > f i l t r a t i o n . r a t e <− c ( 1 2 5 . 3 , 9 8 . 2 , 2 0 1 . 4 , 1 4 7 . 3 , 1 4 5 . 9 , 1 2 4 . 7 , 1 1 2 . 2 , 1 2 0 . 2 , 1 6 1 . 2 , 1 7 8 . 9 , 1 5 9 . 5 ,
6 Call :
7 lm ( f o r m u l a = m o i s t u r e ˜ f i l t r a t i o n . r a t e )
8
9 Coefficients :
10 ( Intercept ) f i l t r a t i o n . rate
11 72.95855 0.04103
12
From the output, we see the least squares estimates (to 3 dp) for the sewage data are
β
c0 = 72.959
β
c1 = 0.041
Therefore, the equation of the least squares line that relates moisture percentage Y to the filtration rate x is
Ŷ = 72.959 + 0.041x
or, in other words,
Moisture
\ = 72.959 + 0.041 × Filtration rate
The least squares line is also known as the prediction equation. This is because we can predict the value of Y (moisture)
for any value of x (filtration rate). For example, when the filtration rate is x = 150kg-DS/m/hr, we would predict the
moisture percentage to be
Ŷ (150) = 72.959 + 0.041(150) ≈ 79.109
E(β
c0 ) = β0
(10..7)
E(β
c1 ) = β1
c0 ∼ N (β0 , c00 σ 2 )
β
(10..8)
c1 ∼ N (β1 , c11 σ 2 )
β
where
1 (x̄)2 1
c00 = + and c11 = (10..9)
n SSxx SSxx
Knowing these sampling distributions is critical if we want to write confidence intervals and perform hypothesis tests
for β0 and β1
Terminology: In the simple linear regression mode, define the ithe fitted value by
Ybi = β
c0 + β
c1 xi (10..10)
where β
c0 and β
c1 are the least squares estimators. Each observation has its own fitted value. Geometrically, an observa-
tion’s fitted value is the (perpendicular) projection of its Y value, upward or downward, onto the least squares line
Terminology: We define the ithe residual by
ei = Yi − Ybi (10..11)
Each observation has its own residual. Geometrically, an observation’s residual is the vertical distance (i.e., length) be-
tween Y value and its fitted value
If an observation’s Y value is above the least squares regression line, its residual is positive
If an observation’s Y value is below the least square regression line, its residual is negative
In the simple linear regression model (provided that the model includes an intercept term β0 ), we have the following
algebraic result
n
X n
X
ei = (Yi − Ybi ) = 0 (10..12)
i=1 i=1
that is, the sum of residual (from a least square fit) is equal to zero
Terminology: We define the residual sum of squares
n
X n
X
SSres ≡ e2i = (Yi − Ybi )2 (10..13)
i=1 i=1
Obs x Y Ŷ = β
c0 + βc1 x e = Y − Ŷ Obs x Y Ŷ = β
c0 + βc1 x e = Y − Ŷ
1 125.3 77.9 78.100 −0.200 11 159.5 79.9 79.503 0.397
2 98.2 76.8 76.988 0.188 12 145.8 79.0 78.941 0.059
3 201.4 81.5 81.223 0.277 13 75.1 76.7 76.040 0.660
4 147.3 79.8 79.003 0.797 14 151.4 78.2 79.171 0.971
5 145.9 78.2 78.945 0.745 15 144.2 79.5 78.876 0.624
6 124.7 78.3 78.075 0.225 16 125.0 78.1 78.088 0.012
7 112.2 77.5 77.563 0.062 17 198.8 81.5 81.116 0.384
8 120.2 77.0 77.891 0.891 18 132.5 77.0 78.396 1.396
9 161.2 80.1 79.573 0.527 19 159.6 79.0 79.508 0.508
10 178.9 80.2 80.299 0.099 20 110.7 78.6 77.501 1.099
1 > f i l t r a t i o n . r a t e <− c ( 1 2 5 . 3 , 9 8 . 2 , 2 0 1 . 4 , 1 4 7 . 3 , 1 4 5 . 9 , 1 2 4 . 7 , 1 1 2 . 2 , 1 2 0 . 2 , 1 6 1 . 2 , 1 7 8 . 9 , 1 5 9 . 5 ,
145.8 , 75.1 , 151.4 , 144.2 , 125.0 , 198.8 , 132.5 , 159.6 , 110.7)
2 > m o i s t u r e <− c ( 7 7 . 9 , 7 6 . 8 , 8 1 . 5 , 7 9 . 8 , 7 8 . 2 , 7 8 . 3 , 7 7 . 5 , 7 7 . 0 , 8 0 . 1 , 8 0 . 2 , 7 9 . 9 , 7 9 . 0 , 7 6 . 7 , 7 8 . 2 ,
79.5 , 78.1 , 81.5 , 77.0 , 79.0 , 78.6)
3 > sewage . d a t a <− d a t a . f r a m e ( f i l t r a t i o n . r a t e , m o i s t u r e )
4 > model <− lm ( m o i s t u r e ˜ f i l t r a t i o n . r a t e , d a t a = sewage . d a t a )
5 > summary ( model )
6
7 Call :
8 lm ( f o r m u l a = m o i s t u r e ˜ f i l t r a t i o n . r a t e , d a t a = sewage . d a t a )
9
10 Residuals :
11 Min 1Q Median 3Q
12 −1.39552 −0.27694 0.03548 0.42913
13 Max
14 1.09901
15
16 Coefficients :
17 Estimate Std . Error
18 ( Intercept ) 72.958547 0.697528
19 f i l t r a t i o n . rate 0.041034 0.004837
20 t v a l u e Pr ( >| t | )
21 ( Intercept ) 1 0 4 . 5 9 6 < 2 e −16 ∗ ∗ ∗
22 f i l t r a t i o n . rate 8 . 4 8 4 1 . 0 5 e −07 ∗ ∗ ∗
23 −−−
24 S i g n i f . codes :
25 0 ∗∗∗ 0.001 ∗∗ 0.01 ∗ 0.05 .
26 0.1 1
27
28 R e s i d u a l s t a n d a r d e r r o r : 0 . 6 6 5 3 on 18 d e g r e e s o f f r e e d o m
29 M u l t i p l e R− s q u a r e d : 0 . 7 9 9 9 , A d j u s t e d R− s q u a r e d : 0.7888
30 F − s t a t i s t i c : 7 1 . 9 7 on 1 and 18 DF , p− v a l u e : 1 . 0 5 2 e −07
31
41 > r e s . s t d . e r r o r = s q r t ( MS r e s )
42 > res . std . error
43 [1] 0.6653946
c1 − β1
β
t= r ∼ t(n − 2) (10..16)
M Sres
SSxx
Note
Null hypothesis:
H0 = β 1 = △ 0
Alternative hypothesis:
Ha : β1 < △0
Ha : β1 > △0
Ha : β1 ̸= △0
where △0 is a fixed value (often, △0 = 0)
Confidence interval approach
β
c1
t0 = (10..18)
M Sres
SSxx
P -value approach
β
c1
t0 = (10..19)
M Sres
SSxx
Obs x Y Ŷ = β
c0 + βc1 x e = Y − Ŷ Obs x Y Ŷ = β
c0 + βc1 x e = Y − Ŷ
1 125.3 77.9 78.100 −0.200 11 159.5 79.9 79.503 0.397
2 98.2 76.8 76.988 0.188 12 145.8 79.0 78.941 0.059
3 201.4 81.5 81.223 0.277 13 75.1 76.7 76.040 0.660
4 147.3 79.8 79.003 0.797 14 151.4 78.2 79.171 0.971
5 145.9 78.2 78.945 0.745 15 144.2 79.5 78.876 0.624
6 124.7 78.3 78.075 0.225 16 125.0 78.1 78.088 0.012
7 112.2 77.5 77.563 0.062 17 198.8 81.5 81.116 0.384
8 120.2 77.0 77.891 0.891 18 132.5 77.0 78.396 1.396
9 161.2 80.1 79.573 0.527 19 159.6 79.0 79.508 0.508
10 178.9 80.2 80.299 0.099 20 110.7 78.6 77.501 1.099
Null hypothesis:
β1 = 0 where △0 = 0
Alternative hypothesis:
β1 ̸= 0 where △0 = 0
1 > summary ( lm ( m o i s t u r e ˜ f i l t r a t i o n . r a t e ) )
2
3 Call :
4 lm ( f o r m u l a = m o i s t u r e ˜ f i l t r a t i o n . r a t e )
5
6 Residuals :
7 Min 1Q Median 3Q
12 Coefficients :
13 Estimate Std . Error
14 ( Intercept ) 72.958547 0.697528
15 f i l t r a t i o n . rate 0.041034 0.004837
16 t v a l u e Pr ( >| t | )
17 ( Intercept ) 1 0 4 . 5 9 6 < 2 e −16 ∗ ∗ ∗
18 f i l t r a t i o n . rate 8 . 4 8 4 1 . 0 5 e −07 ∗ ∗ ∗
19 −−−
20 S i g n i f . codes :
21 0 ∗∗∗ 0.001 ∗∗ 0.01 ∗ 0.05 .
22 0.1 1
23
24 R e s i d u a l s t a n d a r d e r r o r : 0 . 6 6 5 3 on 18 d e g r e e s o f f r e e d o m
25 M u l t i p l e R− s q u a r e d : 0 . 7 9 9 9 , A d j u s t e d R− s q u a r e d : 0.7888
26 F − s t a t i s t i c : 7 1 . 9 7 on 1 and 18 DF , p− v a l u e : 1 . 0 5 2 e −07
Solution
Null hypothesis:
H0 : β1 = 0 where △0 = 0
Alternative hypothesis:
Ha : β1 ̸= 0 where △0 = 0
Sol 1: Confidence interval approach
The Estimate output gives β
c1 = 0.041034
The [Link] outcome gives se(b β
c1 ) = 0.004837
95% CI = β1 ± t18,0.025 se(
c b β1 ) = 0.041034 ± 2.101(0.004837) = (0.0309, 0.0512)
c
/ (0.0309, 0.0512) ⇒ reject H0
0∈
Sol 2: Critical value approach
The t value gives t values: t0 = 8.484
tn−2,α/2 = t18,0.025 = 2.101
⇒ t0 > t18,0.025 ⇒ reject H0
Sol 3: Critical value approach
The Pr(> |t|) gives p-value = 0.000000105
0.000000105 < 0.05 ⇒ p-value < α ⇒ reject H0
Conclusion: At 5% significance level, the data do not provide sufficient evidence to conclude that the population
regression slope β1 is different from 0
setting for the independent variable x = x0 . For example, in our sewage example, we might be interested in the moisture
percentage Y when the filtration rate is x = 150kg-DS/m/hr. Two potential goal arise:
We might be interested in estimating the mean response of Y when x = x0 . This mean response is denoted by E(Y |x0 ).
This value is the mean of the following probability distribution
We might be interested in predicting a new response Y when x = x0 . This predicted response is denoted by Y ∗ (x0 ).
This value is a new outcome frome
Y (x0 ) ∼ N (β0 + β1 x0 , σ 2 ) (10..21)
In the first problem, we are interested in estimating the mean of the response variable Y at a certain value of x, whereas
in the second problem, we are interested in predicting the value of a new random variable Y at a certain value of x.
Conceptually, the second problem is far more difficult than the first
100(1 − α)% interval for the mean E(Y |x0 ) is called a confidence interval (since it is for the mean response)
100(1 − α)% interval for the new value Y ∗ (x0 ) is called a prediction interval (since it is for a new random variable)
Point estimator/Predictor: To construct either interval, we start with the same quantity
Ŷ (x0 ) = β
c0 + β
c1 x0
where β
c0 and β
c1 are the least squares estimates from the fit of the model
In the confidence interval for E(Y |x0 ), we call Ŷ (x0 ) a point estimator
In the prediction interval for Y (x0 ), we call Ŷ (x0 ) a point predictor
Confidence interval: A 100(1 − α)% confidence interval for the mean E(Y |x0 ) is given by
s s
1 (x0 − x̄)2 1 (x0 − x̄)2
[Ŷ (x0 ) − tn−2,α/2 M Sres ( + ), Ŷ (x0 ) + tn−2,α/2 M Sres ( + )] (10..22)
n SSxx n SSxx
Prediction interval: A 100(1 − α)% prediction interval for the new response Y ∗ (x0 ) is given by
s s
1 (x0 − x̄)2 1 (x0 − x̄)2
[Ŷ (x0 ) − tn−2,α/2 M Sres (1 + + ), Ŷ (x0 ) + tn−2,α/2 M Sres (1 + + )] (10..23)
n SSxx n SSxx
Note
Comparison: The two intervals are identical except for the extra ”1” in the standard error part of the pre-
diction interval. This extra ”1” arises from the additional uncertaint with predicting a new response from the
N (β0 + β1 x0 , σ 2 ) distribution. Therefore, a 100(1 − α)% prediction interval for Y ∗ (x0 ) will be wider than the
corresponding 100(1 − α)% confidence interval for E(Y |x0 )
Interval length: The length of both intervals clearly depends on the value of x0 . In fact, the standard error of
Ŷ (x0 ) will be smallest when x0 = x̄ and will get larger the farther x0 is from x̄ in either direction. This implies that
the precision with which we estimate E(Y |x0 ) or predict Y ∗ (x0 ) decrease the farther we get away from x̄. This
make intuitive sense, namely, we would expect to have the most ”confidence” in our fitted modelnear the ”center”
of the observed data
It is sometimes desired to estimate E(Y |x0 ) or predict Y ∗ (x0 ) based on the fit of the model for values of x0 outside the
range of x values used in the experiment/study. This is called extrapolation and can be very dangerous. In order for our
inferences to be valid, we must believe that the straight line relationship holds for x values outside the range where we
have observed data. In some situations, this may be reasonable. In others, we may have no theoretical basis for making
such a claim without to support it.
Example: Sewage Data (cnt)
Suppose that we are interested in estimating E(Y |x0 ) and predicting a new Y ∗ (x0 ) when the filtration rate is x0 =
150kg-DS/m/hr
E(Y |x0 ) denotes the mean moisture percentage for compressed pellets when the machine filtration rate is x0 = 150kg-
DS/m/hr. In other words, it we were to repeat the experiment over and over again, each time using a filtration rate of
x0 = 150kg-DS/m/hr, then E(Y |x0 ) denotes the mean value of Y (moisture percentage) that would be observed
Y ∗ (x0 ) denotes a possible value of Y for a single run of the machine when the filtration rate is set at x0 = 150kg-
DS/m/hr
1 > f i l t r a t i o n . r a t e <− c ( 1 2 5 . 3 , 9 8 . 2 , 2 0 1 . 4 , 1 4 7 . 3 , 1 4 5 . 9 , 1 2 4 . 7 , 1 1 2 . 2 , 1 2 0 . 2 , 1 6 1 . 2 , 1 7 8 . 9 , 1 5 9 . 5 ,
145.8 , 75.1 , 151.4 , 144.2 , 125.0 , 198.8 , 132.5 , 159.6 , 110.7)
2 > m o i s t u r e <− c ( 7 7 . 9 , 7 6 . 8 , 8 1 . 5 , 7 9 . 8 , 7 8 . 2 , 7 8 . 3 , 7 7 . 5 , 7 7 . 0 , 8 0 . 1 , 8 0 . 2 , 7 9 . 9 , 7 9 . 0 , 7 6 . 7 , 7 8 . 2 ,
79.5 , 78.1 , 81.5 , 77.0 , 79.0 , 78.6)
3 > model <− lm ( m o i s t u r e ˜ f i l t r a t i o n . r a t e )
4 > p r e d i c t ( model , d a t a . f r a m e ( f i l t r a t i o n . r a t e = 1 5 0 ) , l e v e l = 0 . 9 5 , i n t e r v a l = ” c o n f i d e n c e ” )
5 fit lwr upr
6 1 79.11361 78.78765 79.43958
7 > p r e d i c t ( model , d a t a . f r a m e ( f i l t r a t i o n . r a t e = 1 5 0 ) , l e v e l = 0 . 9 5 , i n t e r v a l = ” p r e d i c t i o n ” )
8 fit lwr upr
9 1 79.11361 77.6783 80.54893
The point estimate (point prediction) is easily calculated: Ŷ (x0 = 150) = 72.959 + 0.041(150) ≈ 79.11361
A 95% confidence interval for E(Y |x0 ) is (78.79, 79.44). When the filtration rate is x0 = 150kg-DS/m/hr, we are 95%
confident that the mean moisture percentage is between 78.79 and 79.44 percent
A 95% prediction interval for Y ∗ (x0 = 150) is (77.68, 80.55). When the filtration rate is x0 = 150kg-DS/m/hr, we are
95% confident that the moisture percentage for a single run of the experiment will be between 77.68 and 80.55 percent
x1 , x2 , ..., xk . This is much more reaslistic because, in practice, often Y depends on many different factors (i.e., not just
one). Specifically, we consider models of the form
Yi = β0 + β1 xi1 + β2 xi2 + ... + βk xik + ϵi
for i = 1, 2, ..., n. We call this a multiple linear regression model
There are now p = k + 1 regression parameters β0 , β1 , ..., βk . These are unknown and are to be estimated with the
observed data
Schematically, we can envision the observed data as follows: Each of the n individuals contribute a response Y and
Individual Y x1 x2 ··· xk
1 Y1 x11 x12 ··· x1k
2 Y2 x21 x22 ··· x2k
.. .. .. .. .. ..
. . . . . .
n Yn xn1 xn2 ··· xnk
Specimen TASTE ACETIC H2S LACTIC Specimen TASTE ACETIC H2S LACTIC
1 12.3 4.543 3.135 0.86 16 40.9 6.365 9.588 1.74
2 20.9 5.159 5.043 1.53 17 15.9 4.787 3.912 1.16
3 39.0 5.366 5.438 1.57 18 6.4 5.412 4.700 1.49
4 47.9 5.759 7.496 1.81 19 18.0 5.247 6.174 1.63
5 5.6 4.663 3.807 0.99 20 38.9 5.438 9.064 1.99
6 25.9 5.697 7.601 1.09 21 14.0 4.564 4.949 1.15
7 37.3 5.892 8.726 1.29 22 15.2 5.298 5.220 1.33
8 21.9 6.078 7.966 1.78 23 32.0 5.455 9.242 1.44
9 18.1 4.898 3.850 1.29 24 56.7 5.855 10.20 2.01
10 21.0 5.242 4.174 1.58 25 16.8 5.366 3.664 1.31
11 34.9 5.740 6.142 1.68 26 11.6 6.043 3.219 1.46
12 57.2 6.446 7.908 1.90 27 26.5 6.458 6.962 1.72
13 0.7 4.477 2.996 1.06 28 0.7 5.328 3.912 1.25
14 25.9 5.236 4.942 1.30 29 13.4 5.802 6.685 1.08
15 54.9 6.151 6.752 1.52 30 5.5 6.176 4.787 1.25
MODEL: Researchers postulate that each of the three chemical composition variables x1 , x2 and x3 is important in
describing the taste and consider the multiple linear regression model
Yi = β0 + β1 xi1 + β2 xi2 + β3 xi3 + ϵi
for i = 1, 2, ..., 30
1 > t a s t e <− c ( 1 2 . 3 , 2 0 . 9 , 3 9 . 0 , 4 7 . 9 , 5 . 6 , 2 5 . 9 , 3 7 . 3 , 2 1 . 9 , 1 8 . 1 , 2 1 . 0 , 3 4 . 9 , 5 7 . 2 , 0 . 7 , 2 5 . 9 , 5 4 . 9 ,
40.9 , 15.9 , 6.4 , 18.0 , 38.9 , 14.0 , 15.2 , 32.0 , 56.7 , 16.8 , 11.6 , 26.5 , 0.7 , 13.4 , 5.5)
2 > a c e t i c <− c ( 4 . 5 4 3 , 5 . 1 5 9 , 5 . 3 6 6 , 5 . 7 5 9 , 4 . 6 6 3 , 5 . 6 9 7 , 5 . 8 9 2 , 6 . 0 7 8 , 4 . 8 9 8 , 5 . 2 4 2 , 5 . 7 4 0 , 6 . 4 4 6 ,
4.477 , 5.236 , 6.151 , 6.365 , 4.787 , 5.412 , 5.247 , 5.438 , 4.564 , 5.298 , 5.455 , 5.855 , 5.366 ,
6.043 , 6.458 , 5.328 , 5.802 , 6.176)
3 > h 2 s <− c ( 3 . 1 3 5 , 5 . 0 4 3 , 5 . 4 3 8 , 7 . 4 9 6 , 3 . 8 0 7 , 7 . 6 0 1 , 8 . 7 2 6 , 7 . 9 6 6 , 3 . 8 5 0 , 4 . 1 7 4 , 6 . 1 4 2 , 7 . 9 0 8 ,
2.996 , 4.942 , 6.752 , 9.588 , 3.912 , 4.700 , 6.174 , 9.064 , 4.949 , 5.220 , 9.242 , 10.20 , 3.664 ,
3.219 , 6.962 , 3.912 , 6.685 , 4.787)
4 > l a c t i c <− c ( 0 . 8 6 , 1 . 5 3 , 1 . 5 7 , 1 . 8 1 , 0 . 9 9 , 1 . 0 9 , 1 . 2 9 , 1 . 7 8 , 1 . 2 9 , 1 . 5 8 , 1 . 6 8 , 1 . 9 0 , 1 . 0 6 , 1 . 3 0 ,
1.52 , 1.74 , 1.16 , 1.49 , 1.63 , 1.99 , 1.15 , 1.33 , 1.44 , 2.01 , 1.31 , 1.46 , 1.72 , 1.25 , 1.08 , 1.25)
5 > model <− lm ( t a s t e ˜ a c e t i c + h 2 s + l a c t i c )
6 > summary ( model )
7
8 Call :
9 lm ( f o r m u l a = t a s t e ˜ a c e t i c + h 2 s + l a c t i c )
10
11 Residuals :
12 Min 1Q Median 3Q Max
13 −17.390 −6.612 −1.009 4.908 25.449
14
15 Coefficients :
16 E s t i m a t e S t d . E r r o r t v a l u e Pr ( >| t | )
17 ( Intercept ) −28.877 19.735 −1.463 0.15540
18 acetic 0.328 4.460 0.074 0.94193
19 h2s 3.912 1.248 3.133 0.00425 ∗ ∗
20 lactic 19.670 8.629 2.279 0.03109 ∗
21 −−−
22 S i g n i f . codes :
23 0 ∗∗∗ 0.001 ∗∗ 0.01 ∗ 0.05 . 0.1 1
24
25 R e s i d u a l s t a n d a r d e r r o r : 1 0 . 1 3 on 26 d e g r e e s o f f r e e d o m
26 M u l t i p l e R− s q u a r e d : 0 . 6 5 1 8 , A d j u s t e d R− s q u a r e d : 0.6116
27 F − s t a t i s t i c : 1 6 . 2 2 on 3 and 26 DF , p− v a l u e : 3 . 8 1 e −06
n
X n
X
SSres = (Yi − Ybi )2 = e2i (10..24)
i=1 i=1
The quantity s
p SSres
σ̂ = M Sres = (10..27)
n−p
1 > t a s t e <− c ( 1 2 . 3 , 2 0 . 9 , 3 9 . 0 , 4 7 . 9 , 5 . 6 , 2 5 . 9 , 3 7 . 3 , 2 1 . 9 , 1 8 . 1 , 2 1 . 0 , 3 4 . 9 , 5 7 . 2 , 0 . 7 , 2 5 . 9 , 5 4 . 9 ,
40.9 , 15.9 , 6.4 , 18.0 , 38.9 , 14.0 , 15.2 , 32.0 , 56.7 , 16.8 , 11.6 , 26.5 , 0.7 , 13.4 , 5.5)
2 > a c e t i c <− c ( 4 . 5 4 3 , 5 . 1 5 9 , 5 . 3 6 6 , 5 . 7 5 9 , 4 . 6 6 3 , 5 . 6 9 7 , 5 . 8 9 2 , 6 . 0 7 8 , 4 . 8 9 8 , 5 . 2 4 2 , 5 . 7 4 0 , 6 . 4 4 6 ,
4.477 , 5.236 , 6.151 , 6.365 , 4.787 , 5.412 , 5.247 , 5.438 , 4.564 , 5.298 , 5.455 , 5.855 , 5.366 ,
6.043 , 6.458 , 5.328 , 5.802 , 6.176)
3 > h 2 s <− c ( 3 . 1 3 5 , 5 . 0 4 3 , 5 . 4 3 8 , 7 . 4 9 6 , 3 . 8 0 7 , 7 . 6 0 1 , 8 . 7 2 6 , 7 . 9 6 6 , 3 . 8 5 0 , 4 . 1 7 4 , 6 . 1 4 2 , 7 . 9 0 8 ,
2.996 , 4.942 , 6.752 , 9.588 , 3.912 , 4.700 , 6.174 , 9.064 , 4.949 , 5.220 , 9.242 , 10.20 , 3.664 ,
3.219 , 6.962 , 3.912 , 6.685 , 4.787)
4 > l a c t i c <− c ( 0 . 8 6 , 1 . 5 3 , 1 . 5 7 , 1 . 8 1 , 0 . 9 9 , 1 . 0 9 , 1 . 2 9 , 1 . 7 8 , 1 . 2 9 , 1 . 5 8 , 1 . 6 8 , 1 . 9 0 , 1 . 0 6 , 1 . 3 0 ,
1.52 , 1.74 , 1.16 , 1.49 , 1.63 , 1.99 , 1.15 , 1.33 , 1.44 , 2.01 , 1.31 , 1.46 , 1.72 , 1.25 , 1.08 , 1.25)
5 > model <− lm ( t a s t e ˜ a c e t i c + h 2 s + l a c t i c )
6 > summary ( model )
7
8 Call :
9 lm ( f o r m u l a = t a s t e ˜ a c e t i c + h 2 s + l a c t i c )
10
11 Residuals :
12 Min 1Q Median 3Q Max
13 −17.390 −6.612 −1.009 4.908 25.449
14
15 Coefficients :
16 E s t i m a t e S t d . E r r o r t v a l u e Pr ( >| t | )
17 ( Intercept ) −28.877 19.735 −1.463 0.15540
18 acetic 0.328 4.460 0.074 0.94193
19 h2s 3.912 1.248 3.133 0.00425 ∗ ∗
20 lactic 19.670 8.629 2.279 0.03109 ∗
21 −−−
22 S i g n i f . codes :
23 0 ∗∗∗ 0.001 ∗∗ 0.01 ∗ 0.05 . 0.1 1
24
25 R e s i d u a l s t a n d a r d e r r o r : 1 0 . 1 3 on 26 d e g r e e s o f f r e e d o m
26 M u l t i p l e R− s q u a r e d : 0 . 6 5 1 8 , A d j u s t e d R− s q u a r e d : 0.6116
27 F − s t a t i s t i c : 1 6 . 2 2 on 3 and 26 DF , p− v a l u e : 3 . 8 1 e −06
From the Residual standard error output, σ = 10.13 ⇒ M Sres = σ 2 = (10.13)2 = 102.617
SStotal is the total sum of squares. SStotal is the numerator of the sample variance of Y1 , Y2 , ..., Yn . It measures the
total variation in the response data
SSreg is the regression sum of squares. SSreg measures the variation in the response data explained by the linear
regression model.
SSres is the residual sum of squares. SSres measures the variation in the response data not explained by the linear
regression model.
ANOVA Table: We can combine all of this information to produce an analysis of variance (ANOVA) table. Such tables
are standard in regression analysis
The degrees of freedom (df) all down:
SStotal can be viewed as a statistic that has “lost” a degree of freedom for having to estimate the overall mean of Y
with the sample mean Ȳ . Recall that n − 1 is our divisor in the sample variances S 2
There are k degrees of freedom associated with SSreg because there are k independent variables
The degrees of freedom for SSres can be thought of as the divisor needed to create an unbiased estimator of σ 2 . Recall
that
SSres SSres
M Sres = = (10..29)
n−p n−k−1
is an unbiased estimator of σ 2
The sum of squares (SS) also add down. This follows from the algebraic identity noted earlier
Mean squares (MS) are the sum of squares divided by the degrees of freedom
The F statistics is formed by taking the ratio of M Sreg and M Sres
Source df (ν) SS MS F
SSreg M Sreg
Regression k SSreg M Sreg = F =
k M Sres
SSres SSres
Residual n−p SSres M Sres = =
n−p n−k−1
Total n−1 SStotal
Coefficient of determination
Since
SStotal = SSreg + SSres (10..30)
The proportion of the total variation in the data explained by the linear regression model is called the coefficient of
determination.
SSreg SSres
R2 = =1− (10..31)
SStotal SStotal
The larger the R2 , the better the regression model explains the variability in the data
0 ≤ R2 ≤ 1 (10..32)
It is critical to understand what R2 does and does not measure. Its value is computed under the assumption that the
multiple linear regression model is correct and assesses how much of the variation in the data may be attributed to that
relationship rather than to inherent variation.
If R2 is small, it may be that there is a lot of random inherent variation in the data, so that, although the multiple linear
regression model is reasonable, it can explain only so much of the observed overall variation
Alternatively, R2 may be close to 1; e.g., in a simple linear regression model fit, but this may not be the best model.
In fact, R2 could be very “high,” but ultimately not relevant because it assumes the simple linear regression model is
correct. In reality, a better model may exist (e.g., a quadratic model, etc.).
One draw back of R2 is that, it can never decrease when a new x is added. Thus, it can be difficult to judge whether
the increase is telling us anything useful about the new x. Instead, many regression users prefer to use an adjusted R2
statistic:
SSres /(n − p)
2
Radjusted =1− (10..33)
SStotal /(n − 1)
F statistics
M Sreg
F = ∼ F (k, n − p) (10..34)
M Sres
Therefore, we can gauge the evidence against H0 by comparing F to this distribution. Values of F far out in the (right)
upper tail are evidence against H0 . R automatically produces the value of F and produces the corresponding p-value.
Recall the small p-values are evidence against H0 (the smaller p-value, the more evidence)
Example: Cheese data(cnt)
1 > t a s t e <− c ( 1 2 . 3 , 2 0 . 9 , 3 9 . 0 , 4 7 . 9 , 5 . 6 , 2 5 . 9 , 3 7 . 3 , 2 1 . 9 , 1 8 . 1 , 2 1 . 0 , 3 4 . 9 , 5 7 . 2 , 0 . 7 , 2 5 . 9 , 5 4 . 9 ,
40.9 , 15.9 , 6.4 , 18.0 , 38.9 , 14.0 , 15.2 , 32.0 , 56.7 , 16.8 , 11.6 , 26.5 , 0.7 , 13.4 , 5.5)
2 > a c e t i c <− c ( 4 . 5 4 3 , 5 . 1 5 9 , 5 . 3 6 6 , 5 . 7 5 9 , 4 . 6 6 3 , 5 . 6 9 7 , 5 . 8 9 2 , 6 . 0 7 8 , 4 . 8 9 8 , 5 . 2 4 2 , 5 . 7 4 0 , 6 . 4 4 6 ,
4.477 , 5.236 , 6.151 , 6.365 , 4.787 , 5.412 , 5.247 , 5.438 , 4.564 , 5.298 , 5.455 , 5.855 , 5.366 ,
6.043 , 6.458 , 5.328 , 5.802 , 6.176)
3 > h 2 s <− c ( 3 . 1 3 5 , 5 . 0 4 3 , 5 . 4 3 8 , 7 . 4 9 6 , 3 . 8 0 7 , 7 . 6 0 1 , 8 . 7 2 6 , 7 . 9 6 6 , 3 . 8 5 0 , 4 . 1 7 4 , 6 . 1 4 2 , 7 . 9 0 8 ,
2.996 , 4.942 , 6.752 , 9.588 , 3.912 , 4.700 , 6.174 , 9.064 , 4.949 , 5.220 , 9.242 , 10.20 , 3.664 ,
3.219 , 6.962 , 3.912 , 6.685 , 4.787)
4 > l a c t i c <− c ( 0 . 8 6 , 1 . 5 3 , 1 . 5 7 , 1 . 8 1 , 0 . 9 9 , 1 . 0 9 , 1 . 2 9 , 1 . 7 8 , 1 . 2 9 , 1 . 5 8 , 1 . 6 8 , 1 . 9 0 , 1 . 0 6 , 1 . 3 0 ,
1.52 , 1.74 , 1.16 , 1.49 , 1.63 , 1.99 , 1.15 , 1.33 , 1.44 , 2.01 , 1.31 , 1.46 , 1.72 , 1.25 , 1.08 , 1.25)
5 > model <− lm ( t a s t e ˜ a c e t i c + h 2 s + l a c t i c )
6 > summary ( model )
7
8 Call :
9 lm ( f o r m u l a = t a s t e ˜ a c e t i c + h 2 s + l a c t i c )
10
11 Residuals :
12 Min 1Q Median 3Q Max
13 −17.390 −6.612 −1.009 4.908 25.449
14
15 Coefficients :
16 E s t i m a t e S t d . E r r o r t v a l u e Pr ( >| t | )
17 ( Intercept ) −28.877 19.735 −1.463 0.15540
18 acetic 0.328 4.460 0.074 0.94193
19 h2s 3.912 1.248 3.133 0.00425 ∗ ∗
20 lactic 19.670 8.629 2.279 0.03109 ∗
21 −−−
22 S i g n i f . codes :
23 0 ∗∗∗ 0.001 ∗∗ 0.01 ∗ 0.05 . 0.1 1
24
25 R e s i d u a l s t a n d a r d e r r o r : 1 0 . 1 3 on 26 d e g r e e s o f f r e e d o m
26 M u l t i p l e R− s q u a r e d : 0 . 6 5 1 8 , A d j u s t e d R− s q u a r e d : 0.6116
27 F − s t a t i s t i c : 1 6 . 2 2 on 3 and 26 DF , p− v a l u e : 3 . 8 1 e −06
Solution
Null hypothesis:
H0 : β1 = β2 = β3 = 0
Alternative hypothesis:
Ha : at least one of the βj is nonzero
Based on the F − statistic (F = 16.22) and the corresponding p-value < 0.0001 (p − value = 0.00000381),
we have strong evidence to reject H0 .
Interpretation: We conclude that at least one of the independent variables (ACETIC, H2S, LACTIC) is important
in describing taste
The Multiple R − squared gives coefficient of determination R2 : R2 = 0.6518
⇒ about 65.2% of the variability in the taste data is explained by the linear regression model that includes
ACETIC, H2S and LACTIC. The remaining 34.8% of the variability in the taste data is explained by other sources
tance of using the independent variable xj in a model with the other independent variables. That is, inference regarding
βj is always conditional on the other variables being included in the model
Confidence interval
Hypothesis Testing
Null hypothesis:
H0 : βj = 0
Alternative hypothesis:
Ha : βj ̸= 0
can be performed by examining the p-value output
If H0 : βj = 0 is not rejected, then xj is not important in describing Y in the presence of the other independent
variables
If H0 : βj = 0 is rejected, this means that xj is important in describing Y even after including the effects of the other
independent variables
Hypothesis test for β1 : If our interest was to test, where j = 0, 1, ..., k
Null hypothesis:
H0 : βj = △0
Alternative hypotheis:
Ha : βj < △0
Ha : βj > △0
Ha : βj ̸= △0
where △0 is a fixed value (often △0 = 0)
Confidence interval approach
Hypothesis type Alternative hypothesis Rejection Criterion
Left-tail hypothesis Ha : βj < △0 △0 > βbj + tn−p,α se(
b βbj )
Right-tail hypothesis Ha : βj > △0 △0 > βbj − tn−p,α se(
b βbj )
Two-tail hypothesis Ha : βj ̸= △0 / [βbj ± tn−p,α/2 se(
△0 ∈ b βbj )]
βbj
t0 = (10..36)
se(
b βbj )
P -value approach
βbj
t0 = (10..37)
se(
b βbj )
8 Call :
9 lm ( f o r m u l a = t a s t e ˜ a c e t i c + h 2 s + l a c t i c )
10
11 Residuals :
12 Min 1Q Median 3Q Max
13 −17.390 −6.612 −1.009 4.908 25.449
14
15 Coefficients :
16 E s t i m a t e S t d . E r r o r t v a l u e Pr ( >| t | )
17 ( Intercept ) −28.877 19.735 −1.463 0.15540
18 acetic 0.328 4.460 0.074 0.94193
19 h2s 3.912 1.248 3.133 0.00425 ∗ ∗
20 lactic 19.670 8.629 2.279 0.03109 ∗
21 −−−
22 S i g n i f . codes :
23 0 ∗∗∗ 0.001 ∗∗ 0.01 ∗ 0.05 . 0.1 1
24
25 R e s i d u a l s t a n d a r d e r r o r : 1 0 . 1 3 on 26 d e g r e e s o f f r e e d o m
26 M u l t i p l e R− s q u a r e d : 0 . 6 5 1 8 , A d j u s t e d R− s q u a r e d : 0.6116
27 F − s t a t i s t i c : 1 6 . 2 2 on 3 and 26 DF , p− v a l u e : 3 . 8 1 e −06
Solution
Null hypothesis:
H0 : βj = 0 where △0 = 0
Alternative hypothesis:
Ha : βj ̸= 0 where △0 = 0
Sol 1: Confidence interval approach
The Estimate output gives the values of the
least squares
estimates:
β
c0 −28.877
c
β1 0.328
=
β
c2 3.912
β
c3 19.670
The [Link] output give standard error:
se(
b β c0 ) 19.735
se(
c
b β1 ) = 4.460
se(
b β c2 ) 1.248
se(
b βc3 ) 8.629
95% CI for regression parameters β0 , β1 , β2 and β3
c0 ± t26,0.025 se(
β b β c0 ) = −28.877 ± 2.056(19.735) = (−69.45, 11.70) ⇒ 0 ∈ (−69.45, 11.70) ⇒ not reject
H0 : β 0 = 0
c1 ± t26,0.025 se(
β b β c1 ) = 0.328 ± 2.056(4.460) = (−8.84, 9.50) ⇒ 0 ∈ (−8.84, 9.50) ⇒ not reject H0 : β1 = 0
c2 ± t26,0.025 se(
β b β / (1.35, 6.48) ⇒ reject H0 : β2 = 0
c2 ) = 3.912 ± 2.056(1.248) = (1.35, 6.48) ⇒ 0 ∈
c3 ± t26,0.025 se(
β b β / (1.93, 37.41 ⇒) reject H0 : β3 = 0
c3 ) = 19.670 ± 2.056(8.629) = (1.93, 37.41) ⇒ 0 ∈
Sol 2: Critical value approach
The t value gives the t statistics
tβc0 −1.463
tβc 0.074
1 =
t 3.133
βc2
tβc3 2.279
t26,0.025 = 2.056
tβc0 = −1.463 > −2.056 ⇒ not reject H0 : β0 = 0
tβc1 = 0.074 < 2.056 ⇒ not reject H0 : β1 = 0
tβc2 = 3.133 > 2.056 ⇒ reject H0 : β2 = 0
tβc3 = 2.279 > 2.056 ⇒ reject H0 : β3 = 0
Sol 3: p-value approach
The Pr(> |t|) outputs give p-value
pβc0 0.15540
pβc 0.94193
1 =
p 0.00425
βc2
pβc3 0.03109
pβc0 = 0.15540 > 0.05 ⇒ p-value > α ⇒ not reject H0 : β0 = 0
pβc1 = 0.94193 > 0.05 ⇒ p-value > α ⇒ not reject H0 : β1 = 0
pβc0 = 0.00425 < 0.05 ⇒ p-value < α ⇒ reject H0 : β2 = 0
pβc0 = 0.03109 < 0.05 ⇒ p-value < α ⇒ reject H0 : β3 = 0
Conclusion: At 5% significance level, the data do not provide sufficient evidence to conclude that the intercept
term β0 is not statistically different from zero, and ACETIC does not significantly add to a model that include H2S
and LACTIC, whereas H2S and LACTIC does considerably add to a model that include ACETIC, H2S and LACTIC
confidence ” )
7 fit lwr upr
8 1 23.93552 20.04506 27.82597
9 > p r e d i c t ( model , d a t a . f r a m e ( a c e t i c = 5 . 5 , h 2 s = 6 . 0 , l a c t i c = 1 . 4 ) , l e v e l = 0 . 9 5 , i n t e r v a l = ”
prediction ” )
10 fit lwr upr
11 1 23.93552 2.751379 45.11966
The term ”diagnostics” refers to the process of ”checking the model assumptions”. This is an important exercise be-
cause if the model assumptions are violated, then our analysis (and all subsequent interpretations) could be compromised
82).2 Residuals
In checking our model assumptions, we first have to deal with the obvious problem; namely, the error term ϵi in the
model are never observed. However, from the fit of the model, we can calculate the residuals:
ϵi = Yi − Ybi (10..38)
Advanced linear model arguments show that if the model does a good job at describing the data, then the residuals
and fitted values are independent
This means that a plot of the residuals versus the fitted values should reveal no noticeable patterns; that is, the plot
should appear to be random in nature (e.g., “a random scatter of points”).
On the other hand, if there are definite (non-random) patterns in the residual plot, this suggests that the model is
inadequate in some way or it could point to a violation in the model assumptions
Example: Cheese data(cnt)
1 > t a s t e <− c ( 1 2 . 3 , 2 0 . 9 , 3 9 . 0 , 4 7 . 9 , 5 . 6 , 2 5 . 9 , 3 7 . 3 , 2 1 . 9 , 1 8 . 1 , 2 1 . 0 , 3 4 . 9 , 5 7 . 2 , 0 . 7 , 2 5 . 9 , 5 4 . 9 ,
40.9 , 15.9 , 6.4 , 18.0 , 38.9 , 14.0 , 15.2 , 32.0 , 56.7 , 16.8 , 11.6 , 26.5 , 0.7 , 13.4 , 5.5)
2 > a c e t i c <− c ( 4 . 5 4 3 , 5 . 1 5 9 , 5 . 3 6 6 , 5 . 7 5 9 , 4 . 6 6 3 , 5 . 6 9 7 , 5 . 8 9 2 , 6 . 0 7 8 , 4 . 8 9 8 , 5 . 2 4 2 , 5 . 7 4 0 , 6 . 4 4 6 ,
4.477 , 5.236 , 6.151 , 6.365 , 4.787 , 5.412 , 5.247 , 5.438 , 4.564 , 5.298 , 5.455 , 5.855 , 5.366 ,
6.043 , 6.458 , 5.328 , 5.802 , 6.176)
3 > h 2 s <− c ( 3 . 1 3 5 , 5 . 0 4 3 , 5 . 4 3 8 , 7 . 4 9 6 , 3 . 8 0 7 , 7 . 6 0 1 , 8 . 7 2 6 , 7 . 9 6 6 , 3 . 8 5 0 , 4 . 1 7 4 , 6 . 1 4 2 , 7 . 9 0 8 ,
2.996 , 4.942 , 6.752 , 9.588 , 3.912 , 4.700 , 6.174 , 9.064 , 4.949 , 5.220 , 9.242 , 10.20 , 3.664 ,
3.219 , 6.962 , 3.912 , 6.685 , 4.787)
4 > l a c t i c <− c ( 0 . 8 6 , 1 . 5 3 , 1 . 5 7 , 1 . 8 1 , 0 . 9 9 , 1 . 0 9 , 1 . 2 9 , 1 . 7 8 , 1 . 2 9 , 1 . 5 8 , 1 . 6 8 , 1 . 9 0 , 1 . 0 6 , 1 . 3 0 ,
1.52 , 1.74 , 1.16 , 1.49 , 1.63 , 1.99 , 1.15 , 1.33 , 1.44 , 2.01 , 1.31 , 1.46 , 1.72 , 1.25 , 1.08 , 1.25)
5 > model <− lm ( t a s t e ˜ a c e t i c + h 2 s + l a c t i c )
6 > p l o t ( f i t t e d ( model ) , r e s i d u a l s ( model ) , x l a b = ” F i t t e d v a l u e s ” , y l a b = ” R e s i d u a l s ” , pch = 1 9 , c o l =
” black ” )
7 > a b l i n e ( h = 0 , c o l = ” b l a c k ” , lwd = 1 . 5 )
Figure 10..3: Residual plot for the multiple linear regression model fit
Scatterplot of peak demand Y versus monthly usage x Residual plot for the simple linear regression model fit
of a trumpet. This violation may have been missed by looking at the scatterplot alone, but the residual plot highlights it.
Remedy: A common course of action to handle non-constant variance is to apply a transformation to the response
√ 1
variable Y . Common transformations are logarithmic (ln Y ), square-root ( Y ), and inverse .
Y
A square root transformation is commonly applied to address non-constant variance. Consider the simple linear regres-
sion model
W i = β0 + β1 x i + ϵi
√
for i = 1, 2, ..., 53 where wi = Yi . It is straightforward to fit a quadratic model in R. We simply regress W on x
(instead of regression Y on x)
The ”fanning out” shape that we saw previously (in the untransformed model) is now largely absent. The fitted trans-
formed model is
Ŷ = 0.580831 + 0.0000953x
or, in the other words,
√
Peak demand = 0.580831 + 0.0000953 × Monthly usage
1 > f i t . 2 = lm ( s q r t ( peak . demand ) ˜ monthly . u s a g e )
2 > f i t .2
3 Coefficients :
4 ( I n t e r c e p t ) monthly . u s a g e
5 0.580831 0.000953
√
Scatterplot of square root peak demand Y versus Residual plot for the simple linear regression model fit
monthly usage x with transformed response
Scatterplot of DC output Y versus wind velocity x Residual plot for the simple linear regression model fit
Problem: There is a clear quadratic relationship between DC output and wind velocity, so a simple linear regression
model fit (as shown above) is inappropriate. The residual plot shows a pronounced quadratic pattern; this pattern is not
accounted for in fitting a straight line model.
Remedy: Fit a multiple linear regression model with two independent variables: wind velocity x and its square x2 , that
is, consider the quadratic regression model
Yi = β0 + β1 xi + β2 x2i + ϵi
for i = 1, 2, ..., 25. It is straightforward to fit a quadratic model in R. We simply regress Y on x and x2 .
The fitted quadratic regression model is
Ŷ = −1.15590 + 0.72294x − 0.03812x2
or, in other words,
Time series plot of Y versus year x Residual plot for the simple linear regression model fit
xx