lo(…, span=0.5, degree=1)
gam.lo(x, y, w, span, degree, ncols, xeval)
…
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.loess
fit. If specified, the full argument name
span
must be written.1
or 2
. If specified, the full argument name
degree
must be written.gam.lo
, the appropriate basis of polynomials
generated from the arguments to lo
. These are also the
variables that receive linear coefficients in the GAM fit.gam.lo
during backfittinggam.lo
the number of columns in x
used as
the smoothing inputs to local regression. For example, if
degree=2
, then x
has two columns defining a degree-2
polynomial basis. Both are needed for the parameteric part of the fit,
but ncol=1
telling the local regression routine that the first
column is the actually smoothing variable.gam.lo
produces a
prediction at xeval
.lo
returns a numeric matrix. 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 degree-2 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 general.wam
(weighted additive
model) or lo.wam
(currently not implemented). 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 When two or more smoothing variables are given, the user should make
sure they are in a commensurable scale; lo()
does no
normalization. This can make a difference, since lo()
uses a
spherical (isotropic) neighborhood when establishing the nearest neighbors. Note that lo
itself does no smoothing; it simply sets things up
for gam
; gam.lo
does the actual smoothing.
of the model. One important attribute is named call
. For example, lo(x)
has a call component
gam.lo(data[["lo(x)"]], z, w, span = 0.5, degree = 1, ncols = 1)
.
This is an expression that gets evaluated repeatedly in general.wam
(the backfitting algorithm). gam.lo
returns an object with components
x
), so these residual represent the
nonlinear part of the fit.gam.lo
is evaluated with an xeval
argument, it returns a
matrix of predictions.gam.lo
fits the local
polynomial, then strips off this parametric part. All the parametric
pieces from all the terms in the additive model are fit
simultaneously in one operation for each loop of the backfitting
algorithm.s
, bs
, ns
, poly
, loess
y ~ Age + lo(Start)
# fit Start using a loess smooth with a (default) span of 0.5.
y ~ lo(Age) + lo(Start, Number)
y ~ lo(Age, span=0.3) # the argument name span cannot be abbreviated.
Run the code above in your browser using DataLab