smooth.spline
SmoothSpline.Rd
smooth.spline has no formula interface, which is sometimes inconvenient, if one simply wants to copy a formula of a linear model or a plot to spline.
SmoothSpline(x, ...)
# Default S3 method
SmoothSpline(x, y = NULL, w = NULL, df, spar = NULL, cv = FALSE,
all.knots = FALSE, nknots = .nknots.smspl, keep.data = TRUE,
df.offset = 0, penalty = 1, control.spar = list(),
tol = 0.000001 * IQR(x), ...)
# S3 method for class 'formula'
SmoothSpline(formula, data, subset, na.action, ...)
a vector giving the values of the predictor variable, or a list or a two-column matrix specifying x and y.
responses. If y
is missing or NULL
, the responses
are assumed to be specified by x
, with x
the index
vector.
optional vector of weights of the same length as x
;
defaults to all 1.
the desired equivalent number of degrees of freedom (trace of the smoother matrix).
smoothing parameter, typically (but not necessarily) in
\((0,1]\). The coefficient \(\lambda\) of the integral of the
squared second derivative in the fit (penalized log likelihood)
criterion is a monotone function of spar
, see the details
below.
ordinary (TRUE
) or ‘generalized’ cross-validation
(GCV) when FALSE
; setting it to NA
skips the evaluation
of leverages and any score.
if TRUE
, all distinct points in x
are used as
knots. If FALSE
(default), a subset of x[]
is used,
specifically x[j]
where the nknots
indices are evenly
spaced in 1:n
, see also the next argument nknots
.
integer or function
giving the number of
knots to use when all.knots = FALSE
. If a function (as by
default), the number of knots is nknots(nx)
. By default for
\(n_x > 49\) this is less than \(n_x\), the number
of unique x
values, see the Note.
logical specifying if the input data should be kept
in the result. If TRUE
(as per default), fitted values and
residuals are available from the result.
allows the degrees of freedom to be increased by
df.offset
in the GCV criterion.
the coefficient of the penalty for degrees of freedom in the GCV criterion.
optional list with named components controlling the
root finding when the smoothing parameter spar
is computed,
i.e., missing or NULL
, see below.
Note that this is partly experimental and may change with general spar computation improvements!
lower bound for spar
; defaults to -1.5 (used to
implicitly default to 0 in R versions earlier than 1.4).
upper bound for spar
; defaults to +1.5.
the absolute precision (tolerance) used; defaults to 1e-4 (formerly 1e-3).
the relative precision used; defaults to 2e-8 (formerly 0.00244).
logical indicating if iterations should be traced.
integer giving the maximal number of iterations; defaults to 500.
Note that spar
is only searched for in the interval
\([low, high]\).
a tolerance for same-ness or uniqueness of the x
values. The values are binned into bins of size tol
and
values which fall into the same bin are regarded as the same. Must
be strictly positive (and finite).
a formula of the form lhs ~ rhs
where lhs
gives the data values and rhs the corresponding groups.
The data frame from which the formula should be evaluated.
an optional vector specifying a subset of observations to be used.
a function which indicates what should happen when the data contain NAs. Defaults to
getOption("na.action")
.
Other arguments to be passed to
smooth.spline
.