prepare.array {hero}R Documentation

Prepare data array for sandwich smooth

Description

prepare.array prepares a data matrix for the sandwich smooth. The dimensionality of data and the length of x must match. Specifically, length(dim(data)) must equal length(x). The dimensionality of data and the length of splines must match. Specifically, length(dim(data)) must equal length(splines).

Usage

## S3 method for class 'array'
prepare(data, x, splines, m = 2, sparse = TRUE, ...)

Arguments

data

A data array

x

A list of univariate, equidistant sequences. These should correspond to where the data are observed. Equidistant spacing between 0 and 1 is assumed if not supplied. See Details.

splines

A list of spline-related objects, e.g., produced by bspline. Splines are automatically created if not supplied. See Details.

m

A positive integer indicating order of the difference penalty.

sparse

A logical value indicating if the result should be a sparse version of the Matrix-class.

...

Not currently implemented.

Details

For a typical sandwich smooth, for data with d dimensions, Y[i1, i2, ...,id] is assumed to be observed at position x[[1]][i1], x[[2]][i2], ..., x[[d]][id]. Consequently, dim(data)[i] should equal length(x[[i]]) for all i in seq_len(d).

If x is not supplied, then default.evalargs is used to create it automatically.

If splines is not supplied, then a B-spline basis is automatically created for each dimension using default.splines.

Value

A prepared_array object.

Author(s)

Joshua French. Based off code by Luo Xiao (see References).

References

Xiao, L. , Li, Y. and Ruppert, D. (2013), Fast bivariate P-splines: the sandwich smoother. J. R. Stat. Soc. B, 75: 577-599. <doi:10.1111/rssb.12007>

See Also

bspline, default.evalargs, default.splines

Examples

# generate and prepare 3d data
set.seed(9)
dat = generate.data3d()
obj = prepare(dat$data3d, x = dat$x)

[Package hero version 0.6 Index]