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)
.
# S3 method for array
prepare(data, x, splines, m = 2, sparse = TRUE, ...)
A prepared_array
object.
A data array
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.
A list of spline-related objects, e.g.,
produced by bspline
. Splines are
automatically created if not supplied. See Details.
A positive integer indicating order of the difference penalty.
A logical value indicating if the result
should be a sparse version of the
Matrix-class
.
Not currently implemented.
Joshua French. Based off code by Luo Xiao (see References).
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
.
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>
bspline
,
default.evalargs
,
default.splines
# generate and prepare 3d data
set.seed(9)
dat = generate.data3d()
obj = prepare(dat$data3d, x = dat$x)
Run the code above in your browser using DataLab