censorReg
and
censorRegList
for specified statistics,
and summarizes the bootstrap distribution.
bootstrap.censorReg(data, statistic, B = 1000, args.stat = NULL, group, subject, sampler = samp.bootstrap, seed = .Random.seed, sampler.prob, sampler.args, sampler.args.group, resampleColumns, label, statisticNames, block.size = min(100,B), trace = resampleOptions()$trace, assign.frame1 = F, save.indices, save.group, save.subject, statistic.is.random, group.order.matters = T, seed.statistic = 500, L, model.mat, ...)
censorRegList
object to be bootstrapped.
censorReg
objects and returns a
vector or matrix.
It may be a function (e.g.
coef
) which
accepts data as the first argument;
other arguments may be passed using
args.stat
.
predict(fit,newdata=orig.frame)
.
If the
data
object is given by name (e.g.
data=fit
) then use that name
in the expression,
otherwise (e.g.
data=glm(formula,dataframe)
) use the name
data
in
the expression, e.g.
predict(data,newdata=orig.frame)
.
TRUE
(the default),
groups (strata) for resampling are inferred from the data via
the
strata
function in the
formula
argument to
censorReg
.
If
FALSE
, no stratification is used in resampling.
bootstrap
which inherits from
resamp
. See
for details.
This function is designed to simplify calls to and speed up the resulting computations when the statistic of interest requires the computation of a censorReg object. Without this method, bootstrapping objects would require, for example,
#
bootstrap(data=data.frame, coef(censorReg(formula, data=data.frame, ...),...),...)
#
In this case
is called once per iteration, and a new object of
class
censorReg
is created each time. (In fact,
is currently incompatible with
using the above idiom -- see Bug 20994.)
Faster (but equivalent) results are obtained using
#
bootstrap(censorReg(formula, data.frame, ...), coef, ...)
#
which dispatches to
bootstrap.censorReg
. The savings come from the
reduction of the overhead required to create the fitted model.
bootstrap.censorReg
does this work just once, saves the result in
an object of class
model.list
, and then resamples the
model.list
.
A word of warning on resampling
objects: Adequate modeling
by
requires a minimum number of failures in the data or
every stratum (see
for details).
Resampling with replacement may create an individual sample with too few
failures, even if the original data has enough. In this case the
statistic for that sample is omitted and
bootstrap
fails,
because the statistic size varies from sample to sample.
See .
# Unstratified data, default statistic `coef'. Take out the # "voltage" = 20 records (for which there are no failures) # to avoid warnings. fit <- censorReg(censor(days, event) ~ voltage, data = capacitor[-(1:25),], distribution = "weibull", threshold = "Lin") bootstrap(fit, coef(fit), seed=0, B=100) # Stratified data: fit is of class `censorRegList'. fit <- censorReg(censor(days, event) ~ strata(voltage), data = capacitor[-(1:25),], distribution = "weibull", threshold = "Lin") bootstrap(fit, coef(fit), seed=0, B=100)