Lecture 4 - Simple Linear Regression - Part III
Lecture 4 - Simple Linear Regression - Part III
Simple Linear
Regression -
Part III
Prof. Amany
E. Aly
Lecture 4: Simple Linear Regression - Part III
Comparing
Models: The
Analysis of
Variance
Lecture 4:
Simple Linear
Regression -
1 Comparing Models: The Analysis of
Part III
Prof. Amany
Variance
E. Aly
Interpreting
p−values
4 The Coefficient of Determination, R2
The
Coefficient of
Determina-
5 Confidence Intervals and Tests
tion,
R2 The Intercept
Confidence
Intervals and
Tests Slope
The Intercept
Slope
Prof. Amany
E. Aly
Comparing
Models: The
The analysis of variance provides a
Analysis of
Variance convenient method of comparing the fit
The F-Test for
Regression
of two or more mean functions for the
Interpreting
p−values
The
same set of data.
Coefficient of
Determina-
tion,
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Lecture 4:
Simple Linear
Regression -
Part III
Finding best line parallel to the horizontal
Prof. Amany
E. Aly or x−axis.
Comparing
Models: The
Analysis of
Variance
An elementary alternative to the simple
The F-Test for
Regression
Interpreting
regression model suggests fitting the mean
p−values
The
function
Coefficient of
Determina-
tion,
R2 E(Y |X = x) = β0 (2.13)
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
The ols estimate of the mean function is
E. Aly
Comparing
b |X) = βb0,
E(Y
Models: The
Analysis of
Variance
The
D β0 i=1
Coefficient of
Determina-
tion,
R2
i.e. n
Confidence
X
Intervals and
Tests
yi = n β0 ⇒ βb0 = y
The Intercept
Slope i=1
Prof. Amany E. Aly ( Professor of Statistics, Lecture
Department
4: Simple
of Mathematics,
Linear Regression
Faculty- of
Part
Science,
III Helwan University,
4 / 3Ain
/2024
Helwan, Cairo,
7 / 58 Eg
Lecture 4:
Simple Linear
Regression -
The residual sum of squares is
Part III
Prof. Amany Xn
(yi − β0)2
E. Aly
Comparing
RSS(β0) =
Models: The
Analysis of i=1
Variance
Xn
The F-Test for
Regression
Interpreting
= (yi − y)2
p−values
i=1
The
Coefficient of
Determina- = SY Y (2.14)
tion,
R2
Confidence
Intervals and
RSS has n − 1 degree of freedom, df ,
Tests
The Intercept
Slope
= n− (no of parameters to be estimated.)
Prof. Amany E. Aly ( Professor of Statistics, Lecture
Department
4: Simple
of Mathematics,
Linear Regression
Faculty- of
Part
Science,
III Helwan University,
4 / 3Ain
/2024
Helwan, Cairo,
8 / 58 Eg
II: Best line of arbitrary slope.
Lecture 4:
Simple Linear
Regression - Finding best line of arbitrary slope.
Part III
E(Y |X = x) = β0 + β1 x
Prof. Amany
E. Aly (2.15)
Comparing
Models: The
Analysis of
Variance
Interpreting
RSS(β0, β1) =
p−values
The
i=1
Coefficient of
Determina- SXY
tion,
R2 βb1 =
Confidence SXX
Intervals and
Tests
The Intercept
βb0 = y − βb1 x
Slope
Prof. Amany
RSS has n − 2 degree of freedom, df ,
E. Aly
= n− (no of parameters to be estimated.)
Comparing
Models: The
Analysis of
Variance (SXY )2
The F-Test for RSS(β0, β1) = SY Y − (2.16)
Regression
SXX
Interpreting
p−values
= SY Y − βb12 SXX
The
Coefficient of
Determina-
tion,
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly
Comparing
Models: The
Analysis of
Variance
Interpreting
p−values
The
Coefficient of
Determina-
tion,
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
The estimates of β0 under the two mean
E. Aly
Comparing
functions are different, just as the meaning
Models: The
Analysis of
Variance
of β0 in the two mean functions is
The F-Test for
Regression
different.
Interpreting
p−values For (2.13), β0 is the average of the yis,
The
Coefficient of
Determina-
tion,
For (2.15), β0 is the expected value of
R2
Confidence
Y when X = 0.
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly The difference between the sum of squares
Comparing
Models: The
at (2.14) and that at (2.16)
Analysis of
Variance
is the reduction in
The F-Test for
Regression
Interpreting
residual sum of squares due to enlarging
p−values
The
the mean function from (2.13) to the
Coefficient of
Determina-
tion, simple regression mean function (2.15).
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Confidence
SXX
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly
The df for SSreg is
Comparing
Models: The
Analysis of
(n − 1) − (n − 2) = 1
Variance
The
Coefficient of
Determina-
tion,
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Interpreting
p−values
The smaller one is obtained from the
The
Coefficient of
larger by setting some parameters to zero,
Determina-
tion,
R2
or occasionally setting them to some other
Confidence
Intervals and
Tests
known value.
The Intercept
Slope
Lecture 4:
Simple Linear
Regression -
Part III
Prof. Amany
E. Aly
Comparing
Models: The
Analysis of
Variance
Interpreting
p−values
The
Coefficient of
Determina-
tion,
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Lecture 4:
Simple Linear
Regression -
Part III
Prof. Amany
E. Aly
Comparing
Models: The
Analysis of
Variance
Interpreting
p−values
The
Coefficient of
Determina-
tion,
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Lecture 4:
Simple Linear
Regression -
1 Comparing Models: The Analysis of
Part III
Prof. Amany
Variance
E. Aly
Interpreting
p−values
4 The Coefficient of Determination, R2
The
Coefficient of
Determina-
5 Confidence Intervals and Tests
tion,
R2 The Intercept
Confidence
Intervals and
Tests Slope
The Intercept
Slope
Interpreting
p−values
The
should be a significant improvement over
Coefficient of
Determina-
tion,
the mean function given by
R2
Confidence
Intervals and
Tests
E(y|X = x) = β0.
The Intercept
Slope
Interpreting
We call this ratio F .
p−values
The
Coefficient of
Determina-
tion, (SY Y − RSS)/1 SSreg /1
R2 F = =
Confidence
Intervals and σb2 σb2
Tests
The Intercept
Slope
Interpreting
p−values
N H : E(Y |X = x) = β0
The
Coefficient of
Determina-
tion,
R2 AH : E(Y |X = x) = β0 + β1 x
Confidence
Intervals and
Tests
The Intercept
Slope
The
Coefficient of
regression. This is written
Determina-
tion,
R2
Confidence
F v F (1, n − 2).
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly
Comparing
Models: The
For Forbes’ data, we compute
Analysis of
Variance
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly
Comparing
Models: The
We obtain a significance level or p−value
Analysis of
Variance for this test by comparing F to the
The F-Test for
Regression percentage points of the
Interpreting
p−values
The
F (1, n − 2)-distribution.
Coefficient of
Determina-
tion,
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly The p−value is shown as approximately
Comparing
Models: The zero, meaning that, if the N H were true,
Analysis of
Variance
Interpreting
value is essentially zero.
p−values
Lecture 4:
Simple Linear
Regression -
1 Comparing Models: The Analysis of
Part III
Prof. Amany
Variance
E. Aly
Interpreting
p−values
4 The Coefficient of Determination, R2
The
Coefficient of
Determina-
5 Confidence Intervals and Tests
tion,
R2 The Intercept
Confidence
Intervals and
Tests Slope
The Intercept
Slope
Prof. Amany
E. Aly A small p−value provides evidence against
Comparing
Models: The
the N H.
Analysis of
Variance
Interpreting
In some research areas, it has become
p−values
The
traditional to adopt a fixed significance
Coefficient of
Determina-
tion, level when examining p−values.
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly For example, if a fixed significance level of
Comparing
Models: The α is adopted, then we would say that an
Analysis of
Variance
Interpreting
less than α.
p−values
The
Coefficient of
Determina-
tion,
R2
The most common choice for α is 0.05.
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly
Comparing
Models: The
Which would mean that, were the N H to
Analysis of
Variance be true, we would incorrectly find evidence
The F-Test for
Regression
against it about 5% of the time, or about
Interpreting
p−values
The
1 test in 20.
Coefficient of
Determina-
tion,
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Lecture 4:
Simple Linear
Regression -
1 Comparing Models: The Analysis of
Part III
Prof. Amany
Variance
E. Aly
Interpreting
p−values
4 The Coefficient of Determination, R2
The
Coefficient of
Determina-
5 Confidence Intervals and Tests
tion,
R2 The Intercept
Confidence
Intervals and
Tests Slope
The Intercept
Slope
Prof. Amany
E. Aly
The coefficient of determination, R2, is
Comparing
defined by:
Models: The
Analysis of
Variance SSreg
The F-Test for R2 =
Regression
Interpreting
SY Y
p−values RSS
The = 1−
Coefficient of
Determina-
tion,
SY Y
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
For Forbes data,
E. Aly
SSreg 425.63910
Comparing
Models: The R2 = = = 0.995
Analysis of
Variance SY Y 427.79402
The F-Test for
Regression
Interpreting
p−values
Thus about 99.5% of the variability in the
The
Coefficient of
Determina-
tion,
observed values or 100 × log(P ressure)
R2
Confidence
is explained by boiling point.
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly
We can write
Comparing SSreg
2 (SXY )2 2
Models: The
Analysis of R = = = rxy .
Variance
Interpreting
p−values
Thus R2 is the same as the square of the
The
Coefficient of
sample correlation between the predictor
Determina-
tion,
R2
and the response.
Confidence
Intervals and
Tests
The Intercept
Slope
Lecture 4:
Simple Linear
Regression -
1 Comparing Models: The Analysis of
Part III
Prof. Amany
Variance
E. Aly
Interpreting
p−values
4 The Coefficient of Determination, R2
The
Coefficient of
Determina-
5 Confidence Intervals and Tests
tion,
R2 The Intercept
Confidence
Intervals and
Tests Slope
The Intercept
Slope
Prof. Amany
E. Aly
The intercept is used to illustrate the
Comparing general form of confidence intervals for
Models: The
Analysis of
Variance normally distributed estimates.
The F-Test for
Regression
The standard error of the intercept is
Interpreting
p−values r
The
Coefficient of 1 x2
Determina- se(β0) = σ
b b +
tion,
R2 n SXX
Confidence
Intervals and
Tests
The Intercept
Slope
The
6 β0
Coefficient of
Determina-
tion,
6 βb0 + t(α/2, n − 2) se(βb0)
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Confidence
= t(0.05, 15)
Intervals and
Tests
The Intercept
= 1.753.
Slope
Prof. Amany
E. Aly
The interval is
Comparing −42.138 − 1.753(3.340) 6 β0 6 −42.136 + 1.753(3.340)
Models: The
Analysis of
Variance
The
Coefficient of
Ninety percent of such intervals will include the
Determina-
tion,
R2
true value.
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly N H : β0 = β0∗, β1 arbitrary
Comparing
Models: The AH : β0 6= β0∗, β1 arbitrary
Analysis of
Variance
Confidence
Intervals and
which means referring this ratio to the
Tests
The Intercept
Slope
t−distribution with n − 2 df .
Prof. Amany E. Aly ( Professor of Statistics, Lecture
Department
4: Simple
of Mathematics,
Linear Regression
Faculty- of
Part
Science,
III Helwan University,
4 / 3 Ain
/2024
Helwan,45
Cairo,
/ 58 Eg
Lecture 4:
Simple Linear
Regression -
Part III In Forbes’ data, consider testing
Prof. Amany
E. Aly N H : β0 = −35 against
Comparing
Models: The AH : β0 6= −35.
Analysis of
Variance
Lecture 4:
Simple Linear
Regression -
Part III
Prof. Amany
E. Aly The standard error of βb1 is
Comparing
Models: The
σ
Analysis of
se(βb1) = √
b
Variance
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
A a (1 − α) × 100% confidence interval
E. Aly
Comparing
for the intercept is the set of points β1 in
Models: The
Analysis of
Variance
the interval
The F-Test for
Regression
Interpreting
βb1 − t(α/2, n − 2) se(βb1)
p−values
The
Coefficient of
6 β1
Determina-
tion,
R2
6 βb1 + t(α/2, n − 2) se(βb1)
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
A 95% confidence interval for the slope
E. Aly
95% ⇒ 1 − α = 0.95 ⇒ α = 0.05
Comparing
Models: The
Analysis of α 0.05
Variance
t( , n − 2) = t , 17 − 2
The F-Test for
Regression 2 2
Interpreting
p−values = t(0.025, 15)
The
Coefficient of
Determina- = 2.131.
tion,
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly
Comparing
The interval is
Models: The
Analysis of
Variance
0.8955 − 2.131(0.0164) 6 β1 6 0.8955 + 2.131(0.0164)
The F-Test for
Regression
Interpreting
p−values
0.861 6 β1 6 0.930
The
Coefficient of
Determina-
tion,
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
As an example of a test for slope equal to
E. Aly
Comparing
zero, consider the Ft. Collins snowfall data
Models: The
Analysis of
Variance
presented on page 7.
The F-Test for
Regression
The test of interest is
Interpreting
p−values
The
N H : β1 = 0
Coefficient of
Determina-
tion,
R2 AH : β1 6= 0
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly
Comparing
Models: The
Analysis of
So the square of a t statistic with d df
Variance
The
Coefficient of
Determina-
tion,
R2
Confidence
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly
For linear regression models, no conflict
Comparing
occurs and the two tests are equivalent.
Models: The
Analysis of
Variance In nonlinear and logistic regression
The F-Test for
Regression models, the analog of the t test will not
Interpreting
p−values
The
be identical to the analog of the F
Coefficient of
Determina-
tion,
test, and they can give conflicting
R2
Confidence
conclusions.
Intervals and
Tests
The Intercept
Slope
Comparing 0.5
Models: The
Analysis of
Variance 0.4
The F-Test for
Regression
0.3
Interpreting
p−values
0.2
The
Coefficient of α = 0.05
Determina- 0.1
tion,
R2 F
Confidence 1 2 3 4
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly
0.3
Comparing
Models: The
Analysis of
Variance
The 0.1
Coefficient of
Determina-
tion,
R2 α \2 α/2
Confidence -3 -2 L -1 1 U 2 3
Intervals and
Tests
The Intercept
Slope
Prof. Amany
E. Aly P (L < β0 < U ) = 1 − α
Comparing
Models: The
Analysis of
Variance
P − value = P (F > F0 )
The F-Test for
Regression
Interpreting
p−values
> α, don’t reject H0 ;
The
Coefficient of
Determina-
=
tion,
< α, reject H0 .
R2
Confidence
Intervals and
Tests Where F0 is the observed value of F .
The Intercept
Slope