[R] residuals from lowess fit

S.McClatchie s.mcclatchie at niwa.cri.nz
Tue Mar 13 00:23:04 CET 2001


Colleagues

----------------------------------
System info:
R version rw1022 on NT
ESS v. 5.1.18 using emacs ver. 20.4

----------------------------------
I would like to access the residuals from a lowess fit (function lowess() ) 
as an aid to assessing whether I am over-smoothing or under-smoothing 
a dataset (as in Cleveland's book "Visualizing data", section 3.3)

Unless I misunderstand, the lowess function only returns the independent 
variable and the smoothed dependent variable, without residuals. 

e.g. 
> z <- lowess(....)
> names(z)
[1] "x" "y"

I think from a look at the lowess() function that the coding where 
residuals are calculated is in C?

> lowess
function (x, y = NULL, f = 2/3, iter = 3, delta = 0.01 * 
diff(range(xy$x[o]))) 
{
    xy <- xy.coords(x, y)
    if (length(xy$x) != length(xy$y)) 
        stop("x and y lengths differ")
    n <- length(xy$x)
    o <- order(xy$x)
    .C("lowess", x = as.double(xy$x[o]), as.double(xy$y[o]), 
        n, as.double(f), as.integer(iter), as.double(delta), 
        y = double(n), double(n), double(n), PACKAGE = "base")[c("x", 
        "y")]
}

Is there any way for me to get the residuals out?

Help will be appreciated.
Thanks

Sam

Sam McClatchie, Research scientist (fisheries acoustics))))))))))
NIWA (National Institute of Water & Atmospheric Research Ltd)
PO Box 14 901, Kilbirnie, Wellington, New Zealand
s.mcclatchie at niwa.cri.nz 

                    /\
...>><xX(°> // \\
                 /// \\\   
                //// \\\\
               ///  <°)Xx><<
              /////  \\\\\\
        ><(((°>   
  >><(((°>   ...>><xX(°>O<°)Xx><<

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list