Lecture1 STAT4355
Lecture1 STAT4355
Spring 2020
Outline
1. Introduction (Ch 1)
2. Simple Linear Regression Model (Ch 2.1)
3. Least-Squares Estimation of the Parameters (Ch. 2.2)
4. Hypothesis Testing on the Slope and Intercept (Ch 2.3)
5. Interval Estimation in Simple Linear Regression (Ch 2.4)
6. Prediction of New Observations (Ch 2.5)
7. Coefficient of Determination(Ch 2.6)
8. Regression Through the Origin (Ch 2.10)
9. Estimation by Maximum Likelihood (Ch 2.11)
2
Introduction
2
Time spent on Instagram
Instagram (IG or Insta) is a photo and video-sharing social
networking service owned by Facebook, Inc. Instagram users can
follow other users to add their content to a feed (Wikipedia).
5
Regression analysis (cont’d)
The data points do not fall exactly on a straight line. Let the
difference between the observed value of y and the straight line
(β0 + β1 x) be an error ε.
6
Regression analysis (cont’d)
y = β0 + β1 x + ε
7
The Origin of the term “Regression”
8
Regress to the mean: Galton’s Example
9
Regression Effect & Fallacy
I Regression effect: It’s unlikely, on average, to always remain
far out from the mean (in either direction).
I Attributing these expected variations to an outside in
influence is the Regression fallacy.
I Examples
I In a test-retest situation, those who scored below the mean on
the first test tend on average to show improvement while those
who scored above the mean tend on on average to fall back.
I In MLB, the 1st year mean batting average for “Rookies of the
Year” is 0.285. In their 2nd year, these “Rookies of the Year”
had a mean b.a. of 0.272. This is called the “sophomore
slump”, which is blamed on stress of limelight, players get big
heads, etc.
I 30-yr. mean batting average (b.a.) for major leagues is 0.260.
10
Use of Regression
Regression models are used for several purposes, including the
following:
1. Data description
I Engineers and scientists frequently use equations to summarize
or describe a set of data. Regression analysis is helpful in
developing such equations.
I For example, we may collect a considerable amount of data on
IG users’ daily use and followings, and a regression model
would probably be a much more convenient and useful
summary of those data than a table or even a graph.
2. Prediction and estimation
I Many applications of regression involve prediction of the
response variable.
I For example, we may wish to predict daily average IG use for a
specified number of followings.
I However, even when the model form is correct, poor estimates
of the model parameters may still cause poor prediction
performance.
11
Simple Linear Regression Model
12
Simple Linear Regression Model
y = β0 + β1 x + ε
13
Simple Linear Regression Model (cont’d)
E (y |x) = β0 + β1 x
Var(y |x) = Var(β0 + β1 x + ε) = σ 2
14
Least-Squares Estimation of the Parameters
15
Least Squares Estimation
16
Least Squares Estimation (cont’d)
Method of least squares : we want to minimize the sum of the
squares of the differences between the observations yi and the
straight line.
17
Least Squares Estimation (cont’d)
yi = β0 + β1 xi + εi for i = 1, 2, . . . , n
18
Estimation of β0 and β1
19
Estimation of β0 and β1 (cont’d)
Simplifying two equations yields
Xn n
X
nβb0 + βb1 xi = yi
i=1 i=1
n
X Xn Xn
βb0 xi + βb1 xi2 = yi xi
i=1 i=1 i=1
Then,
Sxy
βb1 =
Sxx
21
Estimation of β0 and β1 (cont’d)
βb0 and βb1 are the least-squares estimators of the intercept and
slope, respectively.
22
Example: Rocket Propellant Data
A rocket motor is manufactured by bonding an igniter propellant
and a sustainer propellant together inside a metal housing.
23
Rocket Propellant Example (cont’d)
i xi yi xi2 xi yi
1 15.50 2158.70 240.25 33459.85
2 23.75 1678.15 564.06 39856.06
.. .. .. .. ..
. . . . .
20 21.50 1753.70 462.25 37704.55
Total 266.75 42627.15 4672.44 527388.90
25
Rocket Propellant Example (cont’d)
y = 2, 131.3575, x = 13.3625, n = 20
X n n
X
yi = 42, 627.15, xi = 267.25
i=1 i=1
n
X n
X
xi yi = 528, 492.64, xi2 = 4, 677.69
i=1 i=1
26
Rocket Propellant Example (cont’d)
n
X
Sxx = (xi − x)2 = 1, 106.56
i=1
n
X
Sxy = (xi − x)(yi − y ) = −41, 112.65
i=1
27
Rocket Propellant Example (cont’d)
28
Residual ei
29
Residual ei (cont’d)
Illustration of Residuals
30
Residual ei (cont’d)
31
R programming: Reading data and fitting a model
32
R output
Call:
lm(formula = y ~ x)
Residuals:
Min 1Q Median 3Q Max
-215.98 -50.68 28.74 66.61 106.76
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2627.822 44.184 59.48 < 2e-16 ***
x -37.154 2.889 -12.86 1.64e-10 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
33
Properties of the LSE
i=1
xi − x
with ci = .
Sxx
34
Properties of the LSE (cont’d)
E (βb1 ) = β1
35
Properties of the LSE (cont’d)
σ2
Var(βb1 ) =
Sxx
36
Properties of the LSE (cont’d)
E (βb0 ) = β0
37
Properties of the LSE (cont’d)
1 x2
Var(βb0 ) = σ 2 +
n Sxx
38
Properties of the least-squares fit
I The sum of the residuals in any regression model that
n
X
contains an intercept β0 is always zero, that is, ei = 0.
i=1
39
Properties of the least-squares fit (cont’d)
I The least-squares regression line always passes through the
centroid [the point (y , x)] of the data.
40
Properties of the least-squares fit (cont’d)
41
Estimation of σ 2
42
Estimation of σ 2 (cont’d)
n
X
SSE = ei2 Sum of Squared Error
i=1
Xn
= (yi − βb0 − βb1 xi )2
i=1
Xn
= (yi − y + βb1 x − βb1 xi )2
i=1
Xn n
X n
X
= (yi − y )2 − 2βb1 (yi − y )(xi − x) + βb12 (xi − x)2
i=1 i=1 i=1
Sxy S 2
xy
= Syy −2 Sxy + Sxx
Sxx Sxx
2
Sxy
= Syy − = Syy − βb1 Sxy = Syy − βb12 Sxx
Sxx
43
Estimation of σ 2 (cont’d)
1 Xn 1
σ2) = E
E (b ei2 = E (SSE ) = σ 2 (why?)
n−2 n−2
i=1
44
45
Rocket Propellant Example: Computing MSE
2
Sxy
SSE = Syy − = 166, 402.65
Sxx
SSE 166, 402.65
b2 = MSE =
σ = = 9, 244.59
n−2 18
p
σ
b = 9, 244.59 = 96.15
46
Alternative Form of the Model
yi = β0 + β1 (xi − x) + β1 x + εi
= (β0 + β1 x) + β1 (xi − x) + εi
= β0∗ + β1 (xi − x) + εi ,
where β0∗ = β0 + β1 x.
47
Hypothesis Testing on the Slope and Intercept
48
Hypothesis Testing on the Slope and Intercept
εi ∼ N(0, σ 2 )
49
Hypothesis Testing for β1
H0 : β1 = β10 vs H1 : β1 6= β10
βb1 − β10
Z0 = p ∼ N(0, 1)
σ 2 /Sxx
Do we know σ 2 ?
50
Hypothesis Testing for β1 (cont’d)
Typically σ 2 is unknown.
σ2
(n − 2)b
∼ χ2n−2 and σ
b2 and βb1 are independent
σ2
(why? will be discussed later).
βb1 − β10 H0
t0 = p ∼ tn−2
b2 /Sxx
σ
Rejection region: |t0 | > tα/2,n−2
51
Hypothesis Testing for β1 (cont’d)
βb1 − β10
t0 =
se(βb1 )
52
Hypothesis Testing for β0
A similar procedure can be used to test hypotheses about β0 .
To test
H0 : β0 = β00 vs H1 : β0 6= β00 ,
we would use the test statistic
βb0 − β00
t0 = ,
se(βb0 )
where s
1 x2
se(βb0 ) = b2
σ +
n Sxx
is the standard error of the intercept.
53
Rocket Propellant Example: Testing H0 : β1 = 0
From the textbook p.25,
Test H0 : β1 = 0.
b2 = 9, 244.59
We know βb1 = −37.15, Sxx = 1, 106.56, and σ
Then, s
b2
σ
se(βb1 ) = = 2.89
Sxx
Test statistic is
βb1
t0 = = −12.85
se(βb1 )
If we choose α = 0.05, the critical value of t is t0.025,18 = 2.101.
54
Rocket Propellant Example: Testing H0 : β0 = 0
Test H0 : β0 = 0.
Then, s
1 x2
se(βb0 ) = b2
σ + = 44.20
n Sxx
Test statistic is
βb0
t0 = = 59.45
se(βb0 )
If we choose α = 0.05, the critical value of t is t0.025,18 = 2.101.
55
Testing Significance of Regression
That is,
H0 : β1 = 0 vs H1 : β1 6= 0
This is a special case of the hypotheses H0 : β1 = β10 .
56
Testing Significance of Regression (cont’d)
1) Situations where H0 : β1 = 0 is not rejected
57
Testing Significance of Regression (cont’d)
2) Situations where H0 : β1 = 0 is rejected