reweight(boot.obj, data.weights, probs, L, tau, tilt="exponential", subset.statistic, subjectDivide = F, modifiedStatistic = NULL, frame.eval = boot.obj$parent.frame)
subject
argument from
boot.obj
. Otherwise the
weights are taken to be ordered with respect to the sorted values of
subject
. The default implies equal weights.
In place of
data.weights
, one of
tau
or
probs
may be supplied,
and will be used with
L
to calculate
data.weights
using tilting.
If
data.weights
and
L
are both missing,
L
will be computed from
boot.obj
using
.
tau
is chosen to reweight the bootstrap
distribution to approximately satisfy the hypothesis that the
true parameter is equal to the
probs
quantile of the unweighted
bootstrap distribution.
n
, to be used for computing probabilities
by exponential or maximum likelihood tilting.
L
to use for tilting; default
1
.
boot.obj
was by
subject. Internal calculations involve assigning weights to subjects;
if
TRUE
then the weight for each subject is divided among observations
for that subject before calculating the statistic;
if
FALSE
the subject weight is replicated to observations for that subject.
Also, if
TRUE
and
data.weights
contains observation weights,
then initial subject weights will be the sums of weights for the
observations.
weights
argument, then pass this to indicate how to
call your function.
See below.
boot.obj
can be found.
You need to specify this if objects can't be found by their
original names, or have changed; see
.
"reweight"
which inherits from
"resamp"
.
This is similar to the original
object except that the
observed
value has been recomputed using the weighted empirical
distribution with probabilities
data.weights
, and the bootstrap
distribution now has unequal weights to reflect the sampling
probabilities.
No new sampling is performed; instead the weights are calculated using importance sampling identities.
The name
"Splus.resamp.weights"
is reserved for internal use by
reweight
. To avoid naming conflicts, that name can not be used as
a variable name in the
data
argument to
boot.obj
, if
data
is a data frame.
When the bootstrap statistic is an expression, for example
mean(x)
, a modified expression
mean(x, weights = Splus.resamp.weights)
is created.
Only calls to functions that have an argument named
weights
are modified; e.g.
sum(x)/length(x)
would fail because
sum
does not have a
weights
argument.
If the expression calls a function with a "hidden" weights argument,
e.g. you may pass weights as part of the
...
list, then
use the
modifiedStatistic
argument to specify that, e.g.
modifiedStatistic = myFun(x, weights = Splus.resamp.weights)
.
(You must use the name
Splus.resamp.weights
in
modifiedStatistic
.)
An expression such as
mean(y[a==1])
is converted to
mean(y[a==1], weights = Splus.resamp.weights)
which will fail because the weights vector was not subscripted along
with
y
.
In cases such as these pass a function that performs the desired
calculations, or use
modifiedStatistic = mean(y[a==1], weights = Splus.resamp.weights[a==1])
An error occurs if the bootstrap statistic can not be successfully
modified to accomodate weights and
modifiedStatistic
is not provided.
The bootstrap statistic
should be
"functional"
; that is, the observed value of the statistic
should be equal to the value computed with equal weights. A warning
occurs if this is not the case.
Hesterberg, T.C. (2001), "Bootstrap Tilting Diagnostics" Proceedings of the Statistical Computing Section, American Statistical Association (CD-ROM)
For an annotated list of functions in the package, including other high-level resampling functions, see: .
x <- rexp(30) bfit <- bootstrap(x, mean, save.indices=T) rfit <- reweight(bfit, L=x, probs=.2) bfit rfit plot(bfit) plot(rfit)