| sim.cred.band {credsubs} | R Documentation |
Constructs a simultaneous credible band
Description
sim.cred.band returns a simultaneous band over a finite set of
covariate points given either a sample from the posterior of the
regression surface or a function FUN(x, params) and a sample from
the posterior of the parameters.
Usage
sim.cred.band(
params,
design = NULL,
FUN = function(x, params) { params %*% t(x) },
cred.level = 0.95,
method = c("asymptotic", "quantile"),
sides = c("both", "upper", "lower"),
est.FUN = mean,
var.FUN = sd,
point.estimate = NULL,
track = numeric(0),
verbose = FALSE
)
Arguments
params |
A numeric matrix whose rows are draws from the posterior distribution of either the regression surface or the parameter vector. |
design |
(Optional) A numeric matrix whose rows are covariate points over which the band is to be constructed. |
FUN |
(Optional) a function of the form |
cred.level |
Numeric; the credible level. |
method |
Either "asymptotic" (default) or "quantile"; see details. |
sides |
One of "both" (default), "upper", or "lower". Which bounds should be constructed? |
est.FUN |
The function used to produce estimates of the regression
surface. Default is |
var.FUN |
The function used to quantify the variability of the
regression surface posterior. Default is |
point.estimate |
If not null, replaces the mean and sets the reference
around which the standard error is computed.
Useful for bootstrapping methods.
Treated as a row of the |
track |
A numeric vector of indices indicating which rows (default none)
of the design matrix should have the sample of the corresponding
|
verbose |
Logical (default |
Details
If design is NULL (default), it is taken to be the identity
matrix of dimension ncol(params), so that the rows of params
are treated as draws from the posterior FUN(x, params).
The 'asymptotic' method assumes that the marginal posteriors of
the FUN(x, params) are asymptotically normal and is usually
significantly faster and less memory-intensive than the 'quantile'
method, which makes no such assumption.
Value
An object of class sim.cred.band, which contains:
upperA numeric vector of upper bounds.
lowerA numeric vector of lower bounds.
cred.levelAs provided.
methodAs provided.
sidesAs provided.
estPosterior estimate of the regression surface.
est.FUNAs provided.
varSummary of posterior variability of the regression surface.
var.FUNAs provided.
WAn estimate of the extremal errors.
W.critThe critical quantile of W.
traceThe posterior samples of the regression surface indicated by the
trackargument.
Examples
### Sample from regression surface posterior
reg.surf.sample <- matrix(rnorm(1000, mean=1:10), ncol=2, byrow=TRUE)
sim.cred.band(reg.surf.sample, cred.level=0.80)
### Parametric case
design <- cbind(1, 1:10)
params <- matrix(rnorm(200, mean=1:2), ncol=2, byrow=TRUE)
sim.cred.band(params, design)
### With custom function
params.sd <- cbind(1 / rgamma(100, 1), params)
FUN.sd <- function(x, params) { params[, -1] %*% t(x) / params[, 1] }
sim.cred.band(params.sd, design, FUN.sd)