hero | R Documentation |
hero
constructs a hero sandwich smoother based off
off a prepared data object coming from the
prepare
function.
Subclasses are added (e.g., hero_numeric
,
hero_matrix
, hero_array
, etc.) are added to
the returned object for plotting purposes.
A list is returned (and the data locations are not) for
hero.prepared_list
. Each element of the list
contains the coefficients and fitted values (if fitted
is
TRUE) for the respective data observation.
hero(x, ...)
## S3 method for class 'prepared_array'
hero(x, ...)
## S3 method for class 'prepared_list'
hero(x, ..., fitted = FALSE)
## S3 method for class 'prepared_matrix'
hero(x, ...)
## S3 method for class 'prepared_numeric'
hero(x, ...)
## S3 method for class 'prepared_sequential'
hero(
x,
...,
export_list,
export_fun = base::saveRDS,
package = "base",
call_args = list()
)
## S3 method for class 'prepared_starray'
hero(x, ...)
## S3 method for class 'prepared_sts'
hero(x, ...)
x |
Data prepared via the |
... |
Mostly not implemented. |
fitted |
A logical value indicating whether the fitted values should be
computed. The default is |
export_list |
A vector or list whose elements tell |
export_fun |
A function that will write the results for each observation
to file using the names in |
package |
A character string indicating the approach to use for the
computations. The choices are |
call_args |
A named list providing relevant arguments to
|
A hero
object with the smoothed data
(fitted
), the estimated coefficients for the
basis functions (coefficients
), and the
locations of the original data (x
).
Joshua French.
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>
French, Joshua P., and Piotr S. Kokoszka. "A sandwich smoother for spatio-temporal functional data." Spatial Statistics 42 (2021): 100413.
# create b-splines
x1 = bspline(nbasis = 10)
x2 = bspline(nbasis = 12)
# observed data locations
evalarg1 = seq(0, 1, len = 60)
evalarg2 = seq(0, 1, len = 80)
# construct "true" data
mu = matrix(0, nrow = 60, ncol = 80)
for(i in seq_len(60)) {
for(j in seq_len(80)) {
mu[i, j] = sin(2*pi*(evalarg1[i]-.5)^3)*cos(4*pi*evalarg2[j])
}
}
# construct noisy data
data = mu + rnorm(60 * 80)
obj = prepare(data, list(evalarg1, evalarg2), list(x1, x2))
obj = enhance(obj)
sandmod = hero(obj)
plot(sandmod)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.