loess.boot {simpleboot}R Documentation

2-D Loess bootstrap.

Description

Bootstrapping of loess fits produced by the loess function in the modreg package. Bootstrapping can be done by resampling rows from the original data frame or resampling residuals from the original model fit.

Usage

loess.boot(lo.object, R, rows = TRUE, new.xpts = NULL, ngrid = 100,
           weights = NULL)

Arguments

lo.object

A loess fit, produced by loess.

R

The number of bootstrap replicates.

rows

Should we resample rows? Setting rows to FALSE indicates resampling of residuals.

new.xpts

Locations where new predictions are to be made. If new.xpts is NULL, then an evenly spaced grid spanning the range of X (containing ngrid points) is used. In either case

ngrid

Number of grid points to use if new.xpts is NULL.

weights

Resampling weights; a vector with length equal to the number of observations.

Details

The user can specify locations for new predictions through new.xpts or an evenly spaced grid will be used. In either case, fitted values at each new location will be stored from each bootstrap sample. These fitted values can be retrieved using either the fitted method or the samples function.

Note that the loess function has many parameters for the user to set that can be difficult to reproduce in the bootstrap setting. Right now, the user can only specify the span argument to loess in the original fit.

Value

An object of class "loess.simpleboot" (which is a list) containing the elements:

method

Which method of bootstrapping was used (rows or residuals).

boot.list

A list containing values from each of the bootstrap samples. Currently, only residual sum of squares and fitted values are stored.

orig.loess

The original loess fit.

new.xpts

The locations where predictions were made (specified in the original call to loess.boot).

Author(s)

Roger D. Peng

Examples

set.seed(1234)

x <- runif(100)

## Simple sine function simulation
y <- sin(2*pi*x) + .2 * rnorm(100)
plot(x, y)  ## Sine function with noise
lo <- loess(y ~ x, span = .4)

## Bootstrap with resampling of rows
lo.b <- loess.boot(lo, R = 500)

## Plot original fit with +/- 2 std. errors
plot(lo.b)

## Plot all loess bootstrap fits
plot(lo.b, all.lines = TRUE)

## Bootstrap with resampling residuals
lo.b2 <- loess.boot(lo, R = 500, rows = FALSE)
plot(lo.b2)


[Package simpleboot version 1.1-8 Index]