This box continues with the Low et al. anesthetic example from Box 2.2

Preliminaries

packages: MKinfer, resample

library(MKinfer)
library(resample)
library(tidyverse)

use low data

low <- read_csv("../data/lowco2.csv")
Rows: 23 Columns: 2── Column specification ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Delimiter: ","
chr (1): anesth
dbl (1): co2
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Get jackknife SE for two groups

low1 <- subset(low,anesth=="iso")
jackknife(low1$co2,mean)
Call:
jackknife(data = low1$co2, statistic = mean)
Replications: 12

Summary Statistics:
low2 <- subset(low,anesth=="ac")
jackknife(low2$co2,mean)
Call:
jackknife(data = low2$co2, statistic = mean)
Replications: 11

Summary Statistics:

Get bootstrap SE and 95%CI

low1boot <- bootstrap(low1$co2,mean,R=9999)
low1boot
Call:
bootstrap(data = low1$co2, statistic = mean, R = 9999)
Replications: 9999

Summary Statistics:
CI.percentile(low1boot, probs=c(0.025,0.975))
         2.5%    97.5%
mean 43.41667 58.16667
CI.bca(low1boot, probs=c(0.025,0.975))
         2.5% 97.5%
mean 44.41667    60
low2boot <- bootstrap(low2$co2,mean,R=9999)
low2boot
Call:
bootstrap(data = low2$co2, statistic = mean, R = 9999)
Replications: 9999

Summary Statistics:
CI.percentile(low2boot, probs=c(0.025,0.975))
     2.5%    97.5%
mean   59 86.07054
CI.bca(low2boot, probs=c(0.025,0.975))
         2.5%    97.5%
mean 60.18182 88.59399

Get bootstrap SE and CI on difference

lowboot <- bootstrap2(low$co2,mean,treatment=low$anesth,R=9999,ratio=FALSE)
lowboot
Call:
bootstrap2(data = low$co2, statistic = mean, treatment = low$anesth, 
    R = 9999, ratio = FALSE)
Replications: 9999
Two samples, sample sizes are 11 12

Summary Statistics for the difference between samples 1 and 2:
CI.percentile(lowboot, probs=c(0.025,0.975))
                 2.5%    97.5%
mean: ac-iso 6.050547 36.82406

Randomization test

perm.t.test(co2~anesth, data=low, R=9999, paired= FALSE)

    Permutation Welch Two Sample t-test

data:  co2 by anesth
(Monte-Carlo) permutation p-value = 0.0042 
permutation difference of means (SE) = 20.80499 (7.960466) 
95 percent (Monte-Carlo) permutation percentile confidence interval:
  5.575758 36.251136

Results without permutation:
t = 3.0206, df = 15.485, p-value = 0.008362
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
  6.194866 35.623316
sample estimates:
 mean in group ac mean in group iso 
         70.90909          50.00000 
LS0tCnRpdGxlOiAiUUsgQm94IDIuMyIKb3V0cHV0OiAKICBodG1sX25vdGVib29rOgogICAgdGhlbWU6IGZsYXRseQotLS0KCmBgYHtyIHNldHVwLCBpbmNsdWRlPUZBTFNFfQprbml0cjo6b3B0c19jaHVuayRzZXQoZWNobyA9IFRSVUUpCmBgYApUaGlzIGJveCBjb250aW51ZXMgd2l0aCB0aGUgTG93IGV0IGFsLiBhbmVzdGhldGljIGV4YW1wbGUgZnJvbSBCb3ggMi4yCgojIyMgUHJlbGltaW5hcmllcwpwYWNrYWdlczogTUtpbmZlciwgcmVzYW1wbGUKYGBge3IgcmVzdWx0cz0naGlkZSd9CmxpYnJhcnkoTUtpbmZlcikKbGlicmFyeShyZXNhbXBsZSkKbGlicmFyeSh0aWR5dmVyc2UpCmBgYAp1c2UgbG93IGRhdGEKYGBge3IgfQpsb3cgPC0gcmVhZF9jc3YoIi4uL2RhdGEvbG93Y28yLmNzdiIpCgpgYGAKIyMjIEdldCBqYWNra25pZmUgU0UgZm9yIHR3byBncm91cHMKYGBge3J9CmxvdzEgPC0gc3Vic2V0KGxvdyxhbmVzdGg9PSJpc28iKQpqYWNra25pZmUobG93MSRjbzIsbWVhbikKbG93MiA8LSBzdWJzZXQobG93LGFuZXN0aD09ImFjIikKamFja2tuaWZlKGxvdzIkY28yLG1lYW4pCmBgYAojIyMgR2V0IGJvb3RzdHJhcCBTRSBhbmQgOTUlQ0kKYGBge3J9CmxvdzFib290IDwtIGJvb3RzdHJhcChsb3cxJGNvMixtZWFuLFI9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