On Tue, Apr 29, 2008 at 6:20 AM, tom soyer <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to use a weighted lm model to reduce heteroscendasticity. I am > wondering if the only way to generate the weights in R is through the > laborious process of trial and error by hand. Does anyone know if R has a > function that would automatically generate the weights need for lm?
Hi Tom, The 'weights' argument to the 'gls' function in the nlme package provides a great deal of flexibility in estimate weighting parameters and model coefficients. For example, if you want to model monotonic heteroscedasticity by estimating the weights $E(Y)^{-2\alpha}$, you can use the varPower variance function class. E.g., something like f1 <- gls(y ~ x1 + x2, data = your.data, weights = varPower()) will estimate the regression coefficients and alpha parameter together via maximum likelihood. (note that the usual specification for varPower is varPower(form = ~ your.formula), but by default the mean is used. See Ch 5 of the Pinheiro and Bates Mixed-effects Models book for details) Kingsford Jones ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.