Takes a vector of weights, or data frame or list containing sets of weights, and resamples indices for use in later computation.

get_resampling_idxs(x, frac = 1, replace = TRUE)

Arguments

x

A vector of weights, a list of weight vectors, or a data frame of type adjustr_weighted containing a .weights list-column of weights.

frac

A real number giving the fraction of draws to resample; the default, 1, resamples all draws. Smaller values should be used when replace=FALSE.

replace

Whether sampling should be with replacement. When weights are extreme it may make sense to use replace=FALSE, but accuracy is not guaranteed in these cases.

Value

A vector, list, or data frame, depending of the type of x, containing the sampled indices. If any weights are NA, the indices will also be NA.

Examples

if (FALSE) {
spec = make_spec(eta ~ student_t(df, 0, 1), df=1:10)
adjusted = adjust_weights(spec, eightschools_m)

get_resampling_idxs(adjusted)
get_resampling_idxs(adjusted, frac=0.1, replace=FALSE)
}