Repeat cycles of bootstrap resampling followed by density re-estimation for testing purposes.

cycle_rvtable(x, n, start = NULL, density.args, sample.args, keep = "all")

Arguments

x

an rvtable in distribution form only.

n

total number of iteratively estimated distributions to return, including the original from x.

start

usually NULL when first called and on subsequent recursive calls an integer representing which cycle to begin from in the updated rvtable.

density.args

optional arguments passed to density. If supplied, overrides the density.args attribute of x.

sample.args

optional arguments used when sampling. If supplied, overrides the sample.args attribute of x.

keep

character, iterations to retain in output table. Options are "all" (default) or "last".

Value

an rvtable.

Details

This function repeats cycles of bootstrap resampling from a distribution followed by distribution re-estimation n - 1 times. x must be a distribution-form rvtable and not a sample-form rvtable.

Examples

# NOT RUN {
library(dplyr)
x <- data.frame(
  id1=rep(LETTERS[1:5], each=4),
  id2=factor(c("low", "high")),
  id3=rep(1:2, each=2),
  Val=rep(1:10, each=20), Prob=rep(sqrt(1:10), each=20)) %>% rvtable
cycle_rvtable(x, 2)
x %>% group_by(id1, id2) %>% cycle_rvtable(3, keep="last")
# }