Julien
Julien

Reputation: 1712

What is `s` in the output of the `loess` function in R? The coefficient of determination?

The documentation does not detail the ouput of the function

model <- loess(cyl ~ disp, data = mtcars)
model$s
[1] 0.5679605

EDIT : s is the Residual Standard Error apparently

Upvotes: 1

Views: 168

Answers (2)

Mikael Jagan
Mikael Jagan

Reputation: 11336

There is no official documentation for the content of a loess object. If you look at the source code of the help page for function loess, you'll even see:

\value{
  An object of class \code{"loess"}.% otherwise entirely unspecified (!)
}

As others have suggested, the print method contains clues:

> stats:::print.loess
function (x, digits = max(3L, getOption("digits") - 3L), ...) 
{
    if (!is.null(cl <- x$call)) {
        cat("Call:\n")
        dput(cl, control = NULL)
    }
    cat("\nNumber of Observations:", x$n, "\n")
    cat("Equivalent Number of Parameters:", format(round(x$enp, 
        2L)), "\n")
    cat("Residual", if (x$pars$family == "gaussian") 
        "Standard Error:"
    else "Scale Estimate:", format(signif(x$s, digits)), "\n")
    invisible(x)
}
<bytecode: 0x11f8e7390>
<environment: namespace:stats>

So s is either a residual standard error or a residual scale estimate, depending on the value of argument family passed to loess.

P.S.: I was curious, so I did a quick scan of Chapter 8 of the White Book, the original reference for the loess function now in R. It describes the theory and usage in detail, but it doesn't explicitly define all of the components of a loess object as I thought it might. Oh well.

Upvotes: 0

nerdyaswild
nerdyaswild

Reputation: 122

According to the object definition, it's the the residual standard error for the model.

Upvotes: 1

Related Questions