Hello,
Turns out that you can obtain the desired residuals
from a weighted regression using residual(), specifying
type='Pearson". For example, resid(wls.fit, type='Pearson').
From the lm.object help file:
residuals the residuals from the fit. If weights were used, then the
residuals are the raw residuals - the weights are not taken into account.
If you need residuals that all have the same variance, then use the
residuals function with type="pearson".
Sincerely,
Joel Dubin.
On Sun, 24 Jan 1999, Joel Dubin wrote:
> Date: Sun, 24 Jan 1999 13:05:40 -0800 (PST)
> From: Joel Dubin <dubin@wald.ucdavis.edu>
> To: s-news@wubios.wustl.edu
> Subject: [S] inconsistency with weighted regression
>
>
>
>
> Hello,
>
> I have found some inconsistent behavior of function
> calls on lm objects when weights are specified in lm().
> To begin, in matrix notation, the unweighted regression
> equation is y = X * \beta + \epsilon . In weighted regression,
> we simply premultiply each side of the equation by W^(1/2),
> where W is a diagonal matrix of the weights for each
> observation. This results in: y_w = X_w * \beta + \epsilon_w,
> where y_w = W^(1/2) * y, x_w = W^(1/2) * X,
> and \epsilon_w = W^(1/2) * \epsilon.
>
> Say we run a weighted least squares regression
> with the following code: wls.fit _ lm(formula = y ~ x, weights = wgts),
> where y is of length n, and wgts is a vector of weights of length n.
>
> The inconsistency is this:
>
> summary(wls.fit) outputs some quantile information
> on the residuals, where the residuals are defined as:
> y_w - (sqrt(wgts) * fitted(wls.fit)). In addition, the square root
> of the MSE and the standard errors of the coefficient
> estimates are consistent with this definition of the residuals.
>
> However, residuals(wls.fit) outputs
> the residuals as: y - fitted(wls.fit). That is,
> the function residuals.lm() does not adjust the
> residual values with the provided weights.
>
> Why are the two functions coded to output
> different residuals values from the same weighted regression?
> Shouldn't this be considered a bug?
>
>
> Sincerely,
>
> Joel Dubin
> Graduate Student
> Division of Statistics
> University of California - Davis
>
> -----------------------------------------------------------------------
> This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
> send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
> message: unsubscribe s-news
>
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|