Model Building III – Remedial Measures

19
Model Building III – Remedial Measures KNNL – Chapter 11

description

Model Building III – Remedial Measures. KNNL – Chapter 11. Unequal (Independent) Error Variances – Weighted Least Squares (WLS). Case 1 – Error Variances known exactly (VERY rare) Case 2 – Error Variances known up to a constant - PowerPoint PPT Presentation

Transcript of Model Building III – Remedial Measures

Page 1: Model Building III – Remedial Measures

Model Building III – Remedial Measures

KNNL – Chapter 11

Page 2: Model Building III – Remedial Measures

Unequal (Independent) Error Variances – Weighted Least Squares (WLS)

• Case 1 – Error Variances known exactly (VERY rare)• Case 2 – Error Variances known up to a constant– Occasionally information known regarding experimental units

regarding the relative magnitude (unusual)– If “observations” are means of different numbers of units (each

with equal variance) at the various X levels, Variance of observation i is 2/ni where ni is known

• Case 3 – Variance (or Standard Deviation) is related to one or more predictors, and relation can be modeled (see Breusch-Pagan Test in Chapter 3)

• Case 4 – Ordinary Least Squares with correct variances

Page 3: Model Building III – Remedial Measures

WLS – Case 1 Known Variances - I

20 1 1 1 , 1

21

22

2

2

0 1 1 1 , 1221

... ~ 0, 1,..., , 0

0 0

0 0

0 0

Maximum Likelihood Estimation:

1 1exp ... setting:

22

i i p i p i i i i j

n

n

i i p i p ii ii

Y X X N i n i j

L Y X X w

2σ ε

β

2

2

0 1 1 1 , 111

2

0 1 1 1 , 11

2

1

1exp ...

2 2

To maximize , we need to minimize ...

Note that values with smaller have larger weights

i

n ni

i i i p i pii

n

w i i i p i pi

i i

wL w Y X X

L Q w Y X X

w

β

β

in the weighted least squares criterion.

Page 4: Model Building III – Remedial Measures

WLS – Case 1 Known Variances - II

1

2

0 0

0 0Easiest to set up in matrix form, where: '

0 0

Normal Equations:

n

w

w

w

w

w

2 2 -1

-1 -1

-1

w

-12 2 -w

W =W

σ Y = σ ε = W

X'WX b X'WY

b X'WX X'WY AY A X'WX X'W

E b = AE Y = AXβ = X'WX X'WXβ = β

σ b = Aσ Y A' = X'WX X'WW

-1 -11WX X'WX X'WX

Page 5: Model Building III – Remedial Measures

WLS – Case 2 – Variance Known up to Constant - I

11

122 2 2 2

1

1 1

2 2* *2 2 2 2

0 0

0 0 number of replicates at level of

0 0

0 0 0 0

0 0 0 01 1 1

0 0 0 0

1

thi i i

i

n

ii

i

n n

r

rY r i X

r

r

r r

r rnw

r r

2σ Y

W W W

X'WX X'

22 2

* *2 2

2^*

2 1

1

1 1w

n

ii ii

w w w w

w Y YMSE MSE

n p

-1-1* * *

-1-1* *

-1 -1-12 * 2 *

W X X'W X X'WX X'W X

X'WY X' W Y X'W Y b X'WX X'WY X'W X X'W Y

σ b X'WX X'W X s b X'W X

Data are means of unequal numbers of replicates at X-levels, can use any weights generally

Page 6: Model Building III – Remedial Measures

WLS – Case 2 – Variance Known up to Constant - IIJapanese study of Rosuvastin for patients with high cholesterol. n = 6 doses, # of patients per dose (ri) varied: (15, 17, 12, 14, 18, 13)After preliminary plots, determined that Y = change in LDL, X = ln(Dose)

DoseGrp ChgLDL Dose ln(Dose) r1 -35.8 1 0.0000 152 -45.0 2.5 0.9163 173 -52.7 5 1.6094 124 -49.7 10 2.3026 145 -58.2 20 2.9957 186 -66.0 40 3.6889 13

X Y W*1 0.0000 -35.8 15 0 0 0 0 01 0.9163 -45.0 0 17 0 0 0 01 1.6094 -52.7 0 0 12 0 0 01 2.3026 -49.7 0 0 0 14 0 01 2.9957 -58.2 0 0 0 0 18 01 3.6889 -66.0 0 0 0 0 0 13

X'W*X X'W*Y Y Yhat_W e_w w*(e_w)^289 169.005 -4535.8 -35.8 -36.96 1.2 20.14

169.005 458.0243 -9624.3 -45.0 -43.72 -1.3 27.99-52.7 -48.83 -3.9 179.82

INV(X'W*X) b_w -49.7 -53.94 4.2 251.820.037538 -0.01385 -36.96 -58.2 -59.05 0.9 13.11-0.01385 0.007294 -7.38 -66.0 -64.17 -1.8 43.75

s2{b_w} s{b_w} sum(w*e^2) 536.635.04 -1.86 2.24 n-p 4-1.86 0.98 0.99 MSE_W 134.16

Page 7: Model Building III – Remedial Measures

WLS - Case 3 – Estimated Variances• Use squared residuals (estimated variances) or absolute

residuals (estimated standard deviations) from OLS to model their levels as functions of predictor variables– Plot Residuals, squared residuals and absolute residuals versus

fitted values and predictors– Using model building techniques used on Y previously to obtain

a model for either the variances or standard deviations as functions of the Xs or the mean

– Fit estimated WLS with the estimated weights (1/variances)– Iterate until regression coefficients are stable (iteratively re-

weighted least squares)

^ ^

^ ^

^

^

^ 2^

'1 1 w wi

w wi i

w MSEn pv s

-1^ ^ Y -Xb W Y -Xbb X'WX X'WY

Page 8: Model Building III – Remedial Measures

Case 4 – OLS with Estimated Variances

21

22

2

21

22 2 2 2 2

2

0 0

0 0

0 0

0 0

0 0Note: Use as an estimator of :

0 0

n

i i i i

n

e

eE e

e

2 2

-1 -1

-1 -12 2 2

0

-12

E Y = Xβ σ Y = σ ε

b = X'X X'Y = AY A = X'X X'

σ b = Aσ Y A' = X'X X'σ ε X X'X

S

s b X'X X

-10'S X X'X

This is referred to White’s estimator, and is robust to specification of form of error variance

Page 9: Model Building III – Remedial Measures

Multicollinearity – Remedial Measures - I• Goal: Prediction – Multicollinearity not an issue if new

cases have similar multicollinearity among predictors– Firm uses shipment size (number of pallets) and weight (tons)

to predict unloading times. Future shipments have similar correlation between predictors, predictions and PIs are valid

• Linear Combinations of Predictors can be generated that are uncorrelated (Principal Components)– Good: Multicollinearity gone– Bad: New variables may not have “physical” interpretation

• Use of Cross-Section and Time Series in Economics– Model: Demand = f(Income , Price)– Step 1: Cross-section (1 time): Regress Demand on Income (bI)

– Step 2: Time Series: Regress Residuals from 1 on Price (bP)

Page 10: Model Building III – Remedial Measures

Multicollinearity – Ridge Regression -I• Mean Square Error of an Estimator = Variance + Bias2

• Goal: Add Bias to estimator to reduce MSE(Estimator)• Makes use of Standard Regression Model with

Correlation Transformation

22 2 2

* * * * * * * *1 1 1 , 1

Variance + (Bias)

Correlation Transformation / Standardized Regression Model:

...1 1

Ridge Regression Estimator (

R R R R

ki iki ik i i p i p i XX YX

Y k

MSE b E b b E b

Y Y X XY X Y X X

n s n s

r b r

1

1

with 0):

R

R RXX YX XX YX

Rp

b

c c c

b

-1r I b r b r I r

Goal: choose small c such that the estimators stabilize (flatten) and VIFs get small

Page 11: Model Building III – Remedial Measures

Multicollinearity – Ridge Regression - II

1 1

^ ^* * * * *

1 1 1 , 1

Computational Formulas:

Variance Inflation Factors:

Diagonal Elements of the matrix:

Error Sum of Squares (Correlation Transformed Data):

...

XX XX XX

R Ri i p i p R i i

c c

Y b X b X SSE Y Y

r I r r I

2

1

2 1 since 1

n

i

R R RR SSE SSTO

Page 12: Model Building III – Remedial Measures

Robust Regression for Influential Cases

• Influential cases, after having been ruled out as recording errors or indicative of new predictors, can be reduced in terms of their impacts on the regression model

• Two commonly applied Robust Regression Models:– Least Absolute Residuals (LAR) Regression – Choose the

coefficients that minimize sum of absolute deviations (as opposed to squared deviations in OLS). No closed form solutions, must use specialized programs (can be run in R)

– IRLS Robust Regression – Uses Iteratively Re-weighted Least Squares where weights are based on how much each case is an outlier (lower weights for larger outliers)

Page 13: Model Building III – Remedial Measures

IRLS – Robust Regression1. Choose weight function (we will use Huber here)

2. Obtain starting weights for each case.

3. Use starting weights in Weighted Least Squares and obtain residuals after fitting equation

4. Use Residuals from step 3 to generate new weights.

5. Continue iterations to convergence (small changes in estimated regression coefficients or residuals or fitted values)

Applying Procedure for Huber wight function (1.345 is tuning parameter to achieve high efficiency to normal model)

1 1.345

1. Huber weight function: 1.3451.345

2. Use initial residuals from OLS fit after scaling by Median Absolute Dev

u

wu

u

22

iation (Robust estimate of ):

1median median

0.67453. Iterate to Convergence

1 4.685Note: Bisquare weight Function: 4.685

0 4.685

ii i i

eMAD e e u

MAD

uu

w

u

Page 14: Model Building III – Remedial Measures

Nonparametric Regression• Locally Weighted Regressions (Lowess)– Works best with few predictors, and when data have been

transformed to normality with constant error variances, and predictors have been scaled by their standard deviation (sqrt(MSE) or MAD when outliers are present)

– Applies WLS with weights as distances from the individual points in a neighborhood to the target (q = proportion of data used in the neighborhood, typically 0.40 to 0.60)

• Regression Trees– X-space is broken down into multiple sub-spaces (1-step at a

time), and each region is modeled by the mean response– Each step is chosen to minimize the within region sum of

squares

Page 15: Model Building III – Remedial Measures

Lowess Method• Assumes model has been selected and built so assumptions of

errors being approximately normal with constant variance holds.• Predictors of different units should be scaled by SD or MAD in

distance measure

2 2

1 1 2 2

1 2

3

Assuming -1=2 predictor variables and

proportion of sample used at each point:

Distance Measure (Each point from target point):

1Weight Function:

i h i hi

i qi

p

q

X X X Xd

s s

d dw

3

0

size of neighborhood so of sample is included

Local Fitting: Fit first-order or second-order model by WLS

and get fitted value at each target point

i q

i q

q

d d

d d

d q

Page 16: Model Building III – Remedial Measures

Regression Trees

• Splits region covered by the predictor variables into increasing number of sub-regions, where predicted value is mean response of all cases falling in the sub-region.

• Goal: Choose “cut-points” that minimize Error Sum of Squares for the current number of sub-regions – computationally intensive, no closed form solution

• Problem: SSE will continually drop until there are as many sub-regions as distinct combinations of predictors (SSE → 0)

• Validation samples can be used to determine which number of nodes (sub-regions – 1) that minimizes Mean Square Prediction Error (MSPR)

Page 17: Model Building III – Remedial Measures

Bootstrapping to Estimate Precision

• Computationally intensive methods used to estimate precision of estimators in non-standard situations

• Based on re-sampling (with replacement) from observed samples, re-computing estimates repeatedly (nonparametric). Parametric methods also exist (not covered here)

• Once original sample is observed, and quantity of interest estimated, many samples of size n (selected with replacement) are obtained, each sample providing a new estimate.

• The standard deviation of the new sample quantities represents an estimate of the standard error

Page 18: Model Building III – Remedial Measures

Two Basic Approaches

• Fixed X Sampling (Model is good fit, constant variance, predictor variables are fixed, i.e. controlled experiment)– Fit the regression, obtain all fitted values and residuals– Keeping the corresponding X-level(s) and fitted values, re-

sample the n residuals (with replacement)– Add the bootstrapped residuals to the fitted values, and re-fit

the regression (repeat process many times)

• Random X Sampling (Not sure of adequacy of model: fit, variance, random predictor variables)– After fitting regression, and estimating quantities of interest,

sample n cases (with replacement) and re-estimate quantities of interest with “new” datasets (repeat many times)

Page 19: Model Building III – Remedial Measures

Bootstrap Confidence Intervals – Reflection Method

1

11 2

1

Suppose we are interested in Estimating in simple regression (generalizes to other parameters):

1) Fit regression on original dataset, obtain

2) Obtain bootstrap samples

n

i ii

n

ii

X X Y Yb

X X

m

*1

* * *1 1 1

* *1 1 1 2 1

and their estimated slopes: 1,...,

3) Order the from smallest to largest, and obtain / 2 and 1 / 2

(the lower and upper percentiles of the distribution)

4) Compute / 2

j

j

b j m

b b b

d b b d b

1

1 1 2 1 1 1

1 / 2

5) Approximate 1- 100% CI for :

b

b d b d