Load libraries
library(nlme)
library(ggplot2)
library(ezknitr)
Read in data (modified in RegressionRevisited.R)
mwdat<-read.csv("data/moosewolf.csv")
Add information from 2017 moose survey
mwdat<-rbind(mwdat, rep(NA, ncol(mwdat)))
nobs<-nrow(mwdat)
mwdat$Year[nobs]<-2017
mwdat$moose[nobs]<-3708
mwdat$ca.total[nobs]<-0.15
mwdat$calf.cow[nobs]<-0.36
mwdat$survey[nobs]<-mwdat$survey[nobs-1]
Create figure 2 in the paper
cols<-c("Red", "Blue", "Black")
windows(width=16, height=8)
layout(matrix(c(1,1,2,2,3,3,0,4,4,5,5,0), nrow=2, byrow=TRUE))
par(bty="L", cex.main=1.8, cex.lab=1.8, cex.axis=1.8, oma=c(0.5,2,0,0),mar=c(4.1, 3, 4.1, 4.5), lwd=2)
with(mwdat, plot(Year, moose, col=cols[as.numeric(as.factor(mwdat$survey))], pch=16, xlab="",
ylab="",cex=2))
with(subset(mwdat, survey=="fixed.early"), lines(Year, moose, col=cols[1]))
with(subset(mwdat, survey=="fixed.late"), lines(Year, moose, lty=3, col=cols[2]))
with(subset(mwdat, survey=="heli"), lines(Year, moose, lty=5, col=cols[3]))
mtext(side=2, "Number of moose", cex=1.8, line=3)
mtext(side=3, "A)", cex=1.8, line=1.5, adj=0)
# Now, number of wolves
with(mwdat, plot(Year, wlfdens, col=cols[as.numeric(as.factor(mwdat$survey))], pch=16, xlab="",
ylab="",cex=2))
with(subset(mwdat, survey=="fixed.early"), lines(Year, wlfdens, col=cols[1]))
with(subset(mwdat, survey=="fixed.late"), lines(Year, wlfdens, lty=3, col=cols[3]))
with(subset(mwdat, survey=="heli"), lines(Year, wlfdens, lty=5, col=cols[3]))
mtext(side=2, "Number of wolves", cex=1.8, line=3)
mtext(side=3, "B)", cex=1.8, line=1.5, adj=0)
# Calf:population and calf:cow
with(mwdat, plot(Year, ca.total, col=cols[as.numeric(as.factor(mwdat$survey))], pch=16, xlab="",
ylab="",cex=2))
with(subset(mwdat, survey=="fixed.early"), lines(Year, ca.total, col=cols[1]))
with(subset(mwdat, survey=="fixed.late"), lines(Year, ca.total, lty=3, col=cols[2]))
with(subset(mwdat, survey=="heli"), lines(Year, ca.total, lty=5, col=cols[3]))
mtext(side=2, "Calf:Population", cex=1.6, line=3)
par(new=TRUE, bty="l")
with(mwdat, plot(Year, calf.cow, xlab="", ylab="", type="p", pch=16,
yaxt="n", col=gray(0.6), cex=2))
with(subset(mwdat, survey=="fixed.early"), lines(Year, calf.cow, col=gray(0.6)))
with(subset(mwdat, survey=="fixed.late"), lines(Year, calf.cow, lty=3, col=gray(0.6)))
with(subset(mwdat, survey=="heli"), lines(Year,calf.cow, lty=5, col=gray(0.6)))
axis(4)
mtext("Calf:Cow ", side=4, line=3.1, cex=1.6, col=gray(0.5))
mtext(side=3, "C)", cex=1.8, line=1.5, adj=0)
# Calf:pop versus wolves previous year
par(bty="L")
xo<-order(mwdat$ca.total.hat)
with(mwdat, plot(prvwfden, ca.total,col=cols[as.numeric(as.factor(mwdat$survey))], pch=16, xlab="",
ylab="",cex=2))
with(subset(mwdat[xo,], survey=="fixed.early"), lines(prvwfden, ca.total.hat, col=cols[1]))
with(subset(mwdat[xo,], survey=="fixed.late"), lines(prvwfden, ca.total.hat, col=cols[2]))
with(subset(mwdat[xo,], survey=="heli"), lines(prvwfden, ca.total.hat, col=cols[3]))
mtext(side=2, "Calf:Population (t+1)", cex=1.8, line=3)
mtext(side=1, "Wolves (t)", cex=1.8, line=3.2)
mtext(side=3, "D)", cex=1.8, line=1.5, adj=0)
# log(Moose[t+1]/Moose[t]) versus wolves[t]
xo<-order(mwdat$lambda.hat)
with(mwdat, plot(prvwfden,log.lam,col=cols[as.numeric(as.factor(mwdat$survey))], pch=16, xlab="",
ylab="",cex=2))
with(subset(mwdat[xo,], survey=="fixed.early"), lines(prvwfden,lambda.hat, col=cols[1]))
with(subset(mwdat[xo,], survey=="fixed.late"), lines(prvwfden, lambda.hat, col=cols[2]))
with(subset(mwdat[xo,], survey=="heli"), lines(prvwfden, lambda.hat, col=cols[3]))
with(subset(mwdat[xo,], survey=="heli"), lines(prvwfden, lambda.lci, lty=2, col=cols[3]))
with(subset(mwdat[xo,], survey=="heli"), lines(prvwfden, lambda.uci, lty=2, col=cols[3]))
mtext(side=2, expression(paste("Moose log(", lambda[t], ")")), cex=1.8, line=3)
mtext(side=1, "Wolves (t)", cex=1.8, line=3.2)
mtext(side=3, "E)", cex=1.8, line=1.5, adj=0)
sessionInfo()
## R version 3.3.3 (2017-03-06)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows >= 8 x64 (build 9200)
##
## locale:
## [1] LC_COLLATE=English_United States.1252
## [2] LC_CTYPE=English_United States.1252
## [3] LC_MONETARY=English_United States.1252
## [4] LC_NUMERIC=C
## [5] LC_TIME=English_United States.1252
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] stargazer_5.2 MASS_7.3-45 ggplot2_2.2.1 nlme_3.1-131 knitr_1.16
## [6] ezknitr_0.6
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.12 lattice_0.20-34 mime_0.5
## [4] R.methodsS3_1.7.1 plyr_1.8.4 grid_3.3.3
## [7] gtable_0.2.0 magrittr_1.5 evaluate_0.10
## [10] scales_0.4.1 highr_0.6 rlang_0.1.2
## [13] stringi_1.1.5 lazyeval_0.2.0 R.oo_1.21.0
## [16] R.utils_2.5.0 tools_3.3.3 stringr_1.2.0
## [19] markdown_0.7.7 munsell_0.4.3 colorspace_1.3-2
## [22] tibble_1.3.3
Spun using: ezspin(“Scripts/Figure2Plots.R”, out_dir = “output”, fig_dir = “figures”, keep_md=FALSE)