Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Summary
Chapter 2:
Set up model:
Inferences about model parameters & regression line
Dummy (categorical) variable regression
Chapter 3:
Check the model assumptions: Linear, Independent,
Normal, Errors have constant variance:
Residual plots
Leverage & Influence
Transformations
+ 4
Usual Assumptions
Four assumptions:
Valid Model
Isthe mean structure correct?
For valid models, E[Y | X = x] = 0 + 1x
Using Residuals
Plot residuals:
No pattern => model could be valid
Pattern => residual plot gives information on what to
do
Leverage Points
Leverage Points
A leverage point is a point whose x-value is far from the
other x-values in the data set.
Leverage
+ 14
Leverage Rule
Leverage of ith point = hii
A popular rule is to classify the ith point as a
leverage point in a multiple linear regression
model with p predictors (and one intercept, so
that the design matrix has p+1 columns) if:
Treasury Bonds
110
Bid Price
95 100
4
13 35
90
4 6 8 10 12
Coupon Rate
+ 17
Cases 4, 5, 13, and 35 all have leverage values greater than 0.11.
> hatvalues(my.lm)
1 2 3 4 5 6 7
0.04850372 0.02860476 0.04850372 0.15277805 0.12397083 0.03315530 0.02873009
8 9 10 11 12 13 14
0.10262572 0.03037870 0.03639225 0.06803392 0.02904583 0.21787629 0.04202499
15 16 17 18 19 20 21
0.05784582 0.03018347 0.03997869 0.05784582 0.10262572 0.02858307 0.04202499
22 23 24 25 26 27 28
0.02904583 0.03037870 0.06446917 0.02858307 0.04148268 0.04365431 0.02904583
29 30 31 32 33 34 35
0.02953029 0.02858307 0.03199597 0.02860476 0.02915429 0.04850372 0.18725657
+ 18
Leverage Properties
Standardized Residuals
+ 21
Standardized Residuals
Rule
3
Standardized Residuals
-1 0 -2 1 2
4 6 8 10 12
Coupon Rate
+ 24
2 4 6 8 10 12 14
Coupon Rate
+ 26
28
+
Assessing Influence
Cooks D:
The notation j(i) means the value of y-hat with the ith
observation deleted.
When is Di large?
29
+
Assessing Influence
115
Bid Price
105
Remove
point #13
85 90 95
and
compare
2 4 6 8 10 12 14
Coupon Rate 30
+
Assessing Influence
Remove point
#1:
115
Bid Price
85 90 95 105
2 4 6 8 10 12 14
Coupon Rate
+
Cooks D: Bond data
1.0
0.8
Cook's Distance
0.6
0.4
0.2
0.0
4/33 = 4 6 8 10 12
0.12 Coupon Rate 32
+
Cooks D: Bond data (default plot)
Residuals vs Leverage
3 13
1
35
Standardized residuals
2
4 0.5
1
0
-1
0.5
-2
Cook's distance
1
To check:
34
+
Q-Q Plot: Bonds Data (default)
Normal Q-Q
3 13
35
Standardized residuals
2
1
0
-1
-2
34
-2 -1 0 1 2
Theoretical Quantiles 35
lm(bonds$BidPrice ~ bonds$CouponRate)
+
Transformations
+
Constant Variance
Necessary for inference
37
+
Constant variance: Plots
|Residuals|0.5 against x
or
38
+
Constant Variance: Example
Developing a bid on contract cleaning
Goal: Bid on a contract to clean offices.
Costs
proportional to # cleaning crews
needed.
53days of records: # crews & # rooms
cleaned
39
+
Constant Variance: Example
70 50
Rooms
30 10
2 4 6 8 10 12 14 16
Crews 40
+
Constant Variance: Example
(default) Scale-Location
46
1.5
31 5
Standardized residuals
0.5 1.0
0.0
10 20 30 40 50 60
Fitted values
lm(clean$Rooms ~ clean$Crews)
41
+
Transformations
42
+
Transformations
43
+
Transformations: Count Data
44
+
Transformations: Count Data
46
+
Using Logarithms to Estimate
Percentage Effects
47
+ 48
6000
4000
Sales
2000 0
8
log(Sales)
6 57
55
+
Transforming Y
56
+ 57
Transforming Y
+
Transforming Y: Inverse
Response Plots
Recall that:
58
+ 59
63
+
Transforming Y: Box-Cox
64
+
Transforming Y: Box-Cox
Box and Cox multiply the function S(x, ) by a factor to get
M(x, ), the goal being to keep all units the same for all
values of . The method is based on the maximum
likelihood estimates for Y. Maximizing the likelihood with
respect to is equivalent to minimizing RSS() with respect
to .
65
+
Transformations: Caution
66
+
Transforming X
Try scaled power transformations, as for Y.
67
+
Transforming both the response
and the predictor variables
Approach 1:
1. Transform X to (x, ) so that the distribution of the
transformed version of X is as normal as possible.
Univariate Box-Cox is one way to do this.
2. Consider a simple linear regression model of the form
Y = g(0 + 1 (x, ) + e). Use an inverse response
plot to decide on the transformation g -1 for Y.
Approach 2:
Transform X and Y simultaneously to joint normality
using multivariate Box-Cox.
Transformations: Confidence
and Prediction Intervals
Suppose we are interested in the middle 95% of a
distribution (as in a confidence or prediction interval).
Transformations: Confidence
and Prediction Intervals
If the relationship between Y and some transformation
g(Y) were linear, then it would be true that E[g(Y)] =
g(E[Y]). But if the relationship between X and g(Y) were
linear, and the relationship between g(Y) and Y were
linear, then the relationship between X and Y would be
linear.
Review
+ 73
Transformations: Confidence
and Prediction Intervals
We sometimes want to be able to find confidence intervals and
prediction intervals for the least squares regression line in
models with transformed X and Y.
Example: Inverse
Transformation
Suppose we take W = g(Y) = 1/Y, which is normally
distributed. Then the inverse transformation is also g-
1(W) = 1/W. If W is normally distributed, finding the
Back Transformation
Adjustments
Logarithmic
Square Root
Inverse
Inverse
Square Root
+ 79
Back Transformation
Adjustments
What if we want to use some other transformation?
Bootstrap.
Bootstrap.
+
R2 Rant
+
High R2 does not imply valid model
81
+
R2: Outliers
R2 is not robust to outliers.
r= r=
0.75 0.80
82
+
R2: Stratification
R2 takes different values when different values of X are
observed.
r= r=
0.75 0.81
83
+
R2: Stratification
R2 takes different values when different values of X are
observed.
r= r=
0.75 0.72
84
+
R2: Regression through the origin
R2 is not invariant under location changes like Fahrenheit to
Celsius when we fit a line through the origin (no intercept).
Uncorrected SS
85
+
R2: Transformations
R2 is not invariant under transformations
Example 1:
(0, 0.5), (1, 4), (2, 6), (3, 7), (16, 12), (20, 22)
Example 2:
(0, 0.1), (3, 0.4), (8, 2), (13, 10), (16, 15), (20, 16)
log(Y)
y
x x 87
88