[R] rlm results on trellis plot
deepayan.sarkar at gmail.com
deepayan.sarkar at gmail.com
Fri Jun 8 18:24:12 CEST 2007
On 6/7/07, Alan S Barnett <asb at mail.nih.gov> wrote:
> How do I add to a trellis plot the best fit line from a robust fit? I
> can use panel.lm to add a least squares fit, but there is no panel.rlm
> function.
Well, panel.lmline (not panel.lm, BTW) is defined as:
> panel.lmline
function (x, y, ...)
{
if (length(x) > 0)
panel.abline(lm(as.numeric(y) ~ as.numeric(x)), ...)
}
So it's not much of a stretch to define
panel.rlmline <- function(x, y, ...)
if (require(MASS) && length(x) > 0)
panel.abline(rlm(as.numeric(y) ~ as.numeric(x)), ...)
The other replies have already shown you how you might use this in a call.
-Deepayan
More information about the R-help
mailing list