bootstrap
and other
resample
objects.
resample
objects, or create it if necessary.
resampGetIndices
extracts a matrix of resampling indices from a resampling
object, or creates it from scratch if necessary.
resampGetArgument
extracts arguments used to create resample
objects.
resampGetIndices(object, frame.eval = <<see below>>) resampGetArgument(object, argument, checkObject = <<see below>>, frame.eval = <<see below>>)
resample
object (not all such objects are appropriate for
these functions).
object
.
TRUE
, look first in
object
for a component with name equal to
argument
. This is the default action unless
argument
equals
"B"
, in
which case the value is recreated from the original call to the
resample function.
object
can be found.
You need to specify this if objects can't be found by their
original names, or have changed; see
.
resampGetIndices
returns a matrix of indices.
resampGetArgument
returns the value of
argument
,
evaluated in an appropriate context.
The context is important in two cases. First, if the object were created
inside a function and made use of objects defined in that function,
then those objects, or identical copies, should be accessible;
this is done by letting
frame.eval
be the number of the frame
of that function, or a new frame containing copies of those objects.
Second, if the
data
argument to the resample function is a data
frame, that data frame, then arguments like
group
and
subject
are
searched for there first.
resampGetIndices
just extracts an
indices
component if one exists
in the object. Otherwise it creates a new call to the original function, with
the
statistic
set to a function that returns
NULL
.
Results will be incorrect if the sampler is adaptive, where indices
depend on the value of the statistic returned in earlier replications.
If
checkObject=TRUE
,
resampGetArgument
first checks
object
for a
component with name equal to
argument
and, if found, returns that
value. If the
component is not found (or if
checkObject=FALSE
), the argument is
reconstructed from the original call. Symbolic references in the call
(as in the case where the bootstrap
data
argument is a data frame,
and
group
is the name of a column of
data
) are evaluated so
that the actual value of the argument is returned. Note that this may
cause unintended results in the case
argument="statistic"
: if
statistic
is an expression, the expression is evaluated (if
possible) and that value returned. If you want the unevaluated
expression for an argument, access the component directly, using, for
example,
object$call$statistic
.
The special default action when
argument="B"
addresses the case when
bootstrap
argument
B
is a vector. In this case, the value stored
in the bootstrap object is not the vector, but
sum(B)
,
the total number of resamples. The original vector
B
can be
recreated from the call.
# get indices boot <- bootstrap(stack.loss, mean, B=50) resampGetIndices(boot) # get group argument df <- data.frame(x=stack.loss, a=rep(1:3, 6:8)) boot <- bootstrap(df, mean(x), group=a, B=50) resampGetArgument(boot, "group")