This is a repository copy of How well can body size represent effects of the environment on demographic rates? Disentangling correlated explanatory variables. White Rose Research Online URL for this paper: http://eprints.whiterose.ac.uk/91271/ Version: Supplemental Material Article: Brooks, ME, Mugabo, M, Rodgers, GM et al. (2 more authors) (2016) How well can body size represent effects of the environment on demographic rates? Disentangling correlated explanatory variables. Journal of Animal Ecology, 85. pp. 318-328. ISSN 0021-8790 https://doi.org/10.1111/1365-2656.12465 Reuse Unless indicated otherwise, fulltext items are protected by copyright with all rights reserved. The copyright exception in section 29 of the Copyright, Designs and Patents Act 1988 allows the making of a single copy solely for the purpose of non-commercial research or private study within the limits of fair dealing. The publisher or other rights-holder may allow further reproduction and re-use of this version - refer to the White Rose Research Online record for this item. Where records identify the publisher as the copyright holder, users can verify any specific terms of use on the publisher s website. Takedown If you consider content in White Rose Research Online to be in breach of UK law, please notify us by emailing eprints@whiterose.ac.uk including the URL of the record and the reason for the withdrawal request. eprints@whiterose.ac.uk https://eprints.whiterose.ac.uk/
Appendix S5: Full Model Predictions and Splines Mollie Brooks, Marianne Mugabo, Gwendolen M. Rodgers, Timothy G. Benton, Arpat Ozgul August 25, 2015 Contents 1 Description 2 2 Preliminaries 2 3 Growth 2 3.1 Predictions............................ 3 3.2 Explanatory Variable Effects.................. 4 4 Transition 10 4.1 Predictions............................ 11 4.2 Explanatory Variable Effects.................. 12 5 Probability of Reproducing 18 5.1 Predictions............................ 19 5.2 Explanatory Variable Effects.................. 20 6 Egg Counts, Given Reproduction 25 6.1 Predictions............................ 26 6.2 Explanatory Variable Effects.................. 26 7 All Predictions Combined 32 8 All past environment effects 34 9 Version Info 35 1
1 DESCRIPTION 2 1 Description In this appendix, we present the full models and their predictions and splines. These predictions closely resemble those of the best model chosen by AICc. We look at the full models to examine the past environment splines while controlling for the known effects of body size and the current environment. Not all splines are significantly different from 0 according to Wood s test (Table 2 main text), but the declining and fluctuating treatments were significant for several demographic rates. So we would like to examine these. ReadersmayskipoverchunksofRcodetoexaminethefigures. However, we also provide the code for repeatability. 2 Preliminaries library(reshape) library(ggplot2) library(mgcv) library(bbmle) library(plyr) load("../individual soil mite data.rdata") Indiv$food.s=scale(Indiv$food) newdata=ddply(indiv,.(pop.id,, stage), summarize, trt=trt[1], density.s=density.s[1], supply.s= supply.s[1], food.s=food.s[1], l0.s=quantile(l0.s,.5, na.rm=true)) ke=10 #environment kd=10 #s kl=5 #length 3 Growth
3 GROWTH 3 temp=na.omit(subset(indiv, stage!="egg")[,c("l0.s", "l24", "density.s", "supply.s", "", "trt", "l0", "stage")]) gm_full=gam(l24~s(l0.s, k=kl)+s(density.s, supply.s, k=ke)+trt+s(, by=trt, k=kd), data=temp) 3.1 Predictions gn=newdata gn$l24=predict(gm_full, gn) p1=ggplot(gn, aes(x=, y=l24))+ geom_line(aes(colour=stage, group=pop.id:stage))+ facet_wrap(~trt) p1+geom_point(data=temp,aes(colour=stage), alpha=.15)+theme_bw() ## Warning: Removed 1 rows containing missing values (geom path).
3 GROWTH 4 T1 T2 0.9 0.6 0.3 stage larva l24 T3 T4 proto trito male female 0.9 0.6 0.3 0 20 40 60 0 20 40 60 3.2 Explanatory Variable Effects plot(gm_full, pers=true, residuals=true, sewithmean=true, select=1, main="body size effect")
3 GROWTH 5 body size effect s(l0.s,3.87) 0.2 0.0 0.2 0.4 0.6 1 0 1 2 3 l0.s plot(gm_full, pers=true, residuals=true, sewithmean=true, select=2, main="current environment effect")
3 GROWTH 6 current environment effect density.s supply.s plot(gm_full, pers=true, residuals=true, sewithmean=true, select=3, ylim=c(-0.05, 0.05), main="control treatment")
3 GROWTH 7 control treatment s(,6.19):trtt1 0.04 0.02 0.00 0.02 0.04 0 10 20 30 40 50 60 plot(gm_full, pers=true, residuals=true, sewithmean=true, select=4, ylim=c(-0.2, 0.2), main="famine treatment")
3 GROWTH 8 famine treatment s(,3.8):trtt2 0.2 0.1 0.0 0.1 0.2 0 10 20 30 40 50 60 plot(gm_full, pers=true, residuals=true, sewithmean=true, select=5, ylim=c(-0.05, 0.02), main="declining treatment")
3 GROWTH 9 declining treatment s(,3.09):trtt3 0.05 0.04 0.03 0.02 0.01 0.00 0.01 0.02 0 10 20 30 40 50 60 plot(gm_full, pers=true, residuals=true, sewithmean=true, select=6, ylim=c(-0.05, 0.02), main="fluctuating treatment") #statistically significa
4 TRANSITION 10 fluctuating treatment s(,4.45):trtt4 0.05 0.04 0.03 0.02 0.01 0.00 0.01 0.02 0 10 20 30 40 50 60 4 Transition Subset data to only include the juvenile survivors. tempt=transform(subset(indiv, (!stage %in% c("male","female") & (s24==1))), t.init.24=as.numeric(t24 %in% c("next stage", "quiescent")), t.done.24=as.numeric(t24 == "next stage"), stage=stage[, drop=true] )
4 TRANSITION 11 temp=na.omit(tempt[,c("t.init.24","l0.s","trt","","density.s", "supply.s", "stage", "pop.id") tempsum=ddply(temp,.(trt,, stage, pop.id), summarize, t.sum=mean(t.init.24)) t24m_full=gam(t.init.24~ stage +s(l0.s, k=kl)+ s(density.s, supply.s, k=ke)+trt+s(, by=trt, k=kd), family=binomial, data=temp) 4.1 Predictions tn=subset(newdata,! stage %in% c("male", "female")) tn$t.init.24=predict(t24m_full, tn, type="response") p1=ggplot(tn, aes(x=, y= t.init.24))+ geom_line(aes(colour=stage, group=pop.id:stage))+facet_wrap(~trt) p1+ylab("probability of Initiating Transition")+theme_bw()+ geom_point(data=tempsum, aes(x=, y=t.sum, colour=stage), alpha=.5)
4 TRANSITION 12 1.00 T1 T2 0.75 0.50 Probability of Initiating Transition 0.25 0.00 1.00 0.75 T3 T4 stage larva proto trito 0.50 0.25 0.00 0 20 40 60 0 20 40 60 4.2 Explanatory Variable Effects plot(t24m_full, pers=true, residuals=true, sewithmean=true, select=1, ylim=c(-10, 25), main="body size effect")
4 TRANSITION 13 body size effect s(l0.s,3.26) 10 5 0 5 10 15 20 25 1.5 1.0 0.5 0.0 0.5 l0.s plot(t24m_full, pers=true, residuals=true, sewithmean=true, select=2, main="current environment effect")
4 TRANSITION 14 current environment effect density.s supply.s plot(t24m_full, pers=true, residuals=true, sewithmean=true, select=3, ylim=c(-2, 2), main="control treatment")
4 TRANSITION 15 control treatment s(,1.64):trtt1 2 1 0 1 2 0 10 20 30 40 50 60 plot(t24m_full, pers=true, residuals=true, sewithmean=true, select=4, ylim=c(-10, 20), main="famine treatment")
4 TRANSITION 16 famine treatment s(,2.13):trtt2 10 5 0 5 10 15 20 0 10 20 30 40 50 60 plot(t24m_full, pers=true, residuals=true, sewithmean=true, select=5, ylim=c(-8, 5), main="declining treatment")#marginally statistically signifi
4 TRANSITION 17 declining treatment s(,3.55):trtt3 8 6 4 2 0 2 4 0 10 20 30 40 50 60 plot(t24m_full, pers=true, residuals=true, sewithmean=true, select=6, ylim=c(-3, 2), main="fluctuating treatment")#marginally statistically signi
5 PROBABILITY OF REPRODUCING 18 fluctuating treatment s(,1):trtt4 3 2 1 0 1 2 0 10 20 30 40 50 60 5 Probability of Reproducing Remove ones that were dead at 24hrs. Use females only. Indivtmp=subset(Indiv, stage=="female" &!is.na(s24)) temp=subset(indivtmp,!is.na(l0.s*as.numeric(trt)*f24) & (s24==1))[,c("f24","l0.s","trt","","density.s", "supply.s","stage", "pop.id")] tempsum=ddply(temp,.(trt,, pop.id), summarize, f.sum=mean(f24>0))
5 PROBABILITY OF REPRODUCING 19 fbm_full=gam(as.numeric(f24>0)~s(l0.s, k=kl)+s(density.s, supply.s, k=ke)+trt+s(, 5.1 Predictions fn=subset(newdata, stage == "female") fn$f24pos=predict(fbm_full, fn, type="response") p1=ggplot(fn, aes(x=, y=f24pos))+ geom_line(aes(group=pop.id))+facet_wrap(~trt)+ geom_point(data=tempsum, aes(x=, y=f.sum), alpha=.5) p1+ylab("probability of Reproducing")+theme_bw() 1.00 T1 T2 0.75 0.50 Probability of Reproducing 0.25 0.00 1.00 0.75 T3 T4 0.50 0.25 0.00 0 20 40 60 0 20 40 60
5 PROBABILITY OF REPRODUCING 20 5.2 Explanatory Variable Effects plot(fbm_full, pers=true, residuals=true, sewithmean=true, select=1, ylim=c(-10, 25), main="body size effect") body size effect s(l0.s,3.36) 10 5 0 5 10 15 20 25 0.0 0.5 1.0 1.5 2.0 2.5 3.0 l0.s plot(fbm_full, pers=true, residuals=true, sewithmean=true, select=2, main="current environment effect")
5 PROBABILITY OF REPRODUCING 21 current environment effect density.s supply.s plot(fbm_full, pers=true, residuals=true, sewithmean=true, select=3, ylim=c(-5, 5), main="control treatment")
5 PROBABILITY OF REPRODUCING 22 control treatment s(,1):trtt1 4 2 0 2 4 0 10 20 30 40 50 60 plot(fbm_full, pers=true, residuals=true, sewithmean=true, select=4, ylim=c(-25, 25), main="famine treatment")
5 PROBABILITY OF REPRODUCING 23 famine treatment s(,3.88):trtt2 20 10 0 10 20 0 10 20 30 40 50 60 plot(fbm_full, pers=true, residuals=true, sewithmean=true, select=5, ylim=c(-10, 5), main="declining treatment")#statistically significant
5 PROBABILITY OF REPRODUCING 24 declining treatment s(,2.28):trtt3 10 5 0 5 0 10 20 30 40 50 60 plot(fbm_full, pers=true, residuals=true, sewithmean=true, select=6, ylim=c(-10, 10), main="fluctuating treatment")
6 EGG COUNTS, GIVEN REPRODUCTION 25 fluctuating treatment s(,6.57):trtt4 10 5 0 5 10 0 10 20 30 40 50 60 6 Egg Counts, Given Reproduction temp=na.omit(subset(indivtmp, (f24>0) & (s24==1))[,c("f24","l0.s","trt","","density.s", "supply.s","stage")]) fcm_full=gam(f24-1~s(l0.s, k=kl)+s(density.s, supply.s, k=ke)+ trt+s(, by=trt, k=kd), family=poisson, data=temp)
6 EGG COUNTS, GIVEN REPRODUCTION 26 6.1 Predictions fn$f24=predict(fcm_full, fn, type="response")+1 p1=ggplot(fn, aes(x=, y=f24))+ geom_line(aes(group=pop.id))+facet_wrap(~trt) p1+ylab("number of Eggs")+geom_point(data=temp, alpha=.15)+theme_bw() T1 T2 40 30 20 Number of Eggs 10 0 40 T3 T4 30 20 10 0 0 20 40 60 0 20 40 60 6.2 Explanatory Variable Effects
6 EGG COUNTS, GIVEN REPRODUCTION 27 plot(fcm_full, pers=true, residuals=true, sewithmean=true, select=1, ylim=c(-3, 3), main="body size effect") body size effect s(l0.s,3.53) 3 2 1 0 1 2 3 0.5 1.0 1.5 2.0 2.5 3.0 l0.s plot(fcm_full, pers=true, residuals=true, sewithmean=true, select=2, main="current environment effect")
6 EGG COUNTS, GIVEN REPRODUCTION 28 current environment effect density.s supply.s plot(fcm_full, pers=true, residuals=true, sewithmean=true, select=3, ylim=c(-2, 2), main="control treatment")
6 EGG COUNTS, GIVEN REPRODUCTION 29 control treatment s(,3.54):trtt1 2 1 0 1 2 0 10 20 30 40 50 60 plot(fcm_full, pers=true, residuals=true, sewithmean=true, select=4, ylim=c(-25, 25), main="famine treatment")
6 EGG COUNTS, GIVEN REPRODUCTION 30 famine treatment s(,2.52):trtt2 20 10 0 10 20 0 10 20 30 40 50 60 plot(fcm_full, pers=true, residuals=true, sewithmean=true, select=5, ylim=c(-10, 2), main="declining treatment")#statistically significant
6 EGG COUNTS, GIVEN REPRODUCTION 31 declining treatment s(,7.08):trtt3 10 8 6 4 2 0 2 0 10 20 30 40 50 60 plot(fcm_full, pers=true, residuals=true, sewithmean=true, select=6, ylim=c(-10, 5), main="fluctuating treatment")#marginally statistically sign
7 ALL PREDICTIONS COMBINED 32 fluctuating treatment s(,7.97):trtt4 10 5 0 5 0 10 20 30 40 50 60 7 All Predictions Combined dat0=merge(gn, tn, all=true) dat=merge(dat0, fn, all=true) dm=melt(dat, id.vars=1:8) levels(dm$trt)=c("constant", "famine", "declining", "fluctuating") tmplabel=function(variable, x) { if (variable=="variable") { c("length after \n 24 hrs",
7 ALL PREDICTIONS COMBINED 33 } else { "probability of \n initiating transition", "probability of \n reproducing", "egg count \n given reproduction")[x] c("constant", "famine", "declining", "fluctuating")[x] } } p1=ggplot(dm, aes(x=, y=value))+ geom_line(aes(colour=stage,lty=stage, group=pop.id:stage))+ facet_grid(variable~trt, scale="free", labeller=tmplabel)+ theme_bw() p1 ## Warning: Removed 1 rows containing missing values (geom path).
8 ALL PAST ENVIRONMENT EFFECTS 34 constant famine declining fluctuating 0.8 0.6 0.4 length after 24 hrs 0.2 value 0.75 0.50 0.25 0.00 1.00 0.75 0.50 0.25 0.00 probability of initiating transition probability of reproducing stage larva proto trito male female 20 10 0 0 20 40 0 10 20 30 0 20 40 60 0 20 40 60 egg count given reproduction 8 All past environment effects #pdf("effects of past environments.pdf") par(mfrow=c(4,4), mar=c(0,4,3,0.1), oma=c(4,5,4, 0.1) ) plot(gm_full, pers=true, residuals=true, sewithmean=true, select=3, ylim=c(-0.05, 0.05), main="control", ylab="growth", xlab="") plot(gm_full, pers=true, residuals=true, sewithmean=true, select=4, ylim=c(-0.2, 0.2), main="famine", ylab="", xlab="") plot(gm_full, pers=true, residuals=true, sewithmean=true, select=5, ylim=c(-0.05, 0.02), main="declining", ylab="", xlab="") plot(gm_full, pers=true, residuals=true, sewithmean=true,
8 ALL PAST ENVIRONMENT EFFECTS 35 select=6, ylim=c(-0.05, 0.02), main="fluctuating", ylab="", xlab="") #statistically s plot(t24m_full, pers=true, residuals=true, sewithmean=true, select=3, ylim=c(-2, 2), ylab="transition", xlab="") plot(t24m_full, pers=true, residuals=true, sewithmean=true, select=4, ylim=c(-10, 20), ylab="", xlab="") plot(t24m_full, pers=true, residuals=true, sewithmean=true, select=5, ylim=c(-8, 5), ylab="", xlab="")#marginally statistically significant plot(t24m_full, pers=true, residuals=true, sewithmean=true, select=6, ylim=c(-3, 2), ylab="", xlab="")#marginally statistically significant plot(fbm_full, pers=true, residuals=true, sewithmean=true, select=3, ylim=c(-5, 5), ylab="reproduction", xlab="") plot(fbm_full, pers=true, residuals=true, sewithmean=true, select=4, ylim=c(-25, 25), ylab="", xlab="") plot(fbm_full, pers=true, residuals=true, sewithmean=true, select=5, ylim=c(-10, 5), ylab="", xlab="")#statistically significant plot(fbm_full, pers=true, residuals=true, sewithmean=true, select=6, ylim=c(-10, 10), ylab="", xlab="") plot(fcm_full, pers=true, residuals=true, sewithmean=true, select=3, ylim=c(-2, 2), ylab="fecundity") plot(fcm_full, pers=true, residuals=true, sewithmean=true, select=4, ylim=c(-25, 25), ylab="") plot(fcm_full, pers=true, residuals=true, sewithmean=true, select=5, ylim=c(-10, 2), ylab="")#statistically significant plot(fcm_full, pers=true, residuals=true, sewithmean=true, select=6, ylim=c(-10, 5), ylab="")#marginally statistically significant
9 VERSION INFO 36 control famine declining fluctuating growth 0.04 0.00 0.04 0.2 0.0 0.1 0.2 0.05 0.02 0.01 0.05 0.02 0.01 0 20 40 60 0 20 40 60 0 20 40 60 0 20 40 60 transition 2 1 0 1 2 10 0 5 15 8 4 0 2 4 3 1 0 1 2 0 20 40 60 0 20 40 60 0 20 40 60 0 20 40 60 reproduction 4 0 2 4 20 0 10 10 5 0 5 10 5 0 5 10 0 20 40 60 0 20 40 60 0 20 40 60 0 20 40 60 fecundity 2 1 0 1 2 20 0 10 10 6 2 2 10 5 0 5 0 20 40 60 0 20 40 60 0 20 40 60 0 20 40 60 #dev.off() 9 Version Info sessioninfo() ## R version 3.2.1 (2015-06-18) ## Platform: x86_64-apple-darwin13.4.0 (64-bit) ## Running under: OS X 10.10.4 (Yosemite) ##
9 VERSION INFO 37 ## locale: ## [1] en_us.utf-8/en_us.utf-8/en_us.utf-8/c/en_us.utf-8/en_us.utf-8 ## ## attached base packages: ## [1] stats4 stats graphics grdevices utils datasets methods ## [8] base ## ## other attached packages: ## [1] plyr_1.8.3 bbmle_1.0.17 mgcv_1.8-6 nlme_3.1-120 ggplot2_1.0.1 ## [6] reshape_0.8.5 knitr_1.11 ## ## loaded via a namespace (and not attached): ## [1] Rcpp_0.12.0 magrittr_1.5 MASS_7.3-40 ## [4] munsell_0.4.2 colorspace_1.2-6 lattice_0.20-31 ## [7] stringr_1.0.0 highr_0.5 tools_3.2.1 ## [10] grid_3.2.1 gtable_0.1.2 digest_0.6.8 ## [13] numderiv_2014.2-1 Matrix_1.2-1 reshape2_1.4.1 ## [16] formatr_1.2 evaluate_0.7.2 labeling_0.3 ## [19] stringi_0.5-5 scales_0.2.5 proto_0.3-10