Docsity

Adjusting Models for Heteroscedasticity and Non-linearity, Lecture notes of Remedies

Toggle sidebar
bg1
6 Dealing with Model Assumption Violations
If the regression diagnostics have resulted in the removal of outliers and influential observations, but
the residual and partial residual plots still show that model assumptions are violated, it is necessary
to make further adjustments either to the model (including or excluding predictors), or transforming
the response and/or predictors, and/or weighting the measurements, and if this all does not help
switching to a different model or estimation method entirely.
If the inclusion or exclusion of predictors do not resolve the concerns about the violation of the model
assumptions further approaches can be used.
Depending on the type of violation different remedies can help.
6.1 Transformations
Transformations can help when
1. the homoscedasticity assumption, or
2. the linearity assumption, or
3. normality
is violated.
6.1.1 Heteroscedasticity
If the assumption of constant variance is violated, the least squares estimators are still unbiased, but
the Gauss-Markov theorem does not hold anymore, and standardized scores do not have the assumed
distribution, and therefore test results and confidence intervals are unreliable. Usually the standard
errors of the regression coefficients are too large.
A transformation of the response variable can help to resolve such a problem. Depending on the
type of violation, different transformations are helpful:
Useful transformations:
Relationship between the error Transformation of Y
variance and the mean response
σ2∝E(Y) square root
σ2∝E(Y)2log
σ2∝E(Y)3reciprocal square root (1/p(y))
σ2∝E(Y)4reciprocal
σ2∝E(Y)(1 −E(Y)) if 0 ≤Y≤1, arcsin, (sin−1(p(y))
However, after applying the transformation the interpretation of the regression coefficients is not
straight forward anymore, and the inverse transformation is not necessarily resulting in unbiased
estimates on the original scale.
Confidence intervals and prediction intervals though can be transformed back to the original scale.
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Adjusting Models for Heteroscedasticity and Non-linearity and more Lecture notes Remedies in PDF only on Docsity!

6 Dealing with Model Assumption Violations

If the regression diagnostics have resulted in the removal of outliers and influential observations, but the residual and partial residual plots still show that model assumptions are violated, it is necessary to make further adjustments either to the model (including or excluding predictors), or transforming the response and/or predictors, and/or weighting the measurements, and if this all does not help switching to a different model or estimation method entirely. If the inclusion or exclusion of predictors do not resolve the concerns about the violation of the model assumptions further approaches can be used. Depending on the type of violation different remedies can help.

6.1 Transformations

Transformations can help when

  1. the homoscedasticity assumption, or
  2. the linearity assumption, or
  3. normality

is violated.

6.1.1 Heteroscedasticity

If the assumption of constant variance is violated, the least squares estimators are still unbiased, but the Gauss-Markov theorem does not hold anymore, and standardized scores do not have the assumed distribution, and therefore test results and confidence intervals are unreliable. Usually the standard errors of the regression coefficients are too large. A transformation of the response variable can help to resolve such a problem. Depending on the type of violation, different transformations are helpful: Useful transformations:

Relationship between the error Transformation of Y variance and the mean response σ^2 ∝ E(Y ) square root σ^2 ∝ E(Y )^2 log σ^2 ∝ E(Y )^3 reciprocal square root (1/

(y)) σ^2 ∝ E(Y )^4 reciprocal σ^2 ∝ E(Y )(1 − E(Y )) if 0 ≤ Y ≤ 1, arcsin, (sin−^1 (

(y))

However, after applying the transformation the interpretation of the regression coefficients is not straight forward anymore, and the inverse transformation is not necessarily resulting in unbiased estimates on the original scale. Confidence intervals and prediction intervals though can be transformed back to the original scale.

Example 6.1. The data set consists on 400 randomly sampled elementary schools from the California Department of Education’s API in the 2000. This data file contains a measure of school academic performance (api00) as well as other attributes of the elementary schools, such as, class size, enrollment, poverty, etc. Does enrollment have an effect on academic performance?

The scatterplot indicates the higher the enrollment the lower the academic success. Fitting the model api00 = β 0 + β 1 enrollment + ε

results in the following residual plots

The transformation of the model ensures that the model assumptions are met, and improves the fit of the model to data and hopefully therefore to the population. Tests and confidence intervals become reliable statements which hold the associated error probabilities. But by transforming the response variable we loose the straight forward interpretation of the estimate of βˆ.

6.1.2 Non-linear Relationships

If the scatterplot for response and predictor does indicate a non linear relationship transformations of the response and/or predictor can result in a linear model for fitting the non-linear relationship. The easiest example is to permit for a polynomial relationship, Where the model becomes:

Y = β 0 + β 1 x + β 2 x^2 + · · · + βkxk^ + ε, ε ∼ N (0, σ^2 )

Some other non-linear relationships we can deal with by transforming the response and/or predictor variable(s) are given in the graphs and table below. In general a non-linear regression model should be considered. Some non-linear relationships which can be dealt with by transformations are:

Function Transformations of x and/or y Resulting model y = β 0 xβ^1 y′^ = log(y), x′^ = log(x) y′^ = log(β 0 ) + β 1 x′ y = β 0 eβ^1 x^ y′^ = ln(y) y′^ = ln(β 0 ) + β 1 x y = β 0 + β 1 log(x) x′^ = log(x) y = β 0 + β 1 x′ y =

x β 0 x − β 1

y′^ =

y

, x′^ =

x

y′^ = β 0 − β 1 x′

The transformation have a large influence on the error structure. The assumption is that the error

The residual plot shows that for states with larger per capita income the variation in the per capita expenditure is larger than for states with lower per capita income. This is in violation of the MLRM assumption. Using the log transformation for the per capita expenditure results in the following scatterplot:

Showing a linear relationship.

Fitting log(expend) = β 0 + β 1 (income) + ε

results in the following residual plot:

This residual plot for the transformed model shows a big improvement over the residual plot for the initial model. Tests and confidence intervals based on this model are more reliable than for the first model.

6.1.3 Choosing a Transformation

6.1.4 Box-Cox: transforming the response

Another violation which can be coped with by transforming the data is non-normality of the error. Box and Cox(1964) developed a method for choosing the ”best” transformation from the set of power transformations to correct for this violation. The set of power transformations can be parameterized with the following definition

Definition 6.1. Let λ ∈ R, then

y(λ)^ =

yλ^ − 1 λ y˜λ−^1

, λ 6 = 0

y ln˜ (y), λ = 0

where

y˜ = e

n

∑^ n

i=

ln(yi)

is the geometric mean of the observations.

λ L(λ) -6.07 -5. -5.5 -5. -5.0 -4. -4.5 -4. -4.0 -3. -3.5 -3. -3.0 -3. -2.5 -2. -2.0 -2. -1.5 -3. -1.0 -3. -0.5 -3. 0.0 -4. 0.5 -4. 1.0 -5. 1.5 -5. 2.0 -6.

According to the graph the 95% confidence interval for λ falls between -5.3 and 0.5, with ˆλ ≈ − 2 .1. In particular 1 is not the confidence interval indicating that some transformation should be done to make the residuals more normal, and the residual sum of squares smaller, and therefore result in a better fit of the model. A good choice for λ seems to be -2. The model would be 1 Y 2

= β 0 + β 1 (weight) + β 2 (age) + ε

Comparing the fit of the two models give an adjusted R^2 for the original model of 0.9729, and for the transformed model of 0.9858. The already well fitting model could be improved by the transformation. Plotting the observed versus the fitted blood pressure for the two models illustrates the same fact, the model based on the transformation fits better than the original model.

6.1.5 Transforming a predictor

In some instances the residual plots or the initial scatter plots indicate a non linear relationship between a regressor and the response, which can be linearized by transforming the regressor. Consider the following model (one regressor to illustrate, but also applies to MLRMs)

Y = β 0 + β 1 t(x) + ε, ε ∼ N (0, σ^2 )

Where t is a function t : R 7 → R. Box and Tidwell (1962) proposed an analytic approach to choosing the transformation t. Let

tα(x) =

xα, α 6 = 0 ln(x), α = 0

then for the model given above with t = tα

E(Y ) = β 0 + β 1 tα(x) = f (β 0 , β 1 , tα)

Their iterative approach is based on the Taylor series for f about an initial guess α 0 = 1, see MPV(pg.186). The process:

  1. Start with an initial guess α 0 = 1, and let i = 0.
  2. Until you are convinced to have found a proper value for α, repeat

Find βˆ 1 ,i from fitting the model Y = β 0 ,i + β 1 ,ixαi^ + ε Let w = xαi^ ln(xαi^ ) Find ˆγ from fitting the model Y = β∗ 0 ,i + β∗ 1 ,ixαi^ + γw + ε∗

Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 373.260 6.819 54.739 < 2e-16 *** poly(income, 5)1 507.011 48.217 10.515 1.39e-13 *** poly(income, 5)2 173.291 48.217 3.594 0.000818 *** poly(income, 5)3 100.842 48.217 2.091 0.042294 * poly(income, 5)4 108.461 48.217 2.249 0.029537 * poly(income, 5)5 163.584 48.217 3.393 0.001474 **


Signif. codes: 0 *** 0.001 ** 0.01 * 0.05. 0.1 1

Residual standard error: 48.22 on 44 degrees of freedom Multiple R-squared: 0.7665,Adjusted R-squared: 0. F-statistic: 28.89 on 5 and 44 DF, p-value: 7.308e-

6.2 Generalized and Weighted Least-Squares

In order to deal with a violation of the homoscedasticity assumption is to generalize model, by permitting, a less restrictive form for the covariance matrix of the error. The General Multiple Linear Regression Model (GMLRM) is given by

~Y = X β~ + ε, ε ∼ N (~ 0 , σ^2 V )

For this model the (ordinary) least squares estimator βˆ is no longer appropriate. It is still unbiased, but not any longer providing the estimate with smallest variance. The matrix V

  1. V is non singular and positive definite. (A matrix A is called positive definite, iff ~x ′A~x > 0, for all ~x ∈ Rn^ \ {~ 0 }). V has to be positive definite since σ^2 ~x ′A~x = V ar(~x ′~ε) > 0 if x ∈ Rn^ \ {~ 0 }. Positive matrices are not singular.
  2. V = KK, for some symmetric matrix K ∈ Rn×n. (This matrix exists because V is positive definite, K is called the square root of V .)
  3. It is usually assumed that V is known, but σ^2 is not. Therefore V gives the structure of variances and covariances in the sample.

In order to be able to apply the finding on least squares estimator from earlier. The matrix K is used to transform the model in such a way that it fits a MLRM, for which we know the least squares estimator etc..

Theorem 6.1. Let Z~ = K−^1 Y ,~ B = K−^1 X, ~g = K−^1 ~ε

Then the by K−^1 transformed model is

Z^ ~ = B β~ + ~g

is a MLRM with ~g ∼ N (~ 0 , σ^2 In)

Proof: Since ~g = K−^1 ~ε it is a linear combination of normally distributed random variables and therefore normal, with E(~g) = E(K−^1 ~ε) = K−^1 E(~ε) = K−^1 ~0 = ~ 0

and Cov(~g) = Cov(K−^1 ~ε) = K−^1 Cov(~ε)K−^1 = K−^1 σ^2 V K−^1 = σ^2 K−^1 KKK−^1 = σ^2 In q.e.d. The least squares estimate for β~ derived from this model must then be the least squares estimate of the GMLRM. The normal equation for the transformed model is

B′B βˆ = B′^ Z~ ⇔ X′K−^1 K−^1 X βˆ = X′K−^1 K−^1 ~Y ⇔ X′V −^1 X βˆ = X′V −^1 Y~

with solution βˆ = (X′V −^1 X)−^1 X′V −^1 Y~

β^ ˆ is called the generalized least squares estimator of ~β.

Lemma 1. The generalized least squares estimator of ~β, βˆ, is unbiased and has covariance matrix Cov( βˆ) = σ^2 (X′V −^1 X)−^1.

The residual sum of squares for the GMLRM is

SSRes = Z~′^ Z~ − βˆ′B Z~ = ~Y ′V −^1 Y~ − Y~ ′V −^1 X(X′V −^1 X)−^1 X′V −^1 ~Y

The regression sum of squares

SSR = βˆ′B Z~ −

n

Z~′Jn Z~ = Y~ ′V −^1 X(X′V −^1 X)−^1 X′V −^1 Y~ − 1 n

Y~ ′K−^1 JnK−^1 Y~

The total sum of squares

SST = Z~′^ Z~ −

n

Z~′Jn Z~ = Y~ ′V −^1 Y~ − 1 n

Y~ ′K−^1 JnK−^1 Y~

In general the error covariance matrix is not known, but choosing some structure to it permits the fit of more general models, for example in time series. Here we will focus on Weighted Least Squares Regression, which shall help in the case when the homoscedasticity assumption is violated in the ordinary least squares model.

x = rnorm(100,0,3) y = 3-2x + rnorm(100,0,sapply(x,function(x){1+0.5x^2})) plot(x,y) abline(a=3,b=-2,lty=1) fit.ols = lm(y~x) abline(fit.ols$coefficients,lty=2,col="blue")

The solid line gives the true line, the dashed is the fitted line. And the residual plot clearly shows the violation of homoscedasticity. The squared residuals are indicative of the variance in the error

Use

wght<-1/(1+0.5*x^2) fit.wls = lm(y~x,weight=wght)

The solid line is the correct fit y = 3 − 2 x, the blue dashed line is the fitted line using OLS y =

  1. 60 − 0. 09 x, and the red dotted line is the fitted line using WLS y = 3. 07 − 1. 43 x. What do the confidence intervals say?

confint(fit.ols) # Confidence intervals for OLS 2.5 % 97.5 % (Intercept) 2.358142 6. x -0.775504 0. confint(fit.wls) # Confidence intervals for WLS 2.5 % 97.5 % (Intercept) 2.15419 3. x -1.96547 -0.