This function is not documented (and not available in S-plus).
I do think it is a useful utility (and should be documented).
However, currently
weighted.residuals <- function(obj)
{
w <- weights(obj)
if(is.null(w)) residuals(obj)
else (sqrt(w)*residuals(obj))[w!=0]
}
where I think the "[w!=0]" is really not at all desired.
It makes sum(weighted.residuals(..)^2) slightly faster,
however, weighted.residuals() should return a residual vector of proper
length!
I'm about to drop the above "[w!=0]", document weighted.residuals
and fix deviance.lm(.) according to John Maindonald's bug report
(and use his suggestion to make cooks.distance() work for glm()'s ..).
Any objections ? [please in the next 5 hours or so...]
Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
weighted.residuals() ?
3 messages · Peter Dalgaard, Martin Maechler
Martin Maechler <maechler@stat.math.ethz.ch> writes:
I'm about to drop the above "[w!=0]", document weighted.residuals and fix deviance.lm(.) according to John Maindonald's bug report (and use his suggestion to make cooks.distance() work for glm()'s ..). Any objections ? [please in the next 5 hours or so...]
Be *very* careful! The zero-weight issue has bitten us several times before. Check whether your change would be consistent with what lm/glm does in such cases. (In particular, degrees of freedom calculations can get in trouble).
O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On 12 Aug 1999 16:03, Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> said:
PD> Martin Maechler <maechler@stat.math.ethz.ch> writes:
>> I'm about to drop the above "[w!=0]", document weighted.residuals
>> and fix deviance.lm(.) according to John Maindonald's bug report
>> (and use his suggestion to make cooks.distance() work for glm()'s
>> ..).
>>
>> Any objections ? [please in the next 5 hours or so...]
PD> Be *very* careful! The zero-weight issue has bitten us several
PD> times before. Check whether your change would be consistent with
PD> what lm/glm does in such cases. (In particular, degrees of freedom
PD> calculations can get in trouble).
weighted.residuals() is currently really only used in lm.influence.R;
but the `trouble' is that these {lm diagnostics functions} really all drop
the cases with weight=0.
I'm currently updating documentation {still using fixed deviance.lm() etc}.
weighted.residuals() now has
\title{Computed Weighted Residuals}
\usage{
weighted.residuals(obj, drop0 = TRUE)
}
\arguments{
\item{obj}{\R object, typically of class \code{\link{lm}} or \code{\link{glm}}.}
\item{drop0}{logical. If \code{TRUE}, drop all cases with
\code{\link{weights} == 0}.}
}
--
Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._