get_resampling_idxs: Get Importance Resampling Indices From Weights

View source: R/use_weights.R

get_resampling_idxsR Documentation

Get Importance Resampling Indices From Weights

Description

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

Usage

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

## Not run: 
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)

## End(Not run)


CoryMcCartan/adjustr documentation built on June 25, 2022, 4:44 p.m.