### Supplementary Code S1 for LaPoint et al. (2017) “Growth overshoot and seasonal size changes in ### the skulls of two weasel species” Royal Society Open Science. ### Not run ### Prior to executing bootstrapped t-tests, the x-variable must have only 2 levels, so the dataframe was ### split beforehand into subsets of species-sex specific groups, each containing only two age levels; ### e.g., Mustela.nivalis.female.juvenile.subadult. ### Each subsetted dataframe was run separately in the code ###below. library(boot) ### defining the statistic for comparison: stat <- function(data, indices){ t.test <- t.test(CBL ~ age, data)$stat ### x must have only two levels. t.test } ### Define how the data should be randomized rand.gen <- function(data, mle){ out <- data out$age <- sample(out$age, replace = T) # defining what variable to resample by (with replacement): age out } test.boot <- boot(skulls, stat, R = 5000, sim = "parametric", ran.gen = rand.gen) ### 5000 iterations of a t.test between age factors on CBL print(test.boot) ### output t1* = "original" t-value and bias (abs) = bootstrapped data result plot(test.boot) tval <- length(test.boot[test.boot$t >= abs(test.boot$t0)])+1 tval/(test.boot$R+1) # = resulting p value