Win-stay, lose-switch and public information strategies for patch-fidelity of a songbird with rare extra-pair paternity Andrew J. Campomizzi, Department of Wildlife and Fisheries Sciences, Texas A&M University, College Station, TX, 77843-2258, USA Michael L. Morrison, Department of Wildlife and Fisheries Sciences, Texas A&M University, College Station, TX, 77843-2258, USA J. Andrew DeWoody, Forestry and Natural Resources, Purdue University, West Lafayette, IN 47907-2033, USA Shannon L. Farrell, Department of Wildlife and Fisheries Sciences, Texas A&M University, College Station, TX, 77843-2258, USA R. Neal Wilkins, Institute of Renewable Natural Resources, Texas A&M University, College Station, TX, 77843-2260, USA Corresponding author: Andrew J. Campomizzi, 1500 Research Parkway, Suite 110, 2260 TAMU, College Station, TX 77843-2260, USA. Email: acampomizzi@tamu.edu, phone: 973.752.2390 R code for data analysis #analysis of white-eyed vireo patch fidelity #data were collected in oak-juniper woodland on 4 private ranches in coryell county, texas from #2008-2010 #set working directory setwd("D:/Publication/ScientificReports/SiteFidelity/Data/") #load data fidelity.data=read.table("wevi.paternity_2011.11.16.txt", header=TRUE, colClasses=c("factor", "factor", "numeric", "factor", "numeric")) #check data structure str(fidelity.data) #subset data #for males sub.m=subset(fidelity.data, fidelity.data$sex==0) str(sub.m) #for females sub.f=subset(fidelity.data, fidelity.data$sex==1) str(sub.f) ############################################################################## #calculate descriptive statistics #subset data for males showing patch fidelity sub.m.fidelity=subset(sub.m, sub.m$patch.fidelity==1) str(sub.m.fidelity) #calculate median number of offspring for males showing patch fidelity median(sub.m.fidelity$neighbor.fledglings) #4.0 median(sub.m.fidelity$personal.fledglings) #0.0 #subset data for males not showing patch fidelity sub.m.nofidelity=subset(sub.m, sub.m$patch.fidelity==0) str(sub.m.nofidelity) #calculate median number of offspring for males not showing patch fidelity median(sub.m.nofidelity$neighbor.fledglings) #4.0 median(sub.m.nofidelity$personal.fledglings) #0.0 #subset data for females showing patch fidelity sub.f.fidelity=subset(sub.f, sub.f$patch.fidelity==1) str(sub.f.fidelity) #calculate median number of offspring for females showing patch fidelity median(sub.f.fidelity$neighbor.fledglings) #4.0 median(sub.f.fidelity$personal.fledglings) #2.0 #subset data for females not showing patch fidelity sub.f.nofidelity=subset(sub.f, sub.f$patch.fidelity==0) str(sub.f.nofidelity) #calculate median number of offspring for females not showing patch fidelity median(sub.f.nofidelity$neighbor.fledglings) #2.5 median(sub.f.nofidelity$personal.fledglings) #0.5 ############################################################################## #exploratory plots #boxplot of number of offspring in adjacent territories and number with social mate for males #and females that did and did not show patch fidelity #plot males, number of adjacent offspring tiff("Fig1.tif", width = 7, height = 7, units = "in", bg = "white", compression = "lzw", res = 600) par(mfrow=c(2, 2)) boxplot(sub.m$neighbor.fledglings ~ sub.m$patch.fidelity, bty="l", las=1, col="gray", main="Male", ylim=c(0, 12), xlab="Patch fidelity", names = c("No", "Yes"), ylab="Number of adjacent offspring") #plot females number of offspring with a social mate boxplot(sub.f$neighbor.fledglings ~ sub.f$patch.fidelity, bty="l", las=1, col="gray", main="Female", ylim=c(0, 12), xlab="Patch fidelity", names = c("No", "Yes"), ylab="") #add title to top mtext("(a) Public information", side = 3, line=3, at=0, font=2) #plot males, number of fledglings with social mate boxplot(sub.m$personal.fledglings ~ sub.m$patch.fidelity, las=1, col="gray", ylim=c(0, 4), xlab="Patch fidelity", names=c("No", "Yes"), ylab="Number of offspring with social mate") #plot females, number of offspring with social mate boxplot(sub.f$personal.fledglings ~ sub.f$patch.fidelity, las=1, col="gray", ylim=c(0, 4), xlab="Patch fidelity", names=c("No", "Yes"), ylab="") #add title to bottom mtext("(b) Win-stay, lose-switch", side = 3, line=2, at=0, font=2) dev.off() ############################################################################## #check correlations between predictor variables hist(fidelity.data$personal.fledglings) hist(fidelity.data$neighbor.fledglings) plot(fidelity.data$personal.fledglings, fidelity.data$neighbor.fledglings) attach(fidelity.data) lines(lowess(personal.fledglings, neighbor.fledglings), lwd=2, col="gray40", lty="dashed") detach(fidelity.data) #test for correlation using spearman's cor1=cor.test(fidelity.data$personal.fledglings, fidelity.data$neighbor.fledglings, alternative="two.sided", method = "spearman") cor1 ############################################################################## #fit and evaluate models for males #model 1 - public information strategy - is patch fidelity associated with number of conspecific #offspring in adjacent territories glm1.m=glm(formula=patch.fidelity ~ 1 + neighbor.fledglings, data=sub.m, family=binomial(link="logit")) summary(glm1.m) #model 2 - win-stay, lose-switch - is site fidelity associated with number of offspring with social #mate glm2.m=glm(formula=patch.fidelity ~ 1 + as.numeric(personal.fledglings), data=sub.m, family=binomial(link="logit")) summary(glm2.m) #model 0 - model with intercept only - suggesting neither strategy used for patch fidelity glm01.m=glm(formula=patch.fidelity ~ 1, data=sub.m, family=binomial(link="logit")) summary(glm01.m) ########################################### #compare fit of 3 models for males #calculate aicc for glm1 for males #set k, number of parameters in model k=length(glm1.m$coefficients) #set n, sample size n=33 aicc.glm1.m=glm1.m$aic+(2*k*(k+1)/(n-k-1)) #47.42407 #calculate aicc for glm01 for males k=length(glm01.m$coefficients) n=33 aicc.glm01.m=glm01.m$aic+(2*k*(k+1)/(n-k-1)) #=45.39083 #calculate aicc for glm2 for males k=length(glm2.m$coefficients) n=33 aicc.glm2.m=glm2.m$aic+(2*k*(k+1)/(n-k-1)) #=45.97311 #calculate delta aicc #model glm01.m has the lowest aicc for males #calculate delta aicc for glm1.m delta.aicc1.m=aicc.glm1.m-aicc.glm01.m #=2.033245 #calculate delta aicc for glm2.m delta.aicc2.m=aicc.glm2.m-aicc.glm01.m #=0.5822788 ######################################### #calculate model likelihood #for glm1.m l1.m=exp(-1/2*abs(delta.aicc1.m)) #for glm01.m l01.m=exp(-1/2*0) #for glm2.m l2.m=exp(-1/2*abs(delta.aicc2.m)) #sum likelihoods for males suml.m=sum(l1.m, l01.m, l2.m) ######################################### #calculate model weights #for glm1.m w1.m=l1.m/suml.m #for glm01.m w01.m=l01.m/suml.m #for glm2.m w2.m=l2.m/suml.m ############################################################################## #fit and evaluate models for females #model 1 - public information strategy - is patch fidelity associated with number of conspecific #offspring in adjacent territories glm1.f=glm(formula=patch.fidelity ~ 1 + neighbor.fledglings, data=sub.f, family=binomial(link="logit")) summary(glm1.f) #model 2 - win-stay, lose-switch - is site fidelity associated with number of offspring with social #mate glm2.f=glm(formula=patch.fidelity ~ 1 + as.numeric(personal.fledglings), data=sub.f, family=binomial(link="logit")) summary(glm2.f) #model 0 - model with intercept only - suggesting neither strategy used for patch fidelity glm01.f=glm(formula=patch.fidelity ~ 1, data=sub.f, family=binomial(link="logit")) summary(glm01.f) ########################################### #compare fit of 3 models for females #calculate aicc for glm1 for females #set k, number of parameters in model #calculate aicc for glm1 for females k=length(glm1.f$coefficients) #set n, sample size n=17 aicc.glm1.f=glm1.f$aic+(2*k*(k+1)/(n-k-1)) #=25.11729 #calculate aicc for glm2 for females k=length(glm2.f$coefficients) n=17 aicc.glm2.f=glm2.f$aic+(2*k*(k+1)/(n-k-1)) #=19.33194 #calculate aicc for glm01 for females k=length(glm01.f$coefficients) n=17 aicc.glm01.f=glm01.f$aic+(2*k*(k+1)/(n-k-1)) #=22.86378 #calculate delta aicc #model glm2.f has the lowest aicc for females #calculate delta aicc for glm1.f delta.aicc1.f=aicc.glm1.f-aicc.glm2.f #=5.785356 #calculate delta aicc for glm01.f delta.aicc01.f=aicc.glm01.f-aicc.glm2.f #=3.531845 ######################################### #calculate model likelihood #for glm1.f l1.f=exp(-1/2*abs(delta.aicc1.f)) #for glm2.f l2.f=exp(-1/2*0) #for glm01.f l01.f=exp(-1/2*abs(delta.aicc01.f)) #sum likelihoods for females suml.f=sum(l1.f, l01.f, l2.f) ######################################### #calculate model weights #for glm1.f w1.f=l1.f/suml.f #=0.04519327 #for glm2.f w2.f=l2.f/suml.f #=0.8153571 #for glm01.f w01.f=l01.f/suml.f #=0.1394496 ###################################### #make prediction for probability of female patch fidelity based on number of offspring with #social mate because this was the best-fit model #set range and increment of predictor variable, number of offspring with social mate pers.fledg.num=seq(0, 4, 0.5) #make predictions based on model plogis.predict2f=plogis(coef(summary(glm2.f))[1,1] + coef(summary(glm2.f))[2,1]*pers.fledg.num) #attach data attach(sub.f) #make data frame for values for range of prediction personal.num.df=data.frame(personal.fledglings=pers.fledg.num) #predict confidence intervals predict.cl2f=predict(glm2.f, personal.num.df, interval=("confidence"), level=0.95, type="link", se.fit=TRUE) #calculate 95% confidence intervals upper.cl2f=predict.cl2f$fit + 1.96 * predict.cl2f$se.fit lower.cl2f=predict.cl2f$fit - 1.96 * predict.cl2f$se.fit #transform confidence intervals onto logit scale logit.upper.cl2f=plogis(upper.cl2f) logit.lower.cl2f=plogis(lower.cl2f) detach(sub.f) ######################################### #export figure 2 as tif tiff("Figure-2(Campomizzi).tif", width = 7, height = 7, units = "in", bg = "white", compression = "lzw", res = 600) #plot prediction of probability of site fidelity given number of offspring with social mate, for #females plot(pers.fledg.num, plogis.predict2f, type="l", lwd=2, las=1, bty="l", xlim=c(0, 4), ylim=c(0.0, 1.0), main="Predicted female patch fidelity", xlab="Number of offsping with social mate", ylab="Probability of patch fidelity") #add 95% CI lines(pers.fledg.num, logit.upper.cl2f, type="l", lty="dashed", lwd=2) lines(pers.fledg.num, logit.lower.cl2f, type="l", lty="dashed", lwd=2) #add data points, jittered for visibility because data are integers points(sub.f$personal.fledglings + rnorm(length(sub.f$personal.fledglings), 0, 0.07), as.numeric(sub.f$patch.fidelity) - 1, cex=1.15, col="gray60") dev.off() ############################################################################## #end of analysis ##############################################################################