eecop_boot: Bootstrapping eecop models

View source: R/bootstrap.R

eecop_bootR Documentation

Bootstrapping eecop models

Description

Given a fitted model for the weight function, eecop_boot() generates a number of bootstrap replicates from this model. A multiplier bootstrap procedure is used. The result can be passed to predict.eecop_boot() to generate bootstrapped predictions, or conf_int() to compute confidence intervals directly.

Usage

eecop_boot(object, n_boot = 100, rxi = stats::rexp, cores = 1)

## S3 method for class 'eecop_boot'
predict(
  object,
  x,
  type = "expectile",
  t = 0.5,
  trafo = function(y) y,
  cores = 1,
  ...
)

conf_int(
  object,
  x,
  type = "expectile",
  t = 0.5,
  trafo = function(y) y,
  conf = 0.9,
  cores = 1,
  ...
)

Arguments

object

a fitted eecop object.

n_boot

number of bootstrap replicates.

rxi

a function generating bootstrap multipliers; the function needs to take the number of samples as its first argument and return a numeric vector of this length. Default is rexp(), which corresponds to the 'Bayesian bootstrap'. Note that, for the theory to work, one should normalize so that E(rxi) = var(rxi) = 1, e.g. with function(n) {xi <- rxi(n); return((xi - mean(xi)) / sd(xi) + 1)}.

cores

an integer for the number of cores to use; if cores > 1, estimation will be parallelized within over n_boot (using parallel::parLapply()).

x

covariate values to predict on; must match the format used for fitting the eecop() model.

type

either "quantile", "expectile", "mean", or "variance".

t

a vector of quantile/expectile levels.

trafo

a function with signature ⁠function(y)⁠ with y the response (vector or matrix). The function should return a vector of length NROW(object$y) or a matrix with NROW(object$y) rows.

...

unused.

conf

confidence level.

Value

An objecvt of class eccop_boot containing the original eecop object and bootstrap replicates.

See Also

eecop(), predict.eecop_boot()

Examples

# model with continuous variables
x <- matrix(rnorm(200), 100, 2)
y <- rowSums(x) + rnorm(100)

fit <- eecop(y, x)

bs_fits <- eecop_boot(fit, n_boot = 2)
preds <- predict(bs_fits, x[1:3, ])
CI <- conf_int(bs_fits, x[1:3, ], type = "quantile", t = c(0.5, 0.9))

tnagler/eecop documentation built on June 12, 2024, 12:57 a.m.