Linear model Heteroscedasticity

I have the following linear model:

To address the residuals heteroscedasticity I have tried to apply a log transformation on the dependent variable as $\log(Y + 1)$ but I still see the same fan out effect on the residuals. The DV values are relatively small so the +1 constant addition before taking the log is probably not appropriate in this case.

> summary(Y)
Min.   :-0.0005647
1st Qu.: 0.0001066
Median : 0.0003060
Mean   : 0.0004617
3rd Qu.: 0.0006333
Max.   : 0.0105730
NA's   :30.0000000


How can I transform the variables to improve the prediction error and variance, particularly for the far right fitted values?

What is your goal? We know that heteroskedasticity does not bias our coefficient estimates; it only makes our standard errors incorrect. Hence, if you only care about the fit of the model, then heteroskedasticity doesn't matter.

You can get a more efficient model (i.e., one with smaller standard errors) if you use weighted least squares. In this case, you need to estimate the variance for each observation and weight each observation by the inverse of that observation-specific variance (in the case of the weights argument to lm). This estimation procedure changes your estimates.

Alternatively, to correct the standard errors for heteroskedasticity without changing your estimates, you can use robust standard errors. For an R application, see the package sandwich.

Using the log transformation can be a good approach to correct for heteroskedasticity, but only if all your values are positive and the new model provides a reasonable interpretation relative to the question that you are asking.

• My primary goal is to reduce the errors. I will have to look into weighted least squares but I was under the impression that a DV transformation was the right step, given how regularly the residual variance increases for higher fitted values. – Robert Kubrick Feb 29 '12 at 18:41
• What do you mean "reduce the errors"? The average error is 0. Even looking in your plot, in any window that you choose, the average is 0. – Charlie Feb 29 '12 at 19:28
• I mean improving the prediction of the model, that is reduce the overall absolute error and error variance, particularly for the higher fitted values. – Robert Kubrick Feb 29 '12 at 19:58
• Suppose that you can transform $y$ in such a way that reduces heteroskedasticity. If you want to predict $y$, you'll have to apply the inverse of that transformation, bringing the heteroskedasticity problem back. Transformations are fine if all you care about are coefficients, but aren't going to help you if you're trying to predict $y$. – Charlie Feb 29 '12 at 20:03
• I'm guessing that you don't want to predict transformed $y$, right? Effectively, your transformation would have to shrink the distance between $y$'s on your original scale. You create prediction intervals on the transformed scale that have a similar width across transformed $y$ values, but when you undo the transformation, the prediction intervals get stretched onto the original $y$ scale. – Charlie Feb 29 '12 at 20:20

You would want to try Box-Cox transformation. It is a version of a power transformation:

$$y \mapsto \left\{ \begin{eqnarray} \frac{y^\lambda-1}{\lambda (\dot y)^{\lambda-1}}, & \lambda \neq 0 \\ \dot y \ln y, & \lambda = 0 \end{eqnarray} \right.$$ where $\dot y$ is the geometric mean of the data. When used as a transformation of the response variable, its nominal role is to make the data closer to the normal distribution, and skewness is the leading reason why the data may look non-normal. My gut feeling with your scatterplot is that it needs to be applied to (some of) the explanatory and the response variables.

Some earlier discussions include What other normalizing transformations are commonly used beyond the common ones like square root, log, etc.? and How should I transform non-negative data including zeros?. You can find R code following How to search for a statistical procedure in R?

Econometricians stopped bothering about heteroskedasticity after seminal work of Halbert White (1980) on setting up inferential procedures robust to heteroskedasticity (which in fact just retold the earlier story by a statistician F. Eicker (1967)). See Wikipedia page that I just rewrote.

• Thanks, at this point I'm debating whether to apply a power transform or use robust regression to reduce the errors and improve the prediction intervals. I wonder how the two techniques compare. Also if I use the transformation I would need to back-transform the predicted values. It doesn't look like an obvious formula, does it? – Robert Kubrick Feb 29 '12 at 19:03
• If by robust regression, you mean robust standard errors as @StasK describes, that doesn't change the residuals/errors at all. The coefficients are exactly the same as OLS, giving exactly the same residuals. The standard errors of the coefficients change and are usually larger than the OLS SEs. Prediction intervals are improved in that you now are using the correct standard errors for your coefficients (though they are likely larger relative to those from OLS). If your goal is to predict $y$, you really should stick with the linear model and use the techniques that I mention in my answer. – Charlie Feb 29 '12 at 19:31
• @Charlie I mean en.wikipedia.org/wiki/Robust_regression. I am new to this, but I understand robust regression changes the estimation technique, therefore the residuals must be different. – Robert Kubrick Feb 29 '12 at 20:04
• Right, that is a different method and does change your estimates. I think that robust regression is better suited to cases with outliers. Depending upon which version of robust regression you decide to use and your particular data set, you can get wider confidence intervals relative to OLS. – Charlie Feb 29 '12 at 20:25

There is a very simple solution to heteroskedasticity issue associated with dependent variables within time series data. I don't know if this is applicable to your dependent variable. Assuming it is, instead of using nominal Y change it to % change in Y from the current period over the prior period. For instance, let's say your nominal Y is GDP of $14 trillion in the most current period. Instead, compute the change in GDP over the most recent period (let's say 2.5%). A nominal time series always grows and is always heteroskedastic (the variance of the error grows over time because the values grow). A % change series is typically homoskedastic because the dependent variable is pretty much stationary. • The$Y\$ values I am using are time series % changes from the previous period. – Robert Kubrick Feb 29 '12 at 21:03
• This is surprising. Usually, % change variables are not heteroskedastic. I am wondering if the residuals are less heteroskedastic than we think. And, that the underlying issue is one of outliers. I see 4 or 5 observations in the 0.15% range that if removed would make the whole graph less heteroskedastic looking. Also, as others have mentioned heteroskedasticity will not corrupt your regression coefficients, but only your confidence intervals and related standard error. However, looking at your graph it seems that CIs may not be too affected. And, could still be useful. – Sympa Feb 29 '12 at 22:05