prepare.matrix {hero} | R Documentation |
Prepare data matrix for sandwich smooth
Description
prepare.matrix
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 'matrix'
prepare(
data,
x,
splines,
m = 2,
sparse = TRUE,
spdiffpen = TRUE,
digits = 1,
sts = FALSE,
...
)
Arguments
data |
A data matrix. |
x |
A list of values at which to evaluate the basis functions. See Examples and Details. |
splines |
A list of spline objects
( |
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
|
spdiffpen |
A logical value indicating whether
|
digits |
The number of digits to use when applying
|
sts |
A logical value indicating whether |
... |
Not currently implemented. |
Details
For a typical sandwich smooth (sts = FALSE
),
for two-dimensional data, data[i, j]
is assumed
to be observed at position x[[1]][i]
,
x[[2]][j]
. If the data are a spatial time series,
then the first dimension is assumed to refer to space,
and the second dimension to time. In that case,
data[i, j]
is assumed
to be observed at location x[[1]][i, ]
and time
x[[2]][j]
.
If sts = TRUE
, then x[[1]]
should be a
matrix of spatial coordinates, with each row
corresponding to a location, and x[[2]]
should
be a vector with the observation times.
If x
is not supplied, then
default.evalargs
is used to create it
automatically. This is only valid when
sts = FALSE
.
If splines
is not supplied, then a B-spline basis
is automatically created for each dimension using
default.splines
. This is only valid when
sts = FALSE
.
Value
A prepared_matrix
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
, radspline
,
diffpen
, spdiffpen
,
default.evalargs
,
default.splines
Examples
# prepare Lu et al. (2012) noisy f1 data
data(ludata)
obj = prepare(lunoisyf1, x = list(x, z))
h = hero(obj)
# precompute some stuff
splines = default.splines(list(x, z))
l = assemble(splines, x = list(x, z))
obj2 = prepare(lunoisyf1, x = list(x, z),
splines = splines, assembled = l)
h2 = hero(obj2)
all.equal(h, h2)