These functions generate the mathematical functions for three different basis sets: Fourier (sines), Legendre (orthogonal polynomials), and Splines (low-order smooth approximation)
legendre_set(df = 3, left = -1, right = 1)legendre_M(x, df, left = -1, right = 1)
ns_set(df = 3, left = -1, right = 1)
fourier_M(x, n, fperiod = NULL)
ns_M(x, df = NULL, knots = NULL, intercept = FALSE, Boundary.knots = range(x))
fourier_set(df, left = -1, right = 1)
The _M
functions return a model matrix. The _set
functions
return a function with arguments x
and n
. The integer n
specifies
which function to use, while x
is the set of values at which to evaluate
that function.
number of basis functions to construct
number giving left-hand boundary of the interval
number giving right-hand boundary of the interval
inputs at which to evaluate the functions (in the _M
functions)
number of fourier components to generate
number giving the fundamental period length for the Fourier basis
breakpoints that define the spline. The default is no
knots; together with the natural boundary conditions this results in
a basis for linear regression on x
. Typical values are the
mean or median for one knot, quantiles for more knots. See also
Boundary.knots
.
if TRUE
, an intercept is included in the
basis; default is FALSE
.
boundary points at which to impose the natural
boundary conditions and anchor the B-spline basis (default the range
of the data). If both knots
and Boundary.knots
are
supplied, the basis parameters do not depend on x
. Data can
extend beyond Boundary.knots
For each basis, there are two different forms for the
generating functions. Names ending in _set
create a set of functions with
arguments x
and n
, where integer n
provides an index into the set.
The same names with a _M
suffix produce a model matrix
corresponding to a specified set of x values. These are useful
with lm()
and similar model-building functions in the same way that
poly()
and ns()
are useful. (ns_M()
is just an alias for splines::ns()
.) Like
poly()
and ns()
, the _M
suffix functions do NOT include an
intercept column.