sfsmisc (version 1.1-8)

loessDemo: Graphical Interactive Demo of loess()

Description

A graphical and interactive demonstration and visualization of how loess works. By clicking on the graphic, the user determines the current estimation window which is visualized together with the weights.

Usage

loessDemo(x, y, span = 1/2, degree = 1, family = c("gaussian", "symmetric"),
          nearest = FALSE, nout = 501,
          xlim = numeric(0), ylim = numeric(0), strictlim = TRUE, verbose = TRUE,
          inch.sym = 0.25, pch = 4, shade = TRUE, w.symbols = TRUE,
          sym.col = "blue", w.col = "light blue", line.col = "steelblue")

Arguments

x,y

numeric vectors of the same length; the demo is about loess(y ~ x).

span

the smoothing parameter \(\alpha\).

degree

the degree of the polynomials to be used; must be in \({0,1,2}\).

family

if "gaussian" fitting is by least-squares, and if "symmetric" a re-descending M estimator is used with Tukey's biweight function. Can be abbreviated.

nearest

logical indicating how \(x_0\) should be determined, the value at which \(\hat{f}(x_0)\) is computed. If nearest is true, the closest data value is taken.

nout

the number of points at which to evaluate, i.e, determining \(u_i\), \(i = 1,2, \dots, \mathtt{nout}\), at which \(\hat{f}(u_i)\) is computed.

xlim

x-range; to extend or determine (iff strictlim is true) the \(x\)-range for plotting.

ylim

y-range; to extend or determine (iff strictlim is true) the \(y\)-range for plotting.

strictlim

logical determining if xlim and ylim should be strict limits (as e.g., in plot.default), or just a suggestion to extend the data-dependent ranges.

verbose

logical ......

inch.sym

symbol size in inches of the maximal weight circle symbol.

pch

plotting character, see points.

shade

logical; if true, polygon(.., density=..) will be used to shade off the regions where the weights are zero.

w.symbols

logical indicating if the non-zero weights should be visualized by circles with radius proportional to inch.sym and \(\sqrt{w}\) where \(w\) are the weights.

sym.col, w.col, line.col

colors for the symbols, weights and lines, respectively.

See Also

loess.

Examples

Run this code
# NOT RUN {
if(dev.interactive()) {

 if(requireNamespace("lattice")) {
    data("ethanol", package = "lattice")
    attach(ethanol)
    loessDemo(E,NOx, span=.25)
    loessDemo(E,NOx, span=.25, family = "symmetric")

    loessDemo(E,NOx, degree=0)# Tricube Kernel estimate
  }
# }
# NOT RUN {
<!-- % if (. lattice .) -->
# }
# NOT RUN {
 ## Artificial Example with one outlier
 n2 <- 50; x <- 1:(1+2*n2)
 fx <- (x/10 - 5)^2
 y <- fx + 4*rnorm(x)
 y[n2+1] <- 1e4
 loessDemo(x,y, span=1/3, ylim= c(0,1000))# not robust !!
 loessDemo(x,y, span=1/3, family = "symm")
 loessDemo(x,y, span=1/3, family = "symm", w.symb = FALSE, ylim = c(0,40))
 loessDemo(x,y, span=1/3, family = "symm", ylim = c(0,40))
 ## but see warnings() --- there's a "fixup"

}
# }
# NOT RUN {
<!-- % only if  interactive -->
# }

Run the code above in your browser using DataCamp Workspace