s(x, df=4, spar=1)
gam.s(x, y, w, df, spar, xeval)
spar
below) is found
such that df=tr(S)-1
, where S
is the implicit smoother
matrix. Values for df
sh(0,1]
. See smooth.spline
for more details.gam.s
during backfittinggam.s
produces a
prediction at xeval
.s
returns the vector x
, endowed with a number of
attributes. The vector itself is used in the construction of the model
matrix, while the attributes are needed for the backfitting algorithms
all.wam
(weighted additive model) or s.wam
(currently not
implemented). Since smoothing splines reproduces linear fits, the linear
part will be efficiently computed with the other parametric linear parts
of the model.Note that s
itself does no smoothing; it simply sets things up
for gam
.
One important attribute is named call
. For example, s(x)
has a call component
gam.s(data[["s(x)"]], z, w, spar = 1, df = 4)
.
This is an expression that gets evaluated repeatedly in all.wam
(the backfitting algorithm).
gam.s
returns an object with components
x
), so these residual represent the
nonlinear part of the fit.gam.s
is evaluated with an xeval
argument, it returns a
vector of predictions.Hastie, T. and Tibshirani, R. (1990) Generalized Additive Models. London: Chapman and Hall.
lo
, smooth.spline
, bs
, ns
, poly
# fit Start using a smoothing spline with 4 df.
y ~ Age + s(Start, 4)
# fit log(Start) using a smoothing spline with 5 df.
y ~ Age + s(log(Start), df=5)
Run the code above in your browser using DataLab