setwd("X:/Data/Desktop/PhD Groningen/Manuscripts/Age effect") fitndiet1213<-read.table("fitndiet1213.csv",header=T,sep=";", dec=",") fitndiet1213$year<-as.factor(fitndiet1213$year) require(lme4) #require(lmerTest) require(usdm) require(AICcmodavg) require(ggplot2) require(MuMIn) require(cowplot) require(scales) require(grid) require(MuMIn) #a function to summarize data summarySE <- function(data=NULL, measurevar, groupvars=NULL, na.rm=TRUE, conf.interval=.95, .drop=TRUE) { require(plyr) # New version of length which can handle NA's: if na.rm==T, don't count them length2 <- function (x, na.rm=TRUE) { if (na.rm) sum(!is.na(x)) else length(x) } # This does the summary. For each group's data frame, return a vector with # N, mean, and sd datac <- ddply(data, groupvars, .drop=.drop, .fun = function(xx, col) { c(N = length2(xx[[col]], na.rm=na.rm), mean = mean (xx[[col]], na.rm=na.rm), sd = sd (xx[[col]], na.rm=na.rm) ) }, measurevar ) # Rename the "mean" column datac <- rename(datac, c("mean" = measurevar)) datac$se <- datac$sd / sqrt(datac$N) # Calculate standard error of the mean # Confidence interval multiplier for standard error # Calculate t-statistic for confidence interval: # e.g., if conf.interval is .95, use .975 (above/below), and use df=N-1 ciMult <- qt(conf.interval/2 + .5, datac$N-1) datac$ci <- datac$se * ciMult return(datac) } larvSE<-summarySE(dietage, measurevar="larva", groupvars=c("box","age2")) flyySE<-summarySE(dietage, measurevar="flying", groupvars=c("box","age2")) spidSE<-summarySE(dietage, measurevar="spider", groupvars=c("box","age2")) beetlSE<-summarySE(dietage, measurevar="beetle", groupvars=c("box","age2")) durhSE<-summarySE(dietage, measurevar="durh", groupvars=c("box","age","age2")) durhSE<-summarySE(durhSE, measurevar="durh", groupvars=c("box","age2")) fitness1213<-read.table("fitness1213.csv",header=T,sep=";", dec=",") diet1213av<-read.table("diet1213av.csv",header=T,sep=";", dec=",") fitn1<-summarySE(fitness1213, measurevar="d7m", groupvars=c("box")) fitn2<-summarySE(fitness1213, measurevar="d12m", groupvars=c("box")) fitn3<-summarySE(fitness1213, measurevar="d12t", groupvars=c("box")) fitn4<-summarySE(fitness1213, measurevar="d12p3", groupvars=c("box")) fitn5<-summarySE(fitness1213, measurevar="d7n", groupvars=c("box")) fitn6<-summarySE(fitness1213, measurevar="d12n", groupvars=c("box")) catdatesession<-data.frame(larvSE$box,larvSE$larva,larvSE$age2,flyySE$fl) fitn7<-data.frame(fitn1$box,fitn1$d7m,fitn5$d7n,fitn2$d12m,fitn6$d12n,fitn3$d12t,fitn4$d12p3) fitn7<-rename(fitn7, c("fitn1.box"="box", "fitn1.d7m"="d7m", "fitn5.d7n"="d7n", "fitn2.d12m"="d12m", "fitn6.d12n"="d12n", "fitn3.d12t"="d12t", "fitn4.d12p3"="d12p3")) fitn<-merge(fitn7,diet1213av,by="box") write.table(fitn, "meme2105.txt") catdatesession<-merge(durhSE,larvSE,by=c("box","age2")) catdatesession<-merge(catdatesession,flyySE,by=c("box","age2")) catdatesession<-merge(catdatesession,spidSE,by=c("box","age2")) catdatesession<-merge(catdatesession,beetlSE,by=c("box","age2")) write.table(catdatesession, "catdatesession.txt") summarySE(dietage,measurevar="reldate", groupvars=c("box","age2")) #First we scale our predictor variables summarySE(fitndiet1213, measurevar="olarvchickhour") #.id N olarvchickhour sd se ci #1 53 3.853892 1.727352 0.2372701 0.4761172 fitndiet1213$olch<-(fitndiet1213$olarvchickhour-3.853892)/1.727352 summarySE(fitndiet1213, measurevar="oflyychickhour") #.id N oflyychickhour sd se ci #1 53 1.279669 0.8918577 0.1225061 0.2458264 fitndiet1213$ofch<-(fitndiet1213$oflyychickhour-1.279669)/0.8918577 summarySE(fitndiet1213, measurevar="ospidchickhour") #.id N ospidchickhour sd se ci #1 53 0.7122071 0.7564457 0.1039058 0.2085023 fitndiet1213$osch<-(fitndiet1213$ospidchickhour-0.7122071)/0.7564457 summarySE(fitndiet1213, measurevar="obeetlchickhour") #.id N obeetlchickhour sd se ci #1 53 0.8290218 0.7419065 0.1019087 0.2044947 fitndiet1213$obch<-(fitndiet1213$obeetlchickhour-0.8290218)/0.7419065 summarySE(fitndiet1213, measurevar="ototchickhour") # N ototchickhour sd se ci #1 53 6.674677 2.254745 0.309713 0.6214846 fitndiet1213$otch<-(fitndiet1213$ototchickhour-6.674677)/2.254745 summarySE(fitndiet1213, measurevar="ylarvchickhour") #.id N ylarvchickhour sd se ci #1 59 3.276812 1.573624 0.2048683 0.4100885 fitndiet1213$ylch<-(fitndiet1213$ylarvchickhour-3.276812)/1.573624 summarySE(fitndiet1213, measurevar="yflyychickhour") #.id N yflyychickhour sd se ci #1 59 0.9142117 0.8303388 0.1081009 0.2163875 fitndiet1213$yfch<-(fitndiet1213$yflyychickhour-0.9142117)/0.8303388 summarySE(fitndiet1213, measurevar="yspidchickhour") #.id N yspidchickhour sd se ci #1 59 0.9015762 0.7430985 0.09674319 0.1936525 fitndiet1213$ysch<-(fitndiet1213$yspidchickhour-0.9015762)/0.7430985 summarySE(fitndiet1213, measurevar="ybeetlchickhour") #.id N ybeetlchickhour sd se ci #1 59 0.29537 0.4378536 0.05700369 0.1141053 fitndiet1213$ybch<-(fitndiet1213$ybeetlchickhour-0.29537)/0.4378536 summarySE(fitndiet1213, measurevar="ytotchickhour") #.id N ytotchickhour sd se ci #1 59 5.388089 1.802823 0.2347075 0.4698182 fitndiet1213$ytch<-(fitndiet1213$ytotchickhour-5.388089)/1.802823 summarySE(fitndiet1213, measurevar="yreldate") #.id N yreldate sd se ci #1 59 -2.627119 4.578429 0.5960607 1.193145 fitndiet1213$yreldat<-(fitndiet1213$yreldate+2.542373)/4.598808 summarySE(fitndiet1213, measurevar="oreldate") #.id N oreldate sd se ci #1 53 -2.679245 4.746552 0.651989 1.308312 fitndiet1213$oreldat<-(fitndiet1213$oreldate+2.679245)/4.746552 summarySE(fitndiet1213, measurevar="hd") #.id N hd sd se ci #1 59 -0.008474576 4.193644 0.545966 1.09287 fitndiet1213$hdat<-(fitndiet1213$hd+0.008474576)/4.193644 summarySE(fitndiet1213, measurevar="hba") #.id N hba sd se ci #1 59 53.63288 33.39735 4.347964 8.703396 fitndiet1213$hab<-(fitndiet1213$hba-53.63288)/33.39735 summarySE(fitndiet1213, measurevar="tarsp") #.id N tarsp sd se ci #1 59 17.40339 0.2932024 0.0381717 0.07640895 fitndiet1213$tarp<-(fitndiet1213$tarsp-17.40339)/0.2932024 summarySE(fitndiet1213, measurevar="p3p") #.id N p3p sd se ci #1 59 60.5425 0.949581 0.1236249 0.2474622 fitndiet1213$f8p<-(fitndiet1213$p3p-60.5425)/0.949581 collyoung<-data.frame(fitndiet1213$yreldat^2,fitndiet1213$yfch,fitndiet1213$ylch,fitndiet1213$ysch,fitndiet1213$ybch) collold<-data.frame(fitndiet1213$oreldat^2,fitndiet1213$ofch,fitndiet1213$olch,fitndiet1213$osch,fitndiet1213$obch) vifcor(collyoung,th=0.9) vifcor(collold,th=0.9) vifstep(collyoung,th=10) vifstep(collold,th=10) citation(package="usdm") d7mod<-list() d7mod[[1]]<-lmer(d7m~1+(1|year), data=fitndiet1213,REML = FALSE) d7mod[[2]]<-lmer(d7m~hdat+(1|year), data=fitndiet1213,REML = FALSE) d7mod[[3]]<-lmer(d7m~I(hdat^2)+(1|year), data=fitndiet1213,REML = FALSE) d7mod[[4]]<-lmer(d7m~I(hdat^2)+hdat+(1|year), data=fitndiet1213,REML = FALSE) d7mod[[5]]<-lmer(d7m~yreldat+(1|year), data=fitndiet1213,REML = FALSE) d7mod[[6]]<-lmer(d7m~I(yreldat^2)+(1|year), data=fitndiet1213,REML = FALSE) d7mod[[7]]<-lmer(d7m~I(yreldat^2)+yreldat+(1|year), data=fitndiet1213,REML = FALSE) d7mod[[8]]<-lmer(d7m~hab+(1|year), data=fitndiet1213,REML = FALSE) d7mod[[9]]<-lmer(d7m~ylch+(1|year), data=fitndiet1213,REML = FALSE) d7mod[[10]]<-lmer(d7m~I(hdat^2)+ylch+(1|year), data=fitndiet1213,REML = FALSE) d7mod[[11]]<-lmer(d7m~I(hdat^2)+hab+(1|year), data=fitndiet1213,REML = FALSE) summary(d7mod[[9]]) aictab(cand.set= d7mod) d7mod2<-list() d7mod2[[1]]<-lmer(d7m~I(yreldat^2)+(1|year), data=fitndiet1213,REML = FALSE) d7mod2[[2]]<-lmer(d7m~I(yreldat^2)+yfch+ybch+ysch+(1|year), data=fitndiet1213,REML = FALSE) d7mod2[[3]]<-lmer(d7m~I(yreldat^2)+yfch+ybch+(1|year), data=fitndiet1213,REML = FALSE) d7mod2[[4]]<-lmer(d7m~I(yreldat^2)+yfch+ysch+(1|year), data=fitndiet1213,REML = FALSE) d7mod2[[5]]<-lmer(d7m~I(yreldat^2)+ybch+ysch+(1|year), data=fitndiet1213,REML = FALSE) d7mod2[[6]]<-lmer(d7m~I(yreldat^2)+yfch+(1|year), data=fitndiet1213,REML = FALSE) d7mod2[[7]]<-lmer(d7m~I(yreldat^2)+ybch+(1|year), data=fitndiet1213,REML = FALSE) d7mod2[[8]]<-lmer(d7m~I(yreldat^2)+ysch+(1|year), data=fitndiet1213,REML = FALSE) aictab(cand.set = d7mod2) summary(d7mod2[[1]]) d12mod<-list() d12mod[[1]]<-lmer(d12m~1+(1|year), data=fitndiet1213,REML = FALSE) d12mod[[2]]<-lmer(d12m~hdat+(1|year), data=fitndiet1213,REML = FALSE) d12mod[[3]]<-lmer(d12m~I(hdat^2)+(1|year), data=fitndiet1213,REML = FALSE) d12mod[[4]]<-lmer(d12m~I(hdat^2)+hdat+(1|year), data=fitndiet1213,REML = FALSE) d12mod[[5]]<-lmer(d12m~oreldat+(1|year), data=fitndiet1213,REML = FALSE) d12mod[[6]]<-lmer(d12m~I(oreldat^2)+(1|year), data=fitndiet1213,REML = FALSE) d12mod[[7]]<-lmer(d12m~I(oreldat^2)+oreldat+(1|year), data=fitndiet1213,REML = FALSE) d12mod[[8]]<-lmer(d12m~hab+(1|year), data=fitndiet1213,REML = FALSE) d12mod[[9]]<-lmer(d12m~ylch+(1|year), data=fitndiet1213,REML = FALSE) d12mod[[10]]<-lmer(d12m~olch+(1|year), data=fitndiet1213,REML = FALSE) d12mod[[11]]<-lmer(d12m~I(hdat^2)+olch+(1|year), data=fitndiet1213,REML = FALSE) d12mod[[12]]<-lmer(d12m~I(hdat^2)+hab+(1|year), data=fitndiet1213,REML = FALSE) d12mod[[13]]<-lmer(d12m~I(hdat^2)+ylch+(1|year), data=fitndiet1213,REML = FALSE) summary(d12mod[[10]]) aictab(cand.set = d12mod) d12mod2<-list() d12mod2[[1]]<-lmer(d12m~1+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[2]]<-lmer(d12m~yfch+ybch+ysch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[3]]<-lmer(d12m~yfch+ybch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[4]]<-lmer(d12m~yfch+ysch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[5]]<-lmer(d12m~ybch+ysch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[6]]<-lmer(d12m~yfch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[7]]<-lmer(d12m~ybch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[8]]<-lmer(d12m~ysch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[9]]<-lmer(d12m~ofch+obch+osch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[10]]<-lmer(d12m~ofch+obch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[11]]<-lmer(d12m~ofch+osch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[12]]<-lmer(d12m~obch+osch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[13]]<-lmer(d12m~ofch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[14]]<-lmer(d12m~obch+(1|year), data=fitndiet1213,REML = FALSE) d12mod2[[15]]<-lmer(d12m~osch+(1|year), data=fitndiet1213,REML = FALSE) aictab(cand.set = d12mod2) summary(d12mod2[[13]]) d12tmod<-list() d12tmod[[1]]<-lmer(d12t~1+(1|year), data=fitndiet1213,REML = FALSE) d12tmod[[2]]<-lmer(d12t~hdat+(1|year), data=fitndiet1213,REML = FALSE) d12tmod[[3]]<-lmer(d12t~I(hdat^2)+(1|year), data=fitndiet1213,REML = FALSE) d12tmod[[4]]<-lmer(d12t~I(hdat^2)+hdat+(1|year), data=fitndiet1213,REML = FALSE) d12tmod[[5]]<-lmer(d12t~oreldat+(1|year), data=fitndiet1213,REML = FALSE) d12tmod[[6]]<-lmer(d12t~I(oreldat^2)+(1|year), data=fitndiet1213,REML = FALSE) d12tmod[[7]]<-lmer(d12t~I(oreldat^2)+oreldat+(1|year), data=fitndiet1213,REML = FALSE) d12tmod[[8]]<-lmer(d12t~hab+(1|year), data=fitndiet1213,REML = FALSE) d12tmod[[9]]<-lmer(d12t~ylch+(1|year), data=fitndiet1213,REML = FALSE) d12tmod[[10]]<-lmer(d12t~olch+(1|year), data=fitndiet1213,REML = FALSE) d12tmod[[11]]<-lmer(d12t~I(hdat^2)+olch+(1|year), data=fitndiet1213,REML = FALSE) d12tmod[[12]]<-lmer(d12t~I(hdat^2)+hab+(1|year), data=fitndiet1213,REML = FALSE) d12tmod[[13]]<-lmer(d12t~I(hdat^2)+ylch+(1|year), data=fitndiet1213,REML = FALSE) aictab(cand.set = d12tmod) summary(d12tmod[[6]]) d12tmod2<-list() d12tmod2[[1]]<-lmer(d12t~I(oreldat^2)+tarp+(1|year), na.action=na.exclude, data=fitndiet1213,REML = FALSE) d12tmod2[[2]]<-lmer(d12t~I(oreldat^2)+yfch+ybch+ysch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[3]]<-lmer(d12t~I(oreldat^2)+yfch+ybch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[4]]<-lmer(d12t~I(oreldat^2)+yfch+ysch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[5]]<-lmer(d12t~I(oreldat^2)+ybch+ysch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[6]]<-lmer(d12t~I(oreldat^2)+yfch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[7]]<-lmer(d12t~I(oreldat^2)+ybch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[8]]<-lmer(d12t~I(oreldat^2)+ysch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[9]]<-lmer(d12t~I(oreldat^2)+ofch+obch+osch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[10]]<-lmer(d12t~I(oreldat^2)+ofch+obch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[11]]<-lmer(d12t~I(oreldat^2)+ofch+osch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[12]]<-lmer(d12t~I(oreldat^2)+obch+osch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[13]]<-lmer(d12t~I(oreldat^2)+ofch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[14]]<-lmer(d12t~I(oreldat^2)+obch+tarp+(1|year), data=fitndiet1213,REML = FALSE) d12tmod2[[15]]<-lmer(d12t~I(oreldat^2)+osch+tarp+(1|year), data=fitndiet1213,REML = FALSE) aictab(cand.set = d12tmod2) summary(d12tmod2[[8]]) fitndiet1213$restar14<-resid(d12tmod2[[1]]) d12p3mod<-list() d12p3mod[[1]]<-lmer(d12p3~1+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod[[2]]<-lmer(d12p3~hdat+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod[[3]]<-lmer(d12p3~I(hdat^2)+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod[[4]]<-lmer(d12p3~I(hdat^2)+hdat+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod[[5]]<-lmer(d12p3~oreldat+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod[[6]]<-lmer(d12p3~I(oreldat^2)+(1|year),na.action=na.exclude, data=fitndiet1213,REML = FALSE) d12p3mod[[7]]<-lmer(d12p3~I(oreldat^2)+oreldat+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod[[8]]<-lmer(d12p3~hab+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod[[9]]<-lmer(d12p3~ylch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod[[10]]<-lmer(d12p3~olch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod[[11]]<-lmer(d12p3~I(hdat^2)+olch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod[[12]]<-lmer(d12p3~I(hdat^2)+hab+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod[[13]]<-lmer(d12p3~I(hdat^2)+ylch+(1|year), data=fitndiet1213,REML = FALSE) aictab(cand.set = d12p3mod) d12p3mod2<-list() d12p3mod2[[1]]<-lmer(d12p3~I(oreldat^2)+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[2]]<-lmer(d12p3~I(oreldat^2)+yfch+ybch+ysch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[3]]<-lmer(d12p3~I(oreldat^2)+yfch+ybch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[4]]<-lmer(d12p3~I(oreldat^2)+yfch+ysch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[5]]<-lmer(d12p3~I(oreldat^2)+ybch+ysch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[6]]<-lmer(d12p3~I(oreldat^2)+yfch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[7]]<-lmer(d12p3~I(oreldat^2)+ybch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[8]]<-lmer(d12p3~I(oreldat^2)+ysch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[9]]<-lmer(d12p3~I(oreldat^2)+ofch+obch+osch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[10]]<-lmer(d12p3~I(oreldat^2)+ofch+obch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[11]]<-lmer(d12p3~I(oreldat^2)+ofch+osch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[12]]<-lmer(d12p3~I(oreldat^2)+obch+osch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[13]]<-lmer(d12p3~I(oreldat^2)+ofch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[14]]<-lmer(d12p3~I(oreldat^2)+obch+(1|year), data=fitndiet1213,REML = FALSE) d12p3mod2[[15]]<-lmer(d12p3~I(oreldat^2)+osch+(1|year), data=fitndiet1213,REML = FALSE) aictab(cand.set = d12p3mod2) summary(d12p3mod2[[1]]) fitndiet1213$resp3<-resid(d12p3mod2[[1]]) ############################################################################################# ################################################################# BEST MODELS ###################################### BEST MODELS ########### BEST MODELS d7mbest<-glm(d7m~I(yreldat^2), data=fitndiet1213,REML = FALSE) summary(d7mbest) d12mbest<-glm(d12m~ofch, data=fitndiet1213,REML = FALSE) summary(d12mbest) d12tbest<-glm(d12t~I(oreldat^2)+ysch+tarp, data=fitndiet1213,REML = FALSE) summary(d12tbest) d12p3best<-glm(d12p3~I(oreldat^2)+ofch, data=fitndiet1213,REML = FALSE) summary(d12p3best) ################################# #feeding rates ################################# feed<-read.table("feeding1213.csv",header=T,sep=";", dec=",") feed$year<-as.factor(feed$year) summarySE(feed,measurevar="hba") #.id N hba sd se ci #1 116 54.3634 33.06542 3.070048 6.081173 feed$hab<-(feed$hba-54.3634)/33.06542 summarySE(feed, measurevar="reldate") #.id N reldate sd se ci #1 116 4.666326 5.151068 0.4782646 0.9473502 feed$dat<-(feed$reldate-4.666326)/5.151068 larvs<-list() larvs[[1]]<-lmer(olarvchickhour~1+(1|box), data=feed, REML = FALSE) larvs[[2]]<-lmer(olarvchickhour~year+(1|box), data=feed, REML = FALSE) larvs[[3]]<-lmer(olarvchickhour~dat+year+(1|box), data=feed, REML = FALSE) larvs[[4]]<-lmer(olarvchickhour~dat+I(dat^2)+year+(1|box), data=feed, REML = FALSE) larvs[[5]]<-lmer(olarvchickhour~dat+age+year+(1|box), data=feed, REML = FALSE) larvs[[6]]<-lmer(olarvchickhour~dat+hab+year+(1|box), data=feed, REML = FALSE) larvs[[7]]<-lmer(olarvchickhour~dat+age+hab+year+(1|box), data=feed, REML = FALSE) larvs[[8]]<-lmer(olarvchickhour~age+year+(1|box), data=feed, REML = FALSE) larvs[[9]]<-lmer(olarvchickhour~age+hab+year+(1|box), data=feed, REML = FALSE) larvs[[10]]<-lmer(olarvchickhour~hab+year+(1|box), data=feed, REML = FALSE) larvs[[11]]<-lmer(olarvchickhour~dat+I(dat^2)+age+year+(1|box), data=feed, REML = FALSE) larvs[[12]]<-lmer(olarvchickhour~dat+I(dat^2)+hab+year+(1|box), data=feed, REML = FALSE) larvs[[13]]<-lmer(olarvchickhour~dat+I(dat^2)+age+hab+year+(1|box), data=feed, REML = FALSE) larvs[[14]]<-lmer(olarvchickhour~dat*hab+year+(1|box), data=feed, REML = FALSE) larvs[[15]]<-lmer(olarvchickhour~I(dat^2)+dat*hab+year+(1|box), data=feed, REML = FALSE) larvs[[16]]<-lmer(olarvchickhour~dat*hab+age+year+(1|box), data=feed, REML = FALSE) larvs[[17]]<-lmer(olarvchickhour~dat*age+year+(1|box), data=feed, REML = FALSE) larvs[[18]]<-lmer(olarvchickhour~dat*age+hab+year+(1|box), data=feed, REML = FALSE) larvs[[19]]<-lmer(olarvchickhour~dat*age+I(dat^2)+year+(1|box), data=feed, REML = FALSE) larvs[[20]]<-lmer(olarvchickhour~hab+I(dat^2)*age+(1|box), data=feed, REML = FALSE) larvs[[21]]<-lmer(olarvchickhour~I(dat^2)*age+hab+year+(1|box), data=feed, REML = FALSE) larvs[[22]]<-lmer(olarvchickhour~I(dat^2)*hab+dat+age+year+(1|box), data=feed, REML = FALSE) larvs[[23]]<-lmer(olarvchickhour~I(dat^2)*age+dat+year+(1|box), data=feed, REML = FALSE) larvs[[24]]<-lmer(olarvchickhour~hab+I(dat^2)+age+(1|box), data=feed, REML = FALSE) larvs[[25]]<-lmer(olarvchickhour~I(dat^2)*hab+age+year+(1|box), data=feed, REML = FALSE) aictab(cand.set = larvs) summary(larvs[[24]]) flies<-list() flies[[1]]<-lmer(oflyychickhour~1+(1|box), data=feed, REML = FALSE) flies[[2]]<-lmer(oflyychickhour~year+(1|box), data=feed, REML = FALSE) flies[[3]]<-lmer(oflyychickhour~dat+year+(1|box), data=feed, REML = FALSE) flies[[4]]<-lmer(oflyychickhour~dat+I(dat^2)+year+(1|box), data=feed, REML = FALSE) flies[[5]]<-lmer(oflyychickhour~dat+age+year+(1|box), data=feed, REML = FALSE) flies[[6]]<-lmer(oflyychickhour~dat+hab+year+(1|box), data=feed, REML = FALSE) flies[[7]]<-lmer(oflyychickhour~dat+age+hab+year+(1|box), data=feed, REML = FALSE) flies[[8]]<-lmer(oflyychickhour~age+year+(1|box), data=feed, REML = FALSE) flies[[9]]<-lmer(oflyychickhour~age+hab+year+(1|box), data=feed, REML = FALSE) flies[[10]]<-lmer(oflyychickhour~hab+year+(1|box), data=feed, REML = FALSE) flies[[11]]<-lmer(oflyychickhour~dat+I(dat^2)+age+year+(1|box), data=feed, REML = FALSE) flies[[12]]<-lmer(oflyychickhour~dat+I(dat^2)+hab+year+(1|box), data=feed, REML = FALSE) flies[[13]]<-lmer(oflyychickhour~dat+I(dat^2)+age+hab+year+(1|box), data=feed, REML = FALSE) flies[[14]]<-lmer(oflyychickhour~dat*hab+year+(1|box), data=feed, REML = FALSE) flies[[15]]<-lmer(oflyychickhour~I(dat^2)+dat*hab+year+(1|box), data=feed, REML = FALSE) flies[[16]]<-lmer(oflyychickhour~dat*hab+age+year+(1|box), data=feed, REML = FALSE) flies[[17]]<-lmer(oflyychickhour~dat*age+year+(1|box), data=feed, REML = FALSE) flies[[18]]<-lmer(oflyychickhour~dat*age+hab+year+(1|box), data=feed, REML = FALSE) flies[[19]]<-lmer(oflyychickhour~dat*age+I(dat^2)+year+(1|box), data=feed, REML = FALSE) flies[[20]]<-lmer(oflyychickhour~hab+I(dat^2)*age+(1|box), data=feed, REML = FALSE) flies[[21]]<-lmer(oflyychickhour~I(dat^2)*age+hab+year+(1|box), data=feed, REML = FALSE) flies[[22]]<-lmer(oflyychickhour~I(dat^2)*hab+dat+age+year+(1|box), data=feed, REML = FALSE) flies[[23]]<-lmer(oflyychickhour~I(dat^2)*age+dat+year+(1|box), data=feed, REML = FALSE) flies[[24]]<-lmer(oflyychickhour~hab+I(dat^2)+age+(1|box), data=feed, REML = FALSE) flies[[25]]<-lmer(oflyychickhour~I(dat^2)*hab+age+year+(1|box), data=feed, REML = FALSE) aictab(cand.set = flies) summary(flies[[12]]) spiders<-list() spiders[[1]]<-lmer(ospidchickhour~1+(1|box), data=feed, REML = FALSE) spiders[[2]]<-lmer(ospidchickhour~year+(1|box), data=feed, REML = FALSE) spiders[[3]]<-lmer(ospidchickhour~dat+year+(1|box), data=feed, REML = FALSE) spiders[[4]]<-lmer(ospidchickhour~dat+I(dat^2)+year+(1|box), data=feed, REML = FALSE) spiders[[5]]<-lmer(ospidchickhour~dat+age+year+(1|box), data=feed, REML = FALSE) spiders[[6]]<-lmer(ospidchickhour~dat+hab+year+(1|box), data=feed, REML = FALSE) spiders[[7]]<-lmer(ospidchickhour~dat+age+hab+year+(1|box), data=feed, REML = FALSE) spiders[[8]]<-lmer(ospidchickhour~age+year+(1|box), data=feed, REML = FALSE) spiders[[9]]<-lmer(ospidchickhour~age+hab+year+(1|box), data=feed, REML = FALSE) spiders[[10]]<-lmer(ospidchickhour~hab+year+(1|box), data=feed, REML = FALSE) spiders[[11]]<-lmer(ospidchickhour~dat+I(dat^2)+age+year+(1|box), data=feed, REML = FALSE) spiders[[12]]<-lmer(ospidchickhour~dat+I(dat^2)+hab+year+(1|box), data=feed, REML = FALSE) spiders[[13]]<-lmer(ospidchickhour~dat+I(dat^2)+age+hab+year+(1|box), data=feed, REML = FALSE) spiders[[14]]<-lmer(ospidchickhour~dat*hab+year+(1|box), data=feed, REML = FALSE) spiders[[15]]<-lmer(ospidchickhour~I(dat^2)+dat*hab+year+(1|box), data=feed, REML = FALSE) spiders[[16]]<-lmer(ospidchickhour~dat*hab+age+year+(1|box), data=feed, REML = FALSE) spiders[[17]]<-lmer(ospidchickhour~dat*age+year+(1|box), data=feed, REML = FALSE) spiders[[18]]<-lmer(ospidchickhour~dat*age+hab+year+(1|box), data=feed, REML = FALSE) spiders[[19]]<-lmer(ospidchickhour~dat*age+I(dat^2)+year+(1|box), data=feed, REML = FALSE) spiders[[20]]<-lmer(ospidchickhour~hab+I(dat^2)*age+(1|box), data=feed, REML = FALSE) spiders[[21]]<-lmer(ospidchickhour~I(dat^2)*age+hab+year+(1|box), data=feed, REML = FALSE) spiders[[22]]<-lmer(ospidchickhour~I(dat^2)*hab+dat+age+year+(1|box), data=feed, REML = FALSE) spiders[[23]]<-lmer(ospidchickhour~I(dat^2)*age+dat+year+(1|box), data=feed, REML = FALSE) spiders[[24]]<-lmer(ospidchickhour~hab+I(dat^2)+age+(1|box), data=feed, REML = FALSE) spiders[[25]]<-lmer(ospidchickhour~I(dat^2)*hab+age+year+(1|box), data=feed, REML = FALSE) aictab(cand.set = spiders) summary(spiders[[25]]) beetles<-list() beetles[[1]]<-lmer(obeetlchickhour~1+(1|box), data=feed, REML = FALSE) beetles[[2]]<-lmer(obeetlchickhour~year+(1|box), data=feed, REML = FALSE) beetles[[3]]<-lmer(obeetlchickhour~dat+year+(1|box), data=feed, REML = FALSE) beetles[[4]]<-lmer(obeetlchickhour~dat+I(dat^2)+year+(1|box), data=feed, REML = FALSE) beetles[[5]]<-lmer(obeetlchickhour~dat+age+year+(1|box), data=feed, REML = FALSE) beetles[[6]]<-lmer(obeetlchickhour~dat+hab+year+(1|box), data=feed, REML = FALSE) beetles[[7]]<-lmer(obeetlchickhour~dat+age+hab+year+(1|box), data=feed, REML = FALSE) beetles[[8]]<-lmer(obeetlchickhour~age+year+(1|box), data=feed, REML = FALSE) beetles[[9]]<-lmer(obeetlchickhour~age+hab+year+(1|box), data=feed, REML = FALSE) beetles[[10]]<-lmer(obeetlchickhour~hab+year+(1|box), data=feed, REML = FALSE) beetles[[11]]<-lmer(obeetlchickhour~dat+I(dat^2)+age+year+(1|box), data=feed, REML = FALSE) beetles[[12]]<-lmer(obeetlchickhour~dat+I(dat^2)+hab+year+(1|box), data=feed, REML = FALSE) beetles[[13]]<-lmer(obeetlchickhour~dat+I(dat^2)+age+hab+year+(1|box), data=feed, REML = FALSE) beetles[[14]]<-lmer(obeetlchickhour~dat*hab+year+(1|box), data=feed, REML = FALSE) beetles[[15]]<-lmer(obeetlchickhour~I(dat^2)+dat*hab+year+(1|box), data=feed, REML = FALSE) beetles[[16]]<-lmer(obeetlchickhour~dat*hab+age+year+(1|box), data=feed, REML = FALSE) beetles[[17]]<-lmer(obeetlchickhour~dat*age+year+(1|box), data=feed, REML = FALSE) beetles[[18]]<-lmer(obeetlchickhour~dat*age+hab+year+(1|box), data=feed, REML = FALSE) beetles[[19]]<-lmer(obeetlchickhour~dat*age+I(dat^2)+year+(1|box), data=feed, REML = FALSE) beetles[[20]]<-lmer(obeetlchickhour~hab+I(dat^2)*age+(1|box), data=feed, REML = FALSE) beetles[[21]]<-lmer(obeetlchickhour~I(dat^2)*age+hab+year+(1|box), data=feed, REML = FALSE) beetles[[22]]<-lmer(obeetlchickhour~I(dat^2)*hab+dat+age+year+(1|box), data=feed, REML = FALSE) beetles[[23]]<-lmer(obeetlchickhour~I(dat^2)*age+dat+year+(1|box), data=feed, REML = FALSE) beetles[[24]]<-lmer(obeetlchickhour~hab+I(dat^2)+age+(1|box), data=feed, REML = FALSE) beetles[[25]]<-lmer(obeetlchickhour~I(dat^2)*hab+age+year+(1|box), data=feed, REML = FALSE) aictab(cand.set = beetles) summary(beetles[[18]]) totalfeed<-list() totalfeed[[1]]<-lmer(ototchickhour~1+(1|box), data=feed, REML = FALSE) totalfeed[[2]]<-lmer(ototchickhour~year+(1|box), data=feed, REML = FALSE) totalfeed[[3]]<-lmer(ototchickhour~dat+year+(1|box), data=feed, REML = FALSE) totalfeed[[4]]<-lmer(ototchickhour~dat+I(dat^2)+year+(1|box), data=feed, REML = FALSE) totalfeed[[5]]<-lmer(ototchickhour~dat+age+year+(1|box), data=feed, REML = FALSE) totalfeed[[6]]<-lmer(ototchickhour~dat+hab+year+(1|box), data=feed, REML = FALSE) totalfeed[[7]]<-lmer(ototchickhour~dat+age+hab+year+(1|box), data=feed, REML = FALSE) totalfeed[[8]]<-lmer(ototchickhour~age+year+(1|box), data=feed, REML = FALSE) totalfeed[[9]]<-lmer(ototchickhour~age+hab+year+(1|box), data=feed, REML = FALSE) totalfeed[[10]]<-lmer(ototchickhour~hab+year+(1|box), data=feed, REML = FALSE) totalfeed[[11]]<-lmer(ototchickhour~dat+I(dat^2)+age+year+(1|box), data=feed, REML = FALSE) totalfeed[[12]]<-lmer(ototchickhour~dat+I(dat^2)+hab+year+(1|box), data=feed, REML = FALSE) totalfeed[[13]]<-lmer(ototchickhour~dat+I(dat^2)+age+hab+year+(1|box), data=feed, REML = FALSE) totalfeed[[14]]<-lmer(ototchickhour~dat*hab+year+(1|box), data=feed, REML = FALSE) totalfeed[[15]]<-lmer(ototchickhour~I(dat^2)+dat*hab+year+(1|box), data=feed, REML = FALSE) totalfeed[[16]]<-lmer(ototchickhour~dat*hab+age+year+(1|box), data=feed, REML = FALSE) totalfeed[[17]]<-lmer(ototchickhour~dat*age+year+(1|box), data=feed, REML = FALSE) totalfeed[[18]]<-lmer(ototchickhour~dat*age+hab+year+(1|box), data=feed, REML = FALSE) totalfeed[[19]]<-lmer(ototchickhour~dat*age+I(dat^2)+year+(1|box), data=feed, REML = FALSE) totalfeed[[20]]<-lmer(ototchickhour~hab+I(dat^2)*age+(1|box), data=feed, REML = FALSE) totalfeed[[21]]<-lmer(ototchickhour~I(dat^2)*age+hab+year+(1|box), data=feed, REML = FALSE) totalfeed[[22]]<-lmer(ototchickhour~I(dat^2)*hab+dat+age+year+(1|box), data=feed, REML = FALSE) totalfeed[[23]]<-lmer(ototchickhour~I(dat^2)*age+dat+year+(1|box), data=feed, REML = FALSE) totalfeed[[24]]<-lmer(ototchickhour~hab+I(dat^2)+age+(1|box), data=feed, REML = FALSE) totalfeed[[25]]<-lmer(ototchickhour~I(dat^2)*hab+age+year+(1|box), data=feed, REML = FALSE) aictab(cand.set = totalfeed) summary(totalfeed[[8]]) theme_under<- theme(axis.title.x=element_blank(), axis.title.y=element_text(size=16),axis.line = element_line(colour = "black"), panel.grid.major = element_blank(),panel.grid.minor = element_blank(), panel.background = element_rect(colour="transparent",fill=NA), panel.border=element_rect(fill = NA, colour="black"), plot.background = element_rect(fill = "transparent",colour = NA),legend.background = element_blank(), legend.title=element_blank(),legend.text=element_text(size=14),legend.justification=c(1,1.1), legend.position="none", legend.key = element_rect(fill=alpha('black', 0.2), linetype=0), axis.text.x = element_text(colour="black",angle=0, vjust=0.5, size=16),axis.ticks=element_line(colour = "black"), axis.ticks.length = unit(-0.15, "cm"), axis.ticks.margin=unit(0.5, "cm"), axis.text.y = element_text(colour="black",angle=0, vjust=0.5, size=16), plot.title=element_text(face="bold", size=0)) theme_middle<-theme(axis.title.x=element_blank(), axis.title.y=element_text(size=16),axis.line = element_line(colour = "black"),panel.grid.major = element_blank(),panel.grid.minor = element_blank(), panel.background = element_rect(colour="transparent",fill=NA), panel.border=element_rect(fill = NA, colour="black"), plot.background = element_rect(fill = "transparent",colour = NA), legend.key = element_rect(fill = NA, colour = NA, size = 0.25), legend.title=element_text(size=15),legend.text=element_text(size=15),legend.justification=c(1,0), legend.position="none", legend.background = element_rect(fill = "transparent"), axis.ticks.length = unit(-0.15, "cm"), axis.ticks.margin=unit(0.5, "cm"), axis.text.x = element_text(colour="black",angle=0, vjust=0.5, size=0),axis.ticks.y=element_line(colour = "black"), axis.text.y = element_text(colour="black",angle=0, vjust=0.5, size=16),axis.ticks.x=element_blank(), plot.title=element_text(face="bold", size=0)) theme_upper<- theme(axis.title.x=element_blank(), axis.title.y=element_text(size=16), axis.line = element_line(colour = "black"),panel.grid.major = element_blank(),panel.grid.minor = element_blank(), panel.background = element_rect(colour="transparent",fill=NA), panel.border=element_rect(fill = NA, colour="black"), plot.background = element_rect(fill = "transparent",colour = NA),legend.background = element_blank(), legend.title=element_blank(),legend.text=element_text(size=14),legend.justification=c(1,1.1), legend.position=c(1,1.1), legend.key = element_rect(colour="black", linetype=3), axis.text.x = element_blank(),axis.ticks=element_line(colour = "black"), axis.ticks.length = unit(-0.15, "cm"), axis.ticks.margin=unit(0.5, "cm"), axis.text.y = element_text(colour="black",angle=0, vjust=0.5, size=16), plot.title=element_text(face="bold", size=0)) newdata2<-data.frame(reldate=seq(from=-15, to=6, length.out=100),yreldat=seq(from=(-15+2.542373)/4.598808, to=(6+2.542373)/4.598808, length.out=100), oreldat=seq(from=(-15+2.555556)/4.729142, to=(6+2.555556)/4.729142, length.out=100), oflyychickhour=seq(from=.23, to=3.922, length.out=100), ofch=seq(from=(.23-1.270377)/0.8924393, to=(3.922-1.270377)/0.8924393, length.out=100), ylarvchickhour=seq(from=0.248, to=7.344, length.out=100), ylch=seq(from=(0.248-3.300661)/1.576669, to=(7.344-3.300661)/1.576669, length.out=100), yspidchickhour=seq(from=0, to=2.918, length.out=100), ysch=seq(from=(0-0.9015763)/0.7430985, to=(2.918-0.9015763)/0.7430985, length.out=100)) pd <- position_jitterdodge(jitter.width=.3, dodge.width=.5) pd2<-position_jitterdodge(jitter.width=.4, dodge.width=1.2) palet<-c("black","grey50") #d7 mass day7m<-(11.63)+(-.354*(newdata2$yreldat)^2) newdata2$day7m<-day7m day7mass<- ggplot(fitndiet1213, aes(x=yreldate, y=d7m))+ geom_point(size=3,position=pd,aes(colour=factor(year), fill=factor(year)))+ geom_line(data=newdata2, aes(x=reldate, y=day7m), size=1,linetype=1, colour="black")+ scale_colour_manual(values=palet)+ #theme_bw()+ theme_upper+ylab("Day 7 mass (grams)")+theme(legend.position="none")+ scale_colour_manual(breaks=c("2012", "2013"),labels=c("2012", "2013"), values=palet)+ scale_fill_discrete(breaks=c("2012", "2013"),labels=c("2012", "2013"))+ guides(colour = guide_legend(override.aes = list(size=3)))+ scale_x_continuous(limits=c(-16,7), breaks=-16:7*5)+ scale_y_continuous(limits=c(6,14), breaks=2:20*2)+ # geom_text(data=NULL, label="Day 7 mass",x=-16.7,y=15, hjust=0, size=6)+ geom_text(data=NULL,label="(a)",x=-4.5,y=13.8,size=6) #day7mass<-ggdraw(switch_axis_position(day7mass, axis = 'x')) #print(day7mass) day12mass<- ggplot(fitndiet1213, aes(x=oreldate, y=d12m))+ geom_point(size=3,position=pd,aes(colour=factor(year), fill=factor(year)))+ scale_colour_manual(values=palet)+ #theme_bw()+ theme_upper+ylab("Day 12 mass (grams)")+theme(legend.justification=c(0,1.05), legend.position=c(0,1.05))+ scale_x_continuous(limits=c(-16,7), breaks=-16:7*5)+ scale_y_continuous(limits=c(10,16), breaks=2:20*2)+ # geom_text(data=NULL, label="Day 7 mass",x=-16.7,y=15, hjust=0, size=6)+ geom_text(data=NULL,label="(b)",x=-4.5,y=15.8,size=6) #day12mass<-ggdraw(switch_axis_position(day12mass, axis = 'xy')) #print(day12mass) #day 12 tarsus hatch date day12t<-(17.37)+(-.091*(newdata2$oreldat)^2) newdata2$day12t<-day12t day12t<- ggplot(fitndiet1213, aes(x=oreldate, y=d12t))+ geom_point(size=3,position=pd,aes(colour=factor(year), fill=factor(year)))+ geom_line(data=newdata2, aes(x=reldate, y=day12t), size=1,linetype=1, colour="black")+ scale_colour_manual(values=palet)+ #theme_bw()+ theme_under+ylab("Tarsus length (mm)")+ scale_size(range = c(2, 5), guide="none")+ scale_x_continuous(limits=c(-16,7), breaks=-16:7*5)+ scale_y_continuous(limits=c(16,18.2), breaks=16:18*1)+ # geom_text(data=NULL, label="Day 12 p3",x=-16.7,y=4, hjust=0, size=6)+ geom_text(data=NULL,label="(c)",x=-4.5,y=18.15,size=6) #day12p3<-ggdraw(switch_axis_position(day12p3, axis = 'x')) #png(filename="caterpillar_age.png",type="cairo",width=8,height=6,units="in",bg = "transparent",pointsize=12,res=384) #print(day12t) #day 12 p3 day12p3<-(28.81)+(-.852*(newdata2$oreldat)^2) newdata2$day12p3<-day12p3 day12p3<- ggplot(fitndiet1213, aes(x=oreldate, y=d12p3))+ geom_point(size=3,position=pd,aes(colour=factor(year), fill=factor(year)))+ geom_line(data=newdata2, aes(x=reldate, y=day12p3), size=1,linetype=1, colour="black")+ scale_colour_manual(values=palet)+ #theme_bw()+ theme_under+ylab("Day 12 F8 length (mm)")+ scale_x_continuous(limits=c(-16,7), breaks=-16:7*5)+ scale_y_continuous(limits=c(18,34), breaks=c(18,23,28,33))+ # geom_text(data=NULL, label="Day 12 p3",x=-16.7,y=4, hjust=0, size=6)+ geom_text(data=NULL,label="(d)",x=-4.5,y=33.6,size=6) #day12p3<-ggdraw(switch_axis_position(day12p3, axis = 'y')) #png(filename="caterpillar_age.png",type="cairo",width=8,height=6,units="in",bg = "transparent",pointsize=12,res=384) #print(day12p3) require(cowplot) fitnessmismatch<-ggdraw()+ draw_plot(day7mass, 0, .5, .5, .5) + draw_plot(day12mass, .5, .5, .5, .5) + draw_plot(day12t, 0, .04, .5, .5) + draw_plot(day12p3, .5, .04, .5, .5)+ draw_text("Hatch day relative to caterpillar peak", x = 0.515, y = 0.03, size = 20, fontface = "bold",angle=0) ggsave(fitnessmismatch, file="fitnessmismatch.eps",width=26,height=26*3/4, units="cm") png(filename="fitnessmismatch.png",type="windows",width=10,height=7.5,units="in",bg = "transparent",pointsize=12,res=720) print(fitnessmismatch) dev.off() #Residual tarsus by young spider feeding rate restarspid<- ggplot(fitndiet1213, aes(x=yspidchickhour, y=restar14))+ geom_point(position=pd,aes(size=yNtotspid, colour=factor(year), fill=factor(year)))+ stat_smooth(method = "lm", formula = y ~ x, se = F,colour="black",size=1,linetype=1)+ scale_colour_manual(values=palet)+ #theme_bw()+ theme_under+ylab("Res tarsus length (mm)")+xlab("# spiders/chick/hour age 4-6d")+ theme(axis.title.x=element_text(size=16))+ scale_size(range = c(2, 4), guide="none")+ scale_x_continuous(limits=c(-.1,3), breaks=0:6*.5)+ scale_y_continuous(limits=c(-1.2,.8), breaks=-3:5*0.4)+ geom_text(data=NULL,label="(a)",x=1.5,y=.8,size=6) #print(restarspid) #Residual p3 by flying insects #resp3fly<- # ggplot(fitndiet1213, aes(x=oflyychickhour, y=resp3))+ # geom_point(position=pd,aes(size=oNtotfly, colour=factor(year), fill=factor(year)))+ # stat_smooth(method = "lm", formula = y ~ x, se = F,colour="black",size=1,linetype=2)+ # scale_colour_manual(values=palet)+ # #theme_bw()+ # theme_under+ylab("Res F8 length (mm)")+xlab("# flying insects/chick/hour age 9-12d")+ # theme(axis.title.x=element_text(size=16))+ # scale_size(range = c(2, 4), guide="none")+ # scale_x_continuous(limits=c(0,4), breaks=0:4*1)+ scale_y_continuous(limits=c(-7,6), breaks=-7:6*2)+ geom_text(data=NULL,label="(c)",x=2,y=6,size=6) # print(resp3fly) #Day 12 mass by flying insects d12mfly<- ggplot(fitndiet1213, aes(x=oflyychickhour, y=d12m))+ geom_point(position=pd,aes(size=oNtotfly, colour=factor(year), fill=factor(year)))+ stat_smooth(method = "lm", formula = y ~ x, se = F,colour="black",size=1,linetype=1)+ scale_colour_manual(values=palet)+ scale_colour_manual(breaks=c("2012", "2013"),labels=c("2012", "2013"), values=palet)+ scale_fill_discrete(breaks=c("2012", "2013"),labels=c("2012", "2013"))+ guides(colour = guide_legend(override.aes = list(size=3)))+ #theme_bw()+ theme_under+ylab("Day 12 mass (g)")+xlab("# flying insects/chick/hour age 9-12d")+ theme(axis.title.x=element_text(size=16))+ scale_size(range = c(2, 4), guide="none")+ scale_x_continuous(limits=c(0,4), breaks=0:4*1)+ scale_y_continuous(limits=c(10,16), breaks=2:20*2)+ geom_text(data=NULL,label="(b)",x=2,y=16,size=6) #d12mfly<-ggdraw(switch_axis_position(d12mfly, axis = 'x')) #print(d12mfly) require(cowplot) fitnessfeeding<- plot_grid(restarspid, d12mfly, nrow = 2) ggsave(fitnessfeeding, file="fitnessfeeding.eps",width=13,height=19.5, units="cm") png(filename="fitnessfeeding.png",type="windows",width=6,height=12,units="in",bg = "transparent",pointsize=12,res=720) print(fitnessfeeding) dev.off()