basis_sets | R Documentation |
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)
df |
number of basis functions to construct |
left |
number giving left-hand boundary of the interval |
right |
number giving right-hand boundary of the interval |
x |
inputs at which to evaluate the functions (in the |
n |
number of fourier components to generate |
fperiod |
number giving the fundamental period length for the Fourier basis |
knots |
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 |
intercept |
if |
Boundary.knots |
boundary points at which to impose the natural
boundary conditions and anchor the B-spline basis (default the range
of the data). If both |
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.
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.