```Lecture 1: Linear Models and Applications
TU M¨
unchen
°
ZFS/IMS G¨ottingen 2004
–0–
Overview
• Introduction to linear models
• Exploratory data analysis (EDA)
• Estimation and testing in linear models
• Regression diagnostics
°
ZFS/IMS G¨ottingen 2004
–1–
Introduction to linear models
Goal of regression models is to determine how a response variable depends on
covariates. A special class of regression models are linear models. The general
setup is given by
Data
Responses
Covariates
(Yi, xi1, ..., xik ), i = 1, ..., n
Y = (Y1, ..., Yn)T
xi = (xi1, ..., xik )T (known)
°
ZFS/IMS G¨ottingen 2004
–2–
Example: Life Expectancies from 40 countries
Source: The Economist’s Book of World Statistics, 1990, Time Books, The
World Almanac of Facts, 1992, World Almanac Books
LIFE.EXP
TEMP
URBAN
HOSP.POP
COUNTRY
Life Expectancy at Birth
Temperature in degrees Fahrenheit
Percent of population
living in urban areas
No. of hospitals per population
The name of the country
Which is the response and which are the covariates?
°
ZFS/IMS G¨ottingen 2004
–3–
Linear models (LM) under normality assumption
Yi = β0 + β1xi1 + ... + βk xik + ²i,
²i ∼ N (0, σ 2) iid,
i = 1, .., n,
where the unknown β0, ..., βk regression parameters and the the unknown error
variance σ 2 needs to be estimated. Note E(Yi) is a linear function in β0, ..., βk .
E(Yi) = β0 + β1xi1 + ... + βk xik
V ar(Yi) = V ar(²i) = σ 2 variance homogeneity
°
ZFS/IMS G¨ottingen 2004
–4–
LM’s in matrix notation
Y = Xβ + ²,
X ∈ Rn×p, p = k + 1, β = (β0, ..., βk )T
E(Y) = Xβ
V ar(Y) = σ 2In
Under the normal assumption we have
Y ∼ Nn(Xβ, σ 2In),
where Nn(µ, Σ) is the n-dimensional normal distribution with mean vector µ
and covariance matrix Σ. The matrix X is also called the design matrix.
°
ZFS/IMS G¨ottingen 2004
–5–
Exploratory data analysis (EDA)
Consider the ranges of the responses and covariates. When covariates are
discrete, group covariate levels if they are sparse.
Plot the covariates against the responses. These scatter plots should look
linear. Otherwise consider transformations of the covariates.
To check if the constant variance assumption is reasonable the scatter plot of
covariates against the responses should be contained in a band.
°
ZFS/IMS G¨ottingen 2004
–6–
Example: Life expectancies: Data summaries
> summary(health.data)
LIFE.EXP
Min.
:37
1st Qu.:56
Median :67
Mean
:65
3rd Qu.:73
Max.
:79
TEMP
Min.
:36
1st Qu.:52
Median :61
Mean
:62
3rd Qu.:73
Max.
:85
URBAN
Min.
:14
1st Qu.:42
Median :62
Mean
:59
3rd Qu.:76
Max.
:96
NA’s
: 1
HOSP.POP
Min. :0.0057
1st Qu.:0.0204
Median :0.0295
Mean
:0.0469
3rd Qu.:0.0614
Max.
:0.2190
NA’s
:6.0000
NA=not available (missing data)
°
ZFS/IMS G¨ottingen 2004
–7–
40 50 60 70 80
••
•
•
• •
•••
•
•
• •
••
••
•
•
•
0.0 0.05 0.10 0.15 0.20
•
•
•
•
•
• • •
•
••
•
•
•
•
•
• •
•
•
TEMP
•
•
•
•
•
•
•
•
•• •
•
•
••
•• •
•
•
••
•
•
••
•
• •
•
••
•
•
••
•
• • •
•
• • • •• •• • •• ••
•
•
•
• •• • •
40
50
60
70
80
•
• •• ••
•
•
••• • •
•
•
•
•
•
•
•• • ••
••
•
••••
•
• ••
••
••
• ••• •
•
• ••
•
•
0.20
•
70
•
URBAN
•
•
• •
•
•
•
••
•
• •
• •••• •
•
•
•
•
•
•
• • ••
•
•
•
•
•
•
••
•
••
•
•
•
•
••
•
•
••
•
•
•
•
•
•
•
•
•
• •
•• •
0.15
40
•
•
•
• •••
•
• ••
• ••
•
•
••
•
• •••
•
•
• • • •• •• •
•
•• •
•
•
•
•
•
•
•
0.10
80
•
•
• • •
0.05
•• •• • ••
•
••• •
•
•• •
• ••
•
•••
•
• ••
••
•
•
60
•
•
•
•
•
•
••
•
•••
•• • •• ••• • •
•
•
••
•
• •
•
•
•
60
0.0
•
50
80
• •
••
•
•
40
LIFE.EXP
50
60
70
•
• • • • • ••
•
• • ••
•
• •
••
••
•
• •
•
•
• ••
•
20
40
••
80
Example: Life expectancies: EDA
•
••
•
•
•
••
• • •
••
• • • • • •• • •
•
• •• • ••
•
•
•
•
•
••
HOSP.POP
•
•
•
•
••
• • •••• •• •
••
•
•
••• •
•
20
40
60
80
•
LIFE.EXP decreases if TEMP increases
LIFE.EXP increases if URBAN increases
LIFE.EXP increases if HOSP.POP increases
Check for nonlinearities and nonconstant variances
°
ZFS/IMS G¨ottingen 2004
–8–
Example: Life expectancies: Transformations
Norway
•
• Argentina
• China
••
•
••
•
50
• Tonga
••
• CostaRica
•
•
•
• Morocco
•
•
•
•
•
•
• Australia
Norway •
•
• China
•
• Tonga
•
•
•
• Egypt
• PapuaNewGuinea
• India
• India
0.0
•
• Egypt
• PapuaNewGuinea
•
• •
50
•
•
•
• ••
•
LIFE.EXP
60
LIFE.EXP
60
• Australia
• NewZealand
•
• •
•
•
70
70
UnitedStates • •
•
•
•
•••
•
• France
• Japan
•
0.05
0.10
HOSP.POP
0.15
0.20
-5
-4
-3
log(HOSP.POP)
-2
Logarithm makes relationship more linear.
°
ZFS/IMS G¨ottingen 2004
–9–
Parameter estimation of β
Under the normality assumption it is enough to minimize Q(β) :=k Y − Xβ k2
for β ∈ Rp to calculate the maximum likelihood estimate (MLE) of β. An
estimator which minimizes Q(β) is also called a least square estimator (LSE).
If the matrix X ∈ Rn×p has full rank p the minimum of Q(β) is taken at
ˆ = (X T X)−1X T Y
β
SSRes :=
n
P
i=1
ˆ
ˆ 2 = Q(β)
(Yi − xiT β)
ˆ
Yˆi := xi β
ei := Yi − Yˆi
It follows that
T
Residual Sum of Squares
fitted value for µi := E(Yi)
raw residual
ˆ = β and V ar(β)
ˆ = σ 2(X T X)−1,
E(β)
therefore one has under normality
ˆ ∼ Np(β, σ 2(X T X)−1).
β
°
ZFS/IMS G¨ottingen 2004
– 10 –
Parameter estimation of σ 2
The MLE of σ 2 is given by
n
n
1X
1X
2
Tˆ 2
σ
ˆ :=
(Yi − xi β) =
(Yi − Yˆi)2
n i=1
n i=1
One can show that the estimator is biased, in particular E(ˆ
σ 2) =
unbiased estimator for σ 2 is therefore given by
n−p 2
n σ .
An
n
X
1
n
2
2
ˆ
s :=
(Yi − Yi) =
σ
ˆ2
n − p i=1
n−p
Under normality it follows that
n
P
(n − p)s2
=
2
σ
°
i=1
(Yi − Yˆi)2
σ2
ˆ
∼ χ2n−p is independent of β.
ZFS/IMS G¨ottingen 2004
– 11 –
Goodness of fit in linear models
Consider
SST otal
n
X
=
(Yi − Y¯ )2,
SSReg
n
X
=
(Yˆi − Y¯ )2,
i=1
where Y¯ =
1
n
n
P
i=1
i=1
SSRes
n
X
=
(Yi − Yˆi)2,
i=1
Yi. It follows that
SST otal = SSReg + SSRes,
therefore
SSRes
SSReg
=1−
SST otal
SST otal
explains the proportion of variability explained by the regression. R2 is called
the multiple coefficient of determination.
R2 :=
°
ZFS/IMS G¨ottingen 2004
– 12 –
Statistical hypothesis tests in LM’s: F-test
The restriction
H0 : Cβ = d
for C ∈ Rr,p, rank(C) = r, d ∈ Rr is called general linear hypothesis with
alternative H1 : not H0. Consider the restricted least square problem
SSH0
= min{k Y − Xβ k22 | Cβ
= d}}
|
{z
β
under H
0
ˆ − d)T [C(XT X)−1CT ]−1(Cβ
ˆ − d)
= SSRes + (Cβ
Under normality and that H0 : Cβ = d is valid we have
(SSH0 − SSRes)/r
F =
∼ Fr,n−p,
SSRes/(n − p)
therefore the F-test is given by reject H0 at level α if F > F1−α,r,n−p. Here
Fn,m denotes the F distribution with n numerator and m denominator degree
of freedom and F1−α,n,m is the corresponding 1 − α quantile.
°
ZFS/IMS G¨ottingen 2004
– 13 –
Statistical hypothesis tests in LM’s: t-test
Consider for each regression parameter βj the hypothesis H0j : βj = 0, against
H1j : not H0j and use the corresponding F statistics
(SSH0j − SSRes)/1
Fj :=
∼ F1,n−p under H0j .
SSRes/(n − p)
It follows that Fj = Tj2, where
βˆj
Tj :=
∼ tn−p under H0j ,
ˆ
sˆe(βj )
where sˆe(βˆj ) is the estimated standard error of βˆj i.e.
q
sˆe(βˆj ) = s (X T X)−1
jj .
°
ZFS/IMS G¨ottingen 2004
– 14 –
Weighted Least Squares
Y = Xβ + ²,
² ∼ Nn(0, σ 2W ),
X ∈ Rn×p, p = k + 1, β = (β0, ..., βk )T
An MLE of β (weighted LSE) is given by
ˆ = (X T W −1X)−1X T W −1Y.
β
It follows that
ˆ = β and V ar(β)
ˆ = σ 2(X T W −1X)−1.
E(β)
The MLE of σ 2 is given by
1
1 T −1
T
−1
ˆ
ˆ
σ
ˆ := (Y − X β) W (Y − X β) = e W e.
n
n
2
°
ZFS/IMS G¨ottingen 2004
– 15 –
Example: Life expectancies: First models
Using the Original Scale for HOSP.POP
> attach(health.data)
> f1_LIFE.EXP ~ TEMP + URBAN + HOSP.POP
> r1_lm(f1,na.action = na.omit)
> summary(r1)
Call: lm(formula = f1, na.action = na.omit)
Residuals:
Min
1Q Median
3Q Max
-18.7 -4.72
1.63 4.89 14.7
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 60.666
9.088
6.676
0.000
TEMP -0.167
0.113
-1.480
0.150
URBAN
0.232
0.063
3.710
0.001
HOSP.POP 33.756 30.373
1.111
0.276
Residual standard error: 7.3 on 29 degrees of freedom
Multiple R-Squared: 0.46
F-statistic: 8.3 on 3 and 29 degrees of freedom, the p-value is 0.00039
Correlation of Coefficients:
(Intercept) TEMP URBAN
TEMP -0.90
URBAN -0.59
0.24
HOSP.POP -0.24
0.18 -0.14
TEMP and HOSP.POP are nonsignificant at the 10% level.
°
ZFS/IMS G¨ottingen 2004
– 16 –
Example: Life expectancies: First models
Using the Logarithmic Scale for HOSP.POP
> f2_LIFE.EXP ~ TEMP + URBAN + log(HOSP.POP)
> r2_lm(f2,na.action = na.omit)
> summary(r2)
Call: lm(formula = f2, na.action = na.omit)
Residuals:
Min
1Q Median
3Q Max
-17.6 -4.2
1.71 5.07 14.4
Coefficients:
Value Std. Error t value Pr(>|t|)
(Intercept) 72.964
9.917
7.357
0.000
TEMP -0.151
0.109
-1.387
0.176
URBAN
0.213
0.061
3.476
0.002
log(HOSP.POP)
3.133
1.638
1.912
0.066
Residual standard error: 7 on 29 degrees of freedom
Multiple R-Squared: 0.5
F-statistic: 9.7 on 3 and 29 degrees of freedom, the p-value is 0.00013
Correlation of Coefficients:
(Intercept) TEMP URBAN
TEMP -0.65
URBAN -0.67
0.22
log(HOSP.POP) 0.52
0.19 -0.24
TEMP is still nonsignificant, while log(HOSP.POP) is now significant at the
10% level. 50% of the total variability is explained by the regression.
°
ZFS/IMS G¨ottingen 2004
– 17 –
ANOVA Tables in LM’s
ANOVA= ANalysis Of VAriance
Model
null
full
reduced
Formula
Yi = β0 + ²i
Y = Xβ + ²
Y = X1β 1 + ²
SS
Pn
Pn
2
ˆ
SSE0 = i=1(Yi − β0) = i=1(Yi − Y )2
ˆ k2
SSE(X) =k Y − X β
ˆ k2
SSE(X1) =k Y − X1β
1
ANOVA table:
Source
regression
residual
total
df
p−1
n−p
n−1
°
Sum of Sq
SSReg = SSE0 − SSE(X)
SSE(X)
SSE0
MS
SSReg
M SReg = p−1
s2 = SSE(X)
n−p
F
M SReg
s2
ZFS/IMS G¨ottingen 2004
– 18 –
Hierarchical ANOVA Tables in LM’s
Y = Xβ + ² = X1β 1 + X2β 2 + ²
X ∈ Rn,p, X1 ∈ Rn,p1 , X2 ∈ Rn,p2 , p1 + p2 = p
ANOVA table:
Source
df
Sum of Sq
MS
F
X1
p1 − 1
SSE0 − SSE(X1 )
M S(X1 ) =
X2 given X1
p2
SSE(X1 ) − SSE(X)
M S(X2 |X1 ) =
residual
n−p
SSE(X)
s2 =
total
n−1
SSE0
SSE0 −SSE(X1 )
p1 −1
F (X1 ) =
SSE(X1 )−SSE(X)
p2
M S(X1 )
SSE(X1 )/(n−p1 )
F (X2 |X1 ) =
M S(X2 |X1 )
s2
SSE(X)
n−p
F (X1) tests H0 : β 1 = 0 in Y = X1β 1 + ² (overall F-test in reduced model).
F (X2|X1) tests H0 : β 2 = 0 in Y = X1β 1 + X2β 2 + ² (partial F-test).
°
ZFS/IMS G¨ottingen 2004
– 19 –
ANOVA Tables in Splus
> r <- lm(y ~x1+x2+x3)
> anova(r)
Source
x1
df
1
Sum of Sq
SS1 = SSE0 − SSE(x1)
MS
M S1 =
F
SS1
1
M S1
s2
x2
1
SS2 = SSE(x1) − SSE(x1, x2)
M S2 =
SS2
1
M S2
s2
x3
1
SS3 = SSE(x1, x2) − SSE(x1, x2, x3)
M S3 =
SS3
1
M S3
s2
residual
n−p
SSE(x1, x2, x3)
s2 =
SSE(X)
n−4
These F-values cannot be interpreted as partial F-values, since the denominator
2
1)
s
always assumes the full model. You need to replace it by s21 = SSE(x
,
2 =
n−2
SSE(x1 ,x2 )
SSE(x1 ,x2 ,x3 )
2
2
and
s
=
=
s
, respectively.
3
n−3
n−4
°
ZFS/IMS G¨ottingen 2004
– 20 –
Example: Life Expectancies: ANOVA Tables
ANOVA Table (Original Scale for HOSP.POP)
> anova(r1)
Analysis of Variance Table
Response: LIFE.EXP
Terms added sequentially (first to last)
Df Sum of Sq Mean Sq F Value Pr(F)
TEMP
1
455
455
8.5 0.007
URBAN
1
815
815
15.2 0.001
HOSP.POP
1
66
66
1.2 0.276
Residuals 29
1555
54
ANOVA Table (Log Scale for HOSP.POP)
> anova(r2)
Analysis of Variance Table
Response: LIFE.EXP
Terms added sequentially (first to last)
Df Sum of Sq Mean Sq F Value Pr(F)
TEMP
1
455
455
9.2 0.0051
URBAN
1
815
815
16.4 0.0003
log(HOSP.POP) 1
182
182
3.7 0.0658
Residuals
29
1440
50
°
ZFS/IMS G¨ottingen 2004
– 21 –
Regression diagnostics for LM’s
Goal is to determine
• outliers with regard to the response (y outliers)
• outliers with regard to the design space covered by the covariates (x outliers
or high leverage points)
• observations which change the results greatly when removed (influential
observations).
A general tool for this is to consider the hat matrix and residuals.
°
ZFS/IMS G¨ottingen 2004
– 22 –
Residuals in LM’s: hat matrix
:= X(X T X)−1X T hat matrix
ˆ = X(X T X)−1X T Y = HY fitted values
:= X β
r := Y − Yˆ = (I − H)Y residual vector
H
Yˆ
Properties:
• H is a projection matrix, i.e. H 2 = H and symmetric.
• E(r) = (I − H)E(Y ) = (I − H)Xβ = Xβ − HXβ = Xβ − Xβ = 0 .
• V ar(r) = σ 2(I − H)(I − H)T = σ 2(I − H)
• V ar(ri) = σ 2(1 − hii), where hii is i-th diagonal element of H.
°
ZFS/IMS G¨ottingen 2004
– 23 –
Standardized Residuals in LM’s
ˆ k2
ri
k Y − Xβ
2
si := √
, where s :=
n−p
1 − hiis
are called standardized residuals or internally studentized residuals
hii is called the leverage of observation i.
Problem:
The estimate s2 is biased when outliers are present in the data, therefore one
wants to estimate σ 2 without the ith observation.
°
ZFS/IMS G¨ottingen 2004
– 24 –
Jackknifed Residuals in LM’s
Y −i
=
X−i =
ˆ
β
−i :=
X−iβ + ²−i model without ith obs
design matrix without ith obs
corresponding LSE of β
ˆ
Yˆi,−i := xTi β
−i
ri,−i
s2−i
ti
ith fitted value without using ith obs
:= Yi − Yˆi,−i predictive residual
Pn
Tˆ
2
j=1,j6=j (Yj − xj β −i )
:=
estimate of
n−p−1
σ 2 in model without ith obs
ri
:= √
externally studentized or jackknifed residuals
1 − hiis−i
°
ZFS/IMS G¨ottingen 2004
– 25 –
Jackknifed Residuals in LM’s
For a fast computation one can use linear algebra to show that
ˆ
β
−i
ri,−i
T
−1
(X
X)
xiri
ˆ
= β−
1 − hii
ri
=
1 − hii
2
s2−i
=
(n − p)s −
ri2
1−hii
n−p−1
Residual plots are plots where the observation number i or the jth covariate xij
is plotted against ri, si or ti.
There is no problem with the model if these plots look like a band. Deviations
from this structure might indicate nonlinear regression effects or a violation of
the variance homogeneity.
°
ZFS/IMS G¨ottingen 2004
– 26 –
Residuals in Splus
r_lm(Y~x1+x2+...+xk, x=T)
Raw Residuals:
ri = Yi − Yˆi
e_resid(summary(r))
Residual
r Standard Error:
ˆ
||Y −X β ||2
sigma_summary(r)\$sigma
s=
n−p
External Residual Standard Error:
s−i sigmai_lm.influence(r)\$sigma
Hat Diagonals:
hii
hi_hat(r\$x) or hi_lm.influence(r)\$hat
Internally Studentized Residuals:
ri
si = √1−h
si_e/(sigma*((1-hi)^.5))
s
ii
Externally Studentized Residuals:
ri
ti = √1−h
ti_e/(sigmai*((1-hi)^.5))
s
ii −i
°
ZFS/IMS G¨ottingen 2004
– 27 –
High leverage in LM’s
Since
hii = xi(X T X)−1xTi
one can interpret hii as standardized measure between xi and x.
Further we have
n
X
hii = p,
i=1
therefore we call points with
hii >
2p
n
as high leverage points or x-outliers.
°
ZFS/IMS G¨ottingen 2004
– 28 –
Outlier detection in LM’s
To detect y − outliers, we can use ti, since it can be written as
Yi − Yˆ−i
δˆi
ti = q
=q
for δi := Yi − Yˆ−i.
Vd
ar(Yi − Yˆ−i)
Vd
ar(δi)
In the mean shift outlier model for obs l given by
½
1 l=i
.
Yi = xtiβ + γDli + ²i with Dli =
0 l=
6 i
Therefore reject H : γ = 0 versus K : γ 6= 0 at level α iff |tl| >
tn−p−1,1− α2 , where tm,α is the α quantil of a tm distribution.
Problem:
If one uses this outlier test for every obs. l, one has the problem of multiple
testing, since one needs to substitute α by α
n.
°
ZFS/IMS G¨ottingen 2004
– 29 –
Leverage and Influence
•
2
•
•
•
••
•••
•
•
with obs 20
without obs 20
−5
0
5
•••
•
•
•••• •
•
10
x
−5
•
•
•
•
•
•
•
with obs 10
without obs 10
•
−4
•
•
•
y
−4 −2 0
y
•
•
•••
Figure B
0 2 4 6
Figure A
0
5
10
x
−2 0 2 4
y
Figure C
•
•
•
−5
•
•
•
••
••
•
•
•••
•
•••
with obs 20
without obs 20
0
5
10
x
°
ZFS/IMS G¨ottingen 2004
– 30 –
Leverage and Influence
• Figure A shows that obs 20 is a high leverage point , which is also influential.
• Figure B shows that obs 10 is not a high leverage point and not influential.
• Figure C shows that obs 20 is a high leverage point, which is not influential.
A real valued measure for influential obs. is the Cook’s distance, which is
defined as
ˆ −β
ˆ )T (X T X)(β
ˆ −β
ˆ )
(β
−i
−i
Di :=
,
2
ps
which can be interpreted as the shift in the confidence region when the ith
obs. is deleted. Therefore obs. with
Di > 1
are considered influential. The cutpoint 1 corresponds that the ith obs moves
ˆ to the edge of a 50 % confidence region.
β
°
ZFS/IMS G¨ottingen 2004
– 31 –
Ex:Life expectancies: Residuals and hat values
ex. stud. residuals
-3 -2 -1 0 1 2
Externally Studentized Residuals
• UnitedStates
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
• •
•
•
•
•
•
• •
•
•
•
• •
•
•
•
0
5
10
15
20
Chile
25
30
Index
hat diagonals
0.1 0.2 0.3 0.4 0.5
Hat Diagonals
• PapuaNewGuinea
Australia
•
•
•
•
• •
• •
•
0
5
• • •
•
10
•
•
•
•
15
• Norway
• • • • • • •
• •
20
25
•
•
•
•
•
30
Index
°
ZFS/IMS G¨ottingen 2004
– 32 –
•
•
•
UnitedStates
•
••
••• •
•
•
• • •
•
• •• •
•
•
••
•
•
•
• Chile
-5
•
-4
-3
log(HOSP.POP)
•
•
•
-2
UnitedStates
•
•
•
•
• •
•
20
•
•
40
•
••
• ••
••
•
••
•
••
•
Chile
60
URBAN
• •
•
•
••
•
80
• UnitedStates
•
•
• • •• •
•
•
•
•
•
•
••
•
•
•
• • •
•
• • •
•• •
•
•
•
• Chile
-15
•
•
raw residuals
-15 -5 0 5 10 15
• UnitedStates
•
• •
•• •
••
•• •
•
•
•
•
•
•
•
•
•
•
•
••
•
•
•
•
•
•
• Chile
40
50
60
70
80
TEMP
e
-5 0 5 10 15
raw residuals
-15 -5 0 5 10 15
raw residuals
-15 -5 0 5 10 15
Ex:Life expectancies: Residual plots
0
5
10
15
20
25
raw residuals
30
Bottom right plot plots ri versus ri−1 to detect correlated errors.
°
ZFS/IMS G¨ottingen 2004
– 33 –
Splus function plot() for LM’s
> r_lm(y~x)
> plot(r)
• Plot 1: Yˆi versus ri to check for linearity and variance homogeneity.
p
ˆ
• Plot 2: Yi versus |ri| to check for large residuals.
• Plot 3: Yˆi versus Yi should cluster around x = y line if fit is good.
• Plot 4: qq-plot of ri to check normality of errors
• Plot 5: Residual-Fit (r-f) spread plot: f-values (:= (1:n)−.5
against ordered
n
fitted values (left panel) and ordered residuals (right panel). When a good
fit is present the spread of the residuals should be much smaller than that of
the fitted values.
• Plot 6: i versus Di to check for influential observations.
°
ZFS/IMS G¨ottingen 2004
– 34 –
Ex:Life expectancies: Output from plot()
Residuals
-15 -10 -5 0 5
•
•
•
•
••
•
•
•
•
•
• •
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•3
•22
60
65
70
Fitted : TEMP + URBAN + log(HOSP.POP)
•
•
LIFE.EXP
60
70
•
•
•
•
•
• •
•
•
•
•
•
•
••
•
•
•
•
•
60
65
70
Fitted : TEMP + URBAN + log(HOSP.POP)
•
•
•
•
•
•
•
•
•
•
•
•
•
• •
•
•
•
•
•
60
65
70
Fitted : TEMP + URBAN + log(HOSP.POP)
75
•8
•
• •
• • • •
•••
••••
• • • •
•
•3
• • ••
•
•
••••
•
••
-15 -10 -5
••
•
•
0.2
0.4
••
0.6
°
•
•
5
••••
0.8
-1
0
Quantiles of Standard Normal
1
2
•
••••
•• •
••
• •• •
•••
• •• •
•••
• • ••
•
•
•
1.0
0.0
f-value
22
14
8
0.0
•
••
-2
Residuals
0
•••
•
••••
•
•••
•
75
Cook’s Distance
0.05 0.10 0.15 0.20
•
10 15
Fitted Values
10 15
LIFE.EXP
-15 -10 -5 0 5
•
•
•
•22
55
0.0
•
•
•
•
••••
•
•
55
•
•
•
•3
•
75
•
•
•
50
•
•
•
•
•
•8
Residuals
-15 -10 -5 0 5
55
•22
sqrt(abs(resid(r2)))
1.0 1.5 2.0 2.5 3.0 3.5 4.0
•8
•
10 15
10 15
> plot(r2)
0.2
0.4
0.6
0.8
1.0
0
5
10
15
20
25
30
Index
ZFS/IMS G¨ottingen 2004
– 35 –
```