Specify a Loess Fit in a GAM Formula

DESCRIPTION:
Allows the user to specify a Loess fit in a GAM formula.

USAGE:
lo(..., span=0.5, degree=1)

OPTIONAL ARGUMENTS:
...:
the unspecified ... can be a comma-separated list of numeric vectors, numeric matrix, or expressions that evaluate to either of these. If it is a list of vectors, they must all have the same length.
span:
the number of observations in a neighborhood. This is the smoothing parameter for a loess fit.
degree:
the degree of local polynomial to be fit; can be 1 or 2.

VALUE:
a numeric matrix is returned. The simplest case is when there is a single argument to lo and degree=1; a one-column matrix is returned, consisting of a normalized version of the vector. If degree=2 in this case, a two-column matrix is returned, consisting of a 2d-degree orthogonal-polynomial basis. Similarly, if there are two arguments, or the single argument is a two-column matrix, either a two-column matrix is returned if degree=1, or a five-column matrix consisting of powers and products up to degree 2. Any dimensional argument is allowed, but typically one or two vectors are used in practice. The matrix is endowed with a number of attributes; the matrix itself is used in the construction of the model matrix, while the attributes are needed for the backfitting algorithms all.wam or lo.wam (weighted additive model). Local-linear curve or surface fits reproduce linear responses, while local-quadratic fits reproduce quadratic curves or surfaces. These parts of the loess fit are computed exactly together with the other parametric linear parts of the model.

Note that lo itself does no smoothing; it simply sets things up for gam.


SEE ALSO:
s , bs , ns , poly , loess , gam .

EXAMPLES:
y ~ Age + lo(Start, span=.5)
     # fit Start using a loess smooth with a span of 0.5.
y ~ lo(Age) + lo(Start, Number)
y ~ lo(Age, 0.5) # the argument name for span is not needed.