Low et al (2016) examined the effects of two different anesthetics on aspects of the physiology of the mouse. Twelve mice were anesthetized with isoflurane and eleven mice were anesthetized with alpha chloralose and blood CO2 levels were recorded after 120 minutes. The H0 was that there is no difference between the anesthetics in the mean blood CO2 level. This is an independent comparison because individual mice were only given one of the two anesthetics.

Preliminaries

First, load the required packages (tidyverse, RMisc, MKinfer, car, emmeans)

Import low data file

low <- read.csv("../data/lowco2.csv")
low

Get summary statistics by anesthetic

low_stats <- summarySE(data=low,measurevar="co2", groupvars="anesth")
low_stats
low %>%  
  group_by (anesth) %>% 
summarise (median = median(co2), mean=mean(co2))

We will use a t-test for evaluating differences between two group means.

Fitting a simple linear model with anaesthetic as a categorical predictor (see Boxes 6.4 and 6.5) provides additional information including an ANOVA table and allows effect sizes to be calculated

low.aov <- aov(co2~anesth,data=low)
tidy(low.aov, conf.int=TRUE)

low.emm <- emmeans(low.aov,"anesth")
eff_size(low.emm, sigma=sigma(low.aov), edf=df.residual(low.aov))
 contrast effect.size    SE df lower.CL upper.CL
 ac - iso        1.29 0.463 21    0.329     2.25

sigma used for effect sizes: 16.2 
Confidence level used: 0.95 

Note that we’ve chosen to show a standardized effect size, using the pooled variance from the analysis of variance - Residual MS = 262.44, and √262.44 = 16.2

While we prefer graphical methods for assessing assumptions, we can evaluate differences between group variances with Levene’s test

leveneTest(co2 ~ anesth, low)
Warning: group coerced to factor.
Levene's Test for Homogeneity of Variance (center = median)
      Df F value Pr(>F)
group  1   2.604 0.1215
      21               

Comparing group means with a t-test assuming equal variances

t.test(co2~anesth,var.equal=TRUE, data=low)

    Two Sample t-test

data:  co2 by anesth
t = 3.0927, df = 21, p-value = 0.005515
alternative hypothesis: true difference in means between group ac and group iso is not equal to 0
95 percent confidence interval:
  6.849172 34.969010
sample estimates:
 mean in group ac mean in group iso 
         70.90909          50.00000 

Comparing group means with a t-test allowing different group variances

t.test(co2~anesth,data=low)

    Welch Two Sample t-test

data:  co2 by anesth
t = 3.0206, df = 15.485, p-value = 0.008362
alternative hypothesis: true difference in means between group ac and group iso 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 

The non-parametric Wilcoxon-Mann-Whitney test assesses whether the two samples come from identical populations that don’t have to be normally distributed

wilcox.test(co2~anesth,data=low)
Warning: cannot compute exact p-value with ties

    Wilcoxon rank sum test with continuity correction

data:  co2 by anesth
W = 114, p-value = 0.003398
alternative hypothesis: true location shift is not equal to 0
sum(rank(low$co2)[low$anesth=="ac"])
[1] 180
sum(rank(low$co2)[low$anesth=="iso"])
[1] 96
LS0tCnRpdGxlOiAiUUsgQm94IDIuMiIKb3V0cHV0OgogIGh0bWxfZG9jdW1lbnQ6CiAgICBkZl9wcmludDogcGFnZWQKICBodG1sX25vdGVib29rOgogICAgdGhlbWU6IGZsYXRseQotLS0KCmBgYHtyIHNldHVwLCBpbmNsdWRlPUZBTFNFfQprbml0cjo6b3B0c19jaHVuayRzZXQoZWNobyA9IFRSVUUpCmBgYAoKTG93IGV0IGFsICgyMDE2KSBleGFtaW5lZCB0aGUgZWZmZWN0cyBvZiB0d28gZGlmZmVyZW50IGFuZXN0aGV0aWNzIG9uIGFzcGVjdHMgb2YgdGhlIHBoeXNpb2xvZ3kgb2YgdGhlIG1vdXNlLiBUd2VsdmUgbWljZSB3ZXJlIGFuZXN0aGV0aXplZCB3aXRoIGlzb2ZsdXJhbmUgYW5kIGVsZXZlbiBtaWNlIHdlcmUgYW5lc3RoZXRpemVkIHdpdGggYWxwaGEgY2hsb3JhbG9zZSBhbmQgYmxvb2QgQ09+Mn4gbGV2ZWxzIHdlcmUgcmVjb3JkZWQgYWZ0ZXIgMTIwIG1pbnV0ZXMuIFRoZSAqSCp+MH4gd2FzIHRoYXQgdGhlcmUgaXMgbm8gZGlmZmVyZW5jZSBiZXR3ZWVuIHRoZSBhbmVzdGhldGljcyBpbiB0aGUgbWVhbiBibG9vZCBDT34yfiBsZXZlbC4gVGhpcyBpcyBhbiBpbmRlcGVuZ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