Title: Landscape influence on the feeding habits of European badger (Meles meles) in arid Spain

Journal: Mammal Research

Authors: Juan M. Requena-Mullor*, Enrique López, Antonio J. Castro, Emilio Virgós, and Hermelindo Castro.

*Corresponding author: Andalusian Center for the Assessment and Monitoring of Global Change (CAESCG), Dp. Biology and Geology, University of Almería.E-mail addresses:

Online Resource 1. R code to estimate the F´s distribution from ANOVA analysis by bootstrap resampling technique.

#NOTE: This script is modified from the William B. King´s script in R #tutorials ( to carry out #a two-way ANOVA model with interactions.

#This example estimates the F´s distribution for the effects of #landscape and season factors on the fruit relative volume.

######################################################################

#we estimate the mean values in each level

meanblocks = with(scatsVRcomplet, tapply(fruits_v,fruits_season:fruits_landsca,mean,na.rm=T))

#we center all the groups on the same mean (zero), but we leave the variance and shape of the individual group distributions undisturbed

grpA = as.vector(na.omit(scatsVRcomplet$fruits_v[scatsVRcomplet$fruits_season=="autumn"&scatsVRcomplet$fruits_landsca=="Forestry"] - meanblocks[1]))

grpB = as.vector(na.omit(scatsVRcomplet$fruits_v[scatsVRcomplet$fruits_season=="autumn"&scatsVRcomplet$fruits_landsca=="Maquia"] - meanblocks[2]))

grpC = as.vector(na.omit(scatsVRcomplet$fruits_v[scatsVRcomplet$fruits_season=="autumn"&scatsVRcomplet$fruits_landsca=="Xeric_shrubland"] - meanblocks[3]))

grpD = as.vector(na.omit(scatsVRcomplet$fruits_v[scatsVRcomplet$fruits_season=="spring"&scatsVRcomplet$fruits_landsca=="Forestry"] - meanblocks[4]))

grpE = as.vector(na.omit(scatsVRcomplet$fruits_v[scatsVRcomplet$fruits_season=="spring"&scatsVRcomplet$fruits_landsca=="Maquia"] - meanblocks[5]))

grpF = as.vector(na.omit(scatsVRcomplet$fruits_v[scatsVRcomplet$fruits_season=="spring"&scatsVRcomplet$fruits_landsca=="Xeric_shrubland"] - meanblocks[6]))

grpG = as.vector(na.omit(scatsVRcomplet$fruits_v[scatsVRcomplet$fruits_season=="summer"&scatsVRcomplet$fruits_landsca=="Forestry"] - meanblocks[7]))

grpH = as.vector(na.omit(scatsVRcomplet$fruits_v[scatsVRcomplet$fruits_season=="summer"&scatsVRcomplet$fruits_landsca=="Maquia"] - meanblocks[8]))

grpI = as.vector(na.omit(scatsVRcomplet$fruits_v[scatsVRcomplet$fruits_season=="summer"&scatsVRcomplet$fruits_landsca=="Xeric_shrubland"] - meanblocks[9]))

grpJ = as.vector(na.omit(scatsVRcomplet$fruits_v[scatsVRcomplet$fruits_season=="winter"&scatsVRcomplet$fruits_landsca=="Forestry"] - meanblocks[10]))

grpK = as.vector(na.omit(scatsVRcomplet$fruits_v[scatsVRcomplet$fruits_season=="winter"&scatsVRcomplet$fruits_landsca=="Maquia"] - meanblocks[11]))

grpL = as.vector(na.omit(scatsVRcomplet$fruits_v[scatsVRcomplet$fruits_season=="winter"&scatsVRcomplet$fruits_landsca=="Xeric_shrubland"] - meanblocks[12]))

season = scatsVRcomplet[!is.na(scatsVRcomplet$fruits_v),2]

landscape= scatsVRcomplet[!is.na(scatsVRcomplet$fruits_v),3]

#number of replicates for bootstrap

R = 10000

Fstar = numeric(R)

Fstar1 = numeric(R)

Fstar2 = numeric(R)

for (i in 1:R) {#loop for the replicates

groupA = sample(grpA, size=length(grpA), replace=T)

groupB = sample(grpB, size=length(grpB), replace=T)

groupC = sample(grpC, size=length(grpC), replace=T)

groupD = sample(grpD, size=length(grpD), replace=T)

groupE = sample(grpE, size=length(grpE), replace=T)

groupF = sample(grpF, size=length(grpF), replace=T)

groupG = sample(grpF, size=length(grpG), replace=T)

groupH = sample(grpF, size=length(grpH), replace=T)

groupI = sample(grpF, size=length(grpI), replace=T)

groupJ = sample(grpF, size=length(grpJ), replace=T)

groupK = sample(grpF, size=length(grpK), replace=T)

groupL = sample(grpF, size=length(grpL), replace=T)

simfacto = c(groupA,groupB,groupC,groupD,groupE,groupF,groupG,groupH,groupI,groupJ,groupK,groupL)

simdata = data.frame(simfacto,season,landscape)

Fstar[i] <- summary(aov(simfacto~season*landscape, data=simdata))[[1]]$F[1]

Fstar1[i]<- summary(aov(simfacto~season*landscape, data=simdata))[[1]]$F[2]

Fstar2[i]<- summary(aov(simfacto~season*landscape, data=simdata))[[1]]$F[3]

}

#Fstar: F´s distribution for the season effect

#Fstar1: F´s distribution for the landscape effect

#Fstar2: F´s distribution for the interaction effect

resampling<-matrix(c(Fstar,Fstar1,Fstar2),nrow=10000,ncol=3)

#critical value for the probability 0.95, with corresponding freedom #degrees but assuming normality.

qf(.95,df1,df2)#df1: freedom degrees of the factor; df2: freedom #degrees of the residuals

#critical value for the probability 0.95, with corresponding freedom #degrees but no assuming normality.

quantile(Fstar,.95)

#this script must be run for the relative volume of vertebrates and invertebrates.

------

The R-script results are shown in the Table 3.For the two-way ANOVA analysis with season and landscape as fixed factors and the relative volume of the broad categories as the response variable,no effect varied its significationby applying the bootstrap resampling.

Table 3.Critical values for 0.95 probabilities. With * no assuming normality, without * assuming normality.

Relative volume / Effect / F / Critical value / *Critical value
Fruits / Season / 4.04 / 2.646 / 2.62
Landscape / 13.3 / 3.037 / 2.901
Season x Landscape / 1.22 / 2.14 / 2.059
Vertebrates / Season / 2.07 / 2.76 / 2.26
Landscape / 5.56 / 3.153 / 3.05
Season x Landscape / 1.36 / 2.256 / 1.819
Invertebrates / Season / 2.85 / 2.53 / 2.645
Landscape / 11.61 / 3.036 / 3.058
Season x Landscape / 1.96 / 2.091 / 2.139