This box continues with the Low et al. anesthetic example from Box 2.2
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.
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:
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
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
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