boot_tmeans2: hierarchical bootstrap

Description Usage Arguments Examples

View source: R/boot_tmeans.R

Description

This will implement hierarchical bootstrapping as oppossed to stratified bootstrapping, which is the default

Usage

1
2
3
4
5
6
7
8
boot_tmeans2(
  formula = NULL,
  data,
  R = 500,
  var.names = c("y", "trial"),
  level = 0.95,
  ncpus = 1
)

Arguments

formula

standard R formula, as in resp ~ trial

data

data frame

R

number of replicates

var.names

optional alternative to formula

level

probability level

ncpus

number of cpus for parallel resampling (not implemented yet)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
require(ggplot2)
## How does it compare to stratified resampling?
data(soyrs)
btm1 <- boot_tmeans(lrr ~ Trial_ID, data = soyrs)
btm2 <- boot_tmeans2(lrr ~ Trial_ID, data = soyrs)

dat <- data.frame(method = rep(c("boot","boot2"), each = nrow(btm2$dat)),
                  pos = rep(c(2,5), each = nrow(btm2$dat)),
                  ys = c(btm1$ys, btm2$dat$ys))
                  
ggplot(data = dat) + 
     xlab("lrr") +
     geom_point(aes(x = ys, y = pos, color = method)) + 
     geom_jitter(aes(x = ys, y = pos, color = method)) +
     geom_density(aes(x = ys, color = method))
     
## The two methods give nearly identical answers


## End(Not run)

femiguez/predintma documentation built on July 5, 2021, 4:16 a.m.