0

I need to bootstrap a a relative effect estimate calculated from paired binary data and I don't know how to do this. Below example data set:

# Create test data 

n <- 1000

treated <- rbinom(n, 1, 0.7)
control <- rbinom(n, 1, 0.5)

data <- cbind(treated, control)

# How to calculate relative effect

(sum(treated)-sum(control))/sum(control)*100

So, I should draw N random samples from the data set so that the row-wise pairs would be conserved, calculate the relative effect described above for each sample and then calcuate a desired statistic (mean or median) of the effect. I also would like to calculate the 95 % confidence interval of the bootstrap statistic. Is there any way to do this using an existing bootstrapping function (for example from package "boot") or should I define a custom function?

Pinus
  • 17
  • 4

1 Answers1

0

There's always 'pairs_boot' in Roger Peng's simpleboot package:

library(simpleboot)
library(boot)

rel_effect <- function(x,y) {
  (sum(x)-sum(y))/sum(y)*100
}

boot.RE <- pairs_boot(treated, control, FUN = rel_effect, R = 1000)
boot.ci(boot.RE)