hero: Construct a hero sandwich smoother

View source: R/hero.R

heroR Documentation

Construct a hero sandwich smoother

Description

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.

Usage

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, ...)

Arguments

x

Data prepared via the prepare function.

...

Mostly not implemented. hero.prepared_list takes the fitted argument, specifying whether the fitted values should be returned.

fitted

A logical value indicating whether the fitted values should be computed. The default is FALSE.

export_list

A vector or list whose elements tell export_fun what files to export. The length must match the number of observations, i.e., the number of elements in x$Ytilde

export_fun

A function that will write the results for each observation to file using the names in export_list. Must only have the arguments object, which is what will be saved and computed internally, and file, which is the name of the file that will be saved. file will be one of the elements of export_list.

package

A character string indicating the approach to use for the computations. The choices are "base", "parallel", "pbapply", "future.apply", or "Rmpi". The default is "base". If package == "base", then mapply is used. If package == "parallel", then mcmapply is used. If package == "pbapply", then pblapply is used. If codepackage == "future.apply", then future_mapply is used. If codepackage == "Rmpi", then mpi.applyLB is used.

call_args

A named list providing relevant arguments to mcmapply, pblapply, future_mapply, or mpi.applyLB, depending on the package choice.

Value

A hero object with the smoothed data (fitted), the estimated coefficients for the basis functions (coefficients), and the locations of the original data (x).

Author(s)

Joshua French.

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>

French, Joshua P., and Piotr S. Kokoszka. "A sandwich smoother for spatio-temporal functional data." Spatial Statistics 42 (2021): 100413.

Examples

# 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)

hero documentation built on July 26, 2023, 5:11 p.m.

Related to hero in hero...