Basis | R Documentation |
This function is meant to be used for manual construction of arbitrary basis functions. For
‘local’ basis functions, please use the function local_basis
instead.
Basis(manifold, n, fn, pars, df, regular = FALSE)
manifold |
object of class |
n |
number of basis functions (should be an integer) |
fn |
a list of functions, one for each basis function. Each function should be encapsulated within an environment
in which the manifold and any other parameters required to evaluate the function are defined. The
function itself takes a single input |
pars |
A list containing a list of parameters for each function. For local basis functions these would correspond to location and scale parameters. |
df |
A data frame containing one row per basis function, typically for providing informative summaries. |
regular |
logical indicating if the basis functions (of each resolution) are in a regular grid |
This constructor checks that all parameters are valid before constructing the basis functions. The requirement that every function is encapsulated is tedious, but necessary for FRK to work with a large range of basis functions in the future. Please see the example below which exemplifies the process of constructing linear basis functions from scratch using this function.
auto_basis
for constructing basis functions automatically, local_basis
for
constructing ‘local’ basis functions, and show_basis
for visualising basis functions.
## Construct two linear basis functions on [0, 1]
manifold <- real_line()
n <- 2
lin_basis_fn <- function(manifold, grad, intercept) {
function(s) grad*s + intercept
}
pars <- list(list(grad = 1, intercept = 0),
list(grad = -1, intercept = 1))
fn <- list(lin_basis_fn(manifold, 1, 0),
lin_basis_fn(manifold, -1, 1))
df <- data.frame(n = 1:2, grad = c(1, -1), m = c(1, -1))
G <- Basis(manifold = manifold, n = n, fn = fn, pars = pars, df = df)
## Not run:
eval_basis(G, s = matrix(seq(0,1, by = 0.1), 11, 1))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.