Escolar Documentos
Profissional Documentos
Cultura Documentos
Contents
I Diagnostic: Residual analysis
I The ANOVA (ANalysis Of VAriance) decomposition
I Nonlinear relationships and linearizing transformations
I Simple linear regression model in the matrix notation
I Introduction to the multiple linear regression
Lesson 5. Regression analysis (second part)
Bibliography references
I Newbold, P. Estadstica para los negocios y la economa
(1997)
I Chapters 12, 13 and 14
I Pena, D. Regresion y Analisis de Experimentos (2002)
I Chapters 5 and 6
Regression diagnostics
Diagnostics
I The theoretical assumptions for the simple linear regression
model with one response variable y and one explicative
variable x are:
I Linearity: yi = 0 + 1 xi + ui , for i = 1, . . . , n
I Homogeneity: E [ui ] = 0, for i = 1, . . . , n
I Homoscedasticity: Var[ui ] = 2 , for i = 1, . . . , n
I Independence: ui and uj are independent for i 6= j
I Normality: ui N(0, 2 ), for i = 1, . . . , n
I We study how to apply diagnostic procedures to test if these
assumptions are appropriate for the available data (xi , yi )
I Based on the analysis of the residuals ei = yi yi
Diagnostics: scatterplots
Scatterplots
I The simplest diagnostic procedure is based on the visual
examination of the scatterplot for (xi , yi )
I Often this simple but powerful method reveals patterns
suggesting whether the theoretical model might be
appropriate or not
I We illustrate its application on a classical example. Consider
the four following datasets
Diagnostics: scatterplots
The Anscombe datasets
132 TWO-VARIABLE LINEAR REGRESSION
TABLE 3-10
Four Data Sets
DATASET 1 DATASET 2
X Y X Y
10.0 8.04 10.0 9.14
8.0 6.95 8.0 8.14
1'3.0 7.58 13.0 8.74
9.0 8 .81 9.0 8.77
11.0 8.33 11.0 9.26
14.0 9.96 14.0 8.10
6.0 7.24 6.0 6.13
4.0 4.26 4.0 3.10
12.0 10.84 12.0 9.13
7.0 4.82 7.0 7.26
5.0 5.68 5.0 4.74
DATASET 3 DATASET 4
X Y X Y
10.0 7.46 8.0 6.58
8.0 6.77 8.0 5.76
13.0 12.74 8.0 7.71
9.0 7.11 8.0 8.84
11.0 7.81 8.0 8.47
14.0 8.84 8.0 7.04
6.0 6.08 8.0 5.25
4.0 5.39 19.0 12.50
12.0 8.15 8.0 5.56
7.0 6.42 8.0 7.91
5.0 5.73 8.0 6.89
mean of X = 9.0,
mean of Y = 7.5, for all four data sets.
Diagnostics: scatterplots
The Anscombe example
I The estimated regression model for each of the four previous
datasets is the same
I yi = 3.0 + 0.5xi
I n = 11, x = 9.0, y = 7.5, rxy = 0.817
I The estimated standard error of the estimator 1 ,
s
sR2
(n 1)sx2
10 10
5 5
o 5 10 15 5 10 15 20
Data Set 1 Data Set 2
10 10
5 5
5 10 15 20 5 10 15 20
Data Set 3 Data Set 4
FIGURE 3-29 Scatterplots for the four data sets of Table 3-10
SOURCE: F. J . Anscombe, op cit.
Residual plots
I Several types of residual plots can be constructed. The most
common ones are:
I Plot of standardized residuals vs. x
I Plot of standardized residuals vs. y (the predicted responses)
I Deviations from the model hypotheses result in patterns on
these plots, which should be visually recognizable
Residual plots examples
5.1: Ej:
Consistency consistencia
of the con el modelo teorico
theoretical model
Residual plots examples
5.1: Ej: No linealidad
Nonlinearity
Residual plots examples
5.1: Ej: Heterocedasticidad
Heteroscedasticity
Residual analysis
Outliers
I In a plot of the regression line we may observe outlier data,
that is, data that show significant deviations from the
regression line (or from the remaining data)
I The parameter estimators for the regression model, 0 and 1 ,
are very sensitive to these outliers
I It is important to identify the outliers and make sure that they
really are valid data
Residual analysis
ANOVA table
Excel output
Nonlinear relationships and linearizing transformations
Introduction
I Consider the case when the deterministic part f (xi ; a, b) of
the response in the model
yi = f (xi ; a, b) + ui , i = 1, . . . , n
Linearizing transformations
I Examples of linearizing transformations:
I If y = f (x; a, b) = ax b then log y = log a + b log x. We have
I y 0 = log y , x 0 = log x, 0 = log a, 1 =b
I If y = f (x; a, b) = ab x then log y = log a + (log b)x. We have
I y 0 = log y , x 0 = x, 0 = log a, 1 = log b
I If y = f (x; a, b) = 1/(a + bx) then 1/y = a + bx. We have
I y 0 = 1/y , x 0 = x, 0 = a, 1 =b
I If y = f (x; a, b) = log(ax b ) then y = log a + b(log x). We
have
I y 0 = y , x 0 = log x, 0 = log a, 1 =b
A matrix treatment of linear regression
Introduction
I Remember the simple linear regression model,
yi = 0 + 1 xi + ui , i = 1, . . . , n
y1 = 0 + 1 x1 + u1
y2 = 0 + 1 x2 + u2
.. ..
. .
yn = 0 + 1 xn + un
A matrix treatment of linear regression
0 2 1
0 0
B 0 2 0 C
B C
Cov(u) = B . = 2I
@ .. .. . . . ... C
.
A
0 0 2
The regression model in matrix form
Least-squares estimation
I The least-squares vector parameter estimate is the unique
solution of the 2 2 matrix equation (check the dimensions)
(XT X) = XT y,
that is,
= (XT X) 1
XT y.
I The vector y = (yi ) of response estimates is given by
y = X
Introduction
I Use of the simple linear regression model: predict the value of
a response y from the value of an explanatory variable x
I In many applications we wish to predict the response y from
the values of several explanatory variables x1 , . . . , xk
I For example:
I forecast the value of a house as a function of its size, location,
layout and number of bathrooms
I forecast the size of a parliament as a function of the
population, its rate of growth, the number of political parties
with parliamentary representation, etc.
The multiple linear regression model
The model
I Use of the multiple linear regression model: predict a response
y from several explanatory variables x1 , . . . , xk
I If we have n observations, for i = 1, . . . , n,
y =X +u
Least-squares estimation
I The least-squares vector parameter estimate is the unique
solution of the (k + 1) (k + 1) matrix equation (check the
dimensions)
(XT X) = XT y,
and as in the k = 1 case (simple linear regression) we have
= (XT X) 1
XT y.
y = X
Variance estimation
I For the multiple linear regression model, an estimator for the
error variance 2 is the residual (quasi-)variance,
Pn 2
2 i=1 ei
sR = ,
n k 1
and this estimator is unbiased
I Note that for the simple linear regression case we had n 2 in
the denominator
The multiple linear regression model
The sampling distribution of
I Under the model assumptions, the least-squares estimator
for the parameter vector follows a multivariate normal
distribution
I E ( ) = (it is an unbiased estimator)
I The covariance matrix for is Cov( ) = 2 (XT X) 1
j j
tn k 1 (the Student-t distribution)
s( j )
The multiple linear regression model
j
T =
s( j )
ANOVA table