loessOp: Loess operator matrix calculation

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Calculates the hat matrix, L, used to obtain fitted values for given loess smoothing parameters, for an equally-spaced design 1, ..., n. Also allows extrapolation beyond the design points.

Usage

1
2
3
4
5
6
loessOp(n, span, degree = 1, blend = 0, at = 1:n, 
   stats = TRUE)
## Default S3 method:
loessOp(n, span, degree=1, blend=0, at=1:n, stats=TRUE)
## S3 method for class 'loess'
loessOp(x, at=1:x$n, stats=TRUE, blend=0)

Arguments

n

number of equally-spaced design points, assigned values 1, ..., n.

x

object of class "loess".

span

number of design points to be used in the local neighborhood – must be odd.

degree

degree of local polynomial (currently can be either 0, 1, or 2).

blend

the amount of blending to degree 0 smoothing at the endpoints.

at

which rows of the operator matrix to calculate.

stats

whether or not to calculate auxiliary statistics.

Details

If all that is desired is the loess estimate, it is more efficient and flexible to use the built-in loess(). The main purpose of this function is its use in stlOp or subsequent smoothings after using stlOp().

Value

A list of class "op".

O

the operator matrix of dimension length(at) x n.

at

at as specified in loessOp().

span

span as specified in loessOp().

deg

deg as specified in loessOp().

var

the squared l2 norm of each row in O – used in variance calculations.

stats

only if stats=TRUE. This is a list with the regulator matrix lambda=(I-O)'(I-O), the equivalent number of parameters enp (tr O'O), delta1 (tr lambda), delta2 (tr lambda^2), and trace.hat (tr O).

Note

This requires o(n^2) storage and computation. Rows of the operator matrix corresponding to interior design points will be identical, so keep this in mind.

Author(s)

Ryan Hafen

References

W. S. Cleveland, E. Grosse and W. M. Shyu (1992) Local regression models. Chapter 8 of Statistical Models in S eds J. M. Chambers and T. J. Hastie, Wadsworth & Brooks/Cole.

See Also

stlOp, plotVar, plotOp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
n <- 200
L <- loessOp(n, span=91, degree=2, at=c(-9:(n+10)))
plotVar(L)
plotOp(L)

## get fitted values for some data
x <- c(1:n)
# generate some data
y <- sin(x*2*pi/n) + rnorm(x, sd=0.5) 
# get the fitted values
yhat <- predict(L, y)
# another way: yhat <- L$O %*% y

plot(x, y, xlim=range(L$at))
lines(L$at, yhat, col="red")

hafen/operator documentation built on May 17, 2019, 2:23 p.m.