Chapter2 (Simple Linear Regression)
Chapter2 (Simple Linear Regression)
Introduction
The simplest regression structure uses the Simple Linear Regression Model.
The term “simple” implies that a single regressor/independent variable X is
involved. ”Linear” implies linear relationship between X and Y or linear in
the parameters that is no parameters appear as an exponent or is multiplied
or divided by another parameter.
Examples 2.1
Uses of Regression
1. Prediction - using the data available in conjunction with the model to
predict/estimate future outcomes.
1
In regression analysis the 1st step is to determine whether it is reasonable to
assume that the curve of regression of Y on X is a straight line. For simple
linear regression, the model is given by;
Yi = β0 + β1 Xi + i
We shall use the Least Squares (LS) procedure to estimate the parameters
in the model given above. Although there are other procedures available for
estimating the parameters we shall, however, only use LS procedure.
This procedure is based on the following assumptions;
1. there is linear relationship between xi and yi .
3. 0i s are random variables with mean zero and constant variance. This
is called homogeneous assumption. Mathematically, this assumption is
E(i ) = 0 and V ar(i ) = E(2i ) = σ 2 .
5. ∼ N (0, σ 2 )
We call this the fitted model because the model now has estimated parame-
ters.
2
Defn: Residual
Let ri = yi − ŷi , the difference between observed and fitted values, and this
difference is called a residual.
Note: The residuals, as we shall see later are very useful for assessing the
adequacy of a model.
Dividing by n leads to
ȳ − β̂0 − β̂1 x̄ = 0
3
For β1 we have
n n
!
δ X δ X
ri2 = (yi − β̂0 − β̂1 )2
δβ1 i=1 δβ1 i=1
n
X
= −2 xi (yi − β̂0 − β̂1 )
i=1
n n n
x2i = 0
X X X
= −2 yi xi + 2β̂0 xi + 2β̂1
i=1 i=1 i=1
This simplifies to
n n n
x2i = 0
X X X
yi xi − β̂0 xi − β̂1 ∗
i=1 i=1 i=1
Equations marked with * are called normal equations. Solving for β̂0 from
the 1st normal equation we have
Pn Pn
i=1 yi i=1 xi
β̂0 = − β̂1
n n
and we can write the above as
β̂0 = ȳ − β̂1 x̄
n n n n
!2 n
1X 1
x2i = 0
X X X X
yi xi − xi yi + β̂1 xi − β̂1
i=1 n i=1 i=1 n i=1 i=1
n n n n n
!
1 1
( xi )2 − x2i =
X X X X X
β̂1 xi yi − yi xi
n i=1 i=1 n i=1 i=1 i=1
4
Pn
yi xi − nx̄ȳ
= Pi=1
n 2 2
i=1 xi − nx̄
Pn
i=1 (yi − ȳ)(xi − x̄)
= Pn 2
i=1 (xi − x̄)
We often state the above as
Sxy
βˆ1 =
Sxx
= i=1 (yi − ȳ)(xi − x̄) and Sxx = ni=1 (xi − x̄)2 .
Pn P
Where Sxy
Note: We first find β̂1 and then find β̂0 , using β̂0 = ȳ − β̂1 x̄.
The fitted line is ŷi = β̂0 + β̂0 xi . This fitted line is referred to by many
different names in Statistics. Some of the names are: the least squares line,
fitted regression line, estimated regression line or just the fitted model.
Example 2.2
Consider the following data set, where Y is the dependent variable and X is
the regressor variable.
X 4 8 5 9 10
Y 2 3 4 6 8
Solution
Pn Pn Pn
i=1 (yi − ȳ)(xi − x̄) yi xi
βˆ1 = Pn 2
β̂0 = i=1
− β̂1 i=1
5
From the data set:
Pn
xi = 36, ni=1 yi = 23,P ni=1 xi yi = 186, ni=1 x2i = 286,
P P P
i=1P n n
xi yi
x̄ = i=1
n
= 7.2 and ȳ = i=1
n
= 4.6
Thus
186 − 5(7.2)(4.6)
βˆ1 = = 0.7612
286 − 5(7.2)2
Therefore
β̂0 = 4.6 − 0.7617(7.2) = −0.8806
Thus the fitted line is;
ŷi = −0.8806 + 0.7617xi
If X is increased by one unit then Y will increase by 0.7617.
Prediction
The fitted regression line is used to predict the values of the dependent vari-
able given the value of the independent variable.
Example 2.3
Solution
ŷ = −0.8806 + 0.7617(7) = 4.4478
6
Properties of Least Squares Residuals
Pn
(i) i=1 ri =0
Pn
(ii) i=1 ri is minimum
Pn
(iii) i=1 xi ri = 0, that is sum of residuals weighted by the xi values is zero.
Pn
(iv) i=1 ŷi ri = 0, that is sum of residuals weighted by fitted values is zero.
7
we usually use what are referred to as Q − Q plots. These are plots
of ordered residuals versus the normal distribution quartiles q(j) which
are defined by
1
Z q(j) 1 1 2 j−
P (Z ≤ q(j) ) = exp− 2 z dz = 2
−∞ 2π n
The resulting plot should be a straight line or almost a straight line,
that is, there should be a linear relationship between q(j) and ordered
rj . We usually construct Q − Q plots using computer programs or
statistical packages, such as MINITAB, SPSS, SAS, e.t.c. We may also
use the histogram of residuals and for the assumption to be valid, the
histogram must resemble a bell/symtric shape.
1. Standardized Residuals
ei
di = √ , i = 1, 2, ..., n, E(di ) = 0 and V ar(di ) = 1
hatσ 2
If the errors are normally distributed, then approximately 95% of the
standardized residuals should fall in the interval (-2,2). Residuals that
are far outside this interval may indicate the presence of an outlier,
that is, an observation that is not typical of the rest of the data. You
may (may not) discard the outlier.
8
2. Studentised Residuals
ei
ri = q
M SE(1 − hii )
Problem Solution
-Variance increases with Y -Variance statbilizing transformation,
√
for example, y,ln y, y1
-Varinace shows ‘Double Bow’ shape -logistic regression
-Curvature with xi -Include x2i in the model
-Increasing variance with xi -Use weigted least squares
in the estimation of parameters
-Increasing variance with time -Use weigted least squares
in the estimation of parameters
-Linear time trend Include time as a regressor
-Seasonal effect -Include seasonal effect in the model
-Autocorrelation -Time series modelling
9
Activity 2.1
1. The table below gives observations on systolic blood pressure and age
for a sample of eight individuals
Chirps (Y) 24 21 19 19 19 15 12 11 10 22 18
Temp (X) 63 62 60 60 58 58 55 53 52 64 61
10
(c) Briefly describe how each of these model assumptions is checked.
xi 39 43 21 64 57 47 28 75 34 52
yi 65 78 52 82 92 89 73 98 56 75
11