Regression modelling with unequal variance I would like to fit a linear model (lm) where the residuals variance is clearly dependent on the explanatory variable.
The way I know to do this is by using glm with the Gamma family to model the variance, and then put its inverse into the weights in the lm function (example: http://nitro.biosci.arizona.edu/r/chapter31.pdf)
I was wondering: 


*

*Is this the only technique?  

*What other approaches are relevant?

*What R packages/functions relevant to this type of modelling? (other then glm, lm)

 A: Pills against the "megaphone effect" include (among others):


*

*Use log or square root transform  $Y$. This is not exact but sometimes it tames the widening.

*Use weighted least square regression. In this approach, each observation is given its own variance factor. This answer shows how to use WLSR in R (for instance if the variance of the residuals is proportional to the means, you can provide as weights the inverse of the fitted value in the unweighted model).

*Use robust regression. The funciton rlm() in the MASS package of R does M-estimation, which is supposed to be robust to inequality of variances.


July 2017 edit: It seems that generalized least squares, as suggested in the answer of Greg Snow, is one of the best options.
A: The gls function in the nlme package for R can estimate the regression and the relationship with the variance at the same time.  See the weights argument and the 2nd example on the help page.
A: With the gamlss package you can model the error distribution of the response as a linear, a non-linear, or a smooth function of the explanatory variables. This seems to be a quite powerful approach (I learned a lot about all the possibilities that might arise during the model selection process) and everything is nicely explained in several publications (including books) that is referenced at the link above.
