Shenandoah National Park brook trout data 72 sites in 1996-2010: not all sites were sampled every year & there is a mix of 1-pass and 3-pass surveys ========================================================================
rm(list=ls()) setwd('/Users/Dan/Documents/Research/Stream_Climate_Change/Brook_Trout/Compare_Single_Multiple_Pass/') getwd() library(reshape2) library(rjags) library(plyr) library(ggplot2) library(knitr) library(arm) library(boot)
load("Data/Shen Dail Madsen data and results ver 6.8.RData")
Compare to 3-pass DM model by Yoichiro
adult.dm <- filter(yearTotalAbund, filter = size2 == "adult") adult.dm <- filter(adult.dm, filter = year2 != 1996) colnames(adult.dm) <- c("year.num", "size", "N.pop", "total.lower", "total.upper", "year", "size2") adult.dm$method <- "Dail-Madsen" agg.adult$method <- "Single-Pass" adult.compare <- rbind(adult.dm[, c("year", "N.pop", "method")], agg.adult[ , c("year", "N.pop", "method")]) ggplot(adult.compare, aes(x=year, y=N.pop, colour=method)) + #geom_errorbar(aes(ymin=total.lower, ymax=total.upper), width=0.5, size=1.2) + geom_line(size = 1.2) + geom_point(size = 3) + xlab("Year") + ylab("Estimated total adult abundance") + labs(title = "Yearly adult abundance over 72 sites in Shenandoah") + #theme(legend.position = c(2008, 6000)) theme_bw() yoy.dm <- filter(yearTotalAbund, filter = size2 == "YOY") yoy.dm <- filter(yoy.dm, filter = year2 != 1996) colnames(yoy.dm) <- c("year.num", "size", "N.pop", "total.lower", "total.upper", "year", "size2") yoy.dm$method <- "Dail-Madsen" agg.yoy$method <- "Single-Pass" yoy.compare <- rbind(yoy.dm[, c("year", "N.pop", "method")], agg.yoy[ , c("year", "N.pop", "method")]) ggplot(yoy.compare, aes(x=year, y=N.pop, colour=method)) + #geom_errorbar(aes(ymin=total.lower, ymax=total.upper), width=0.5, size=1.2) + geom_line(size = 1.2) + geom_point(size = 3) + xlab("Year") + ylab("Estimated total YOY abundance") + labs(title = "Yearly YOY abundance over 72 sites in Shenandoah") + #theme(legend.position = c(2008, 6000)) theme_bw() adult.detect.1$detection.probabilities cor(adult.dm$N.pop, agg.adult$N.pop) cor(yoy.dm$N.pop, agg.yoy$N.pop) summary(lm(adult.dm$N.pop ~ agg.adult$N.pop)) summary(lm(yoy.dm$N.pop ~ agg.yoy$N.pop))
abund <- rpois(10, 20) year <- 1:10 count1 <- abund * 0.5 count2 <- rbinom(10, abund, 0.5) flow <- rnorm(10) * (year - mean(year))/sd(year) p <- 0.5 - flow * 0.18 count3 <- NA for(i in 1:length(year)) { # effects of random flow when surveyed in different years count3[i] <- rbinom(1, abund, p[i]) } df <- data.frame(year, abund, count1, count2) gp1 <- ggplot(df, aes(year, abund)) + geom_point(size = 3) + geom_line(size = 1) + xlab("Year") + ylab("Abundance") + ylim(c(0, 30)) + theme_bw() + theme(axis.text=element_text(size=12), axis.title=element_text(size=14,face="bold")) gp1 gp2 <- gp1 + geom_point(aes(year, count1), colour = "blue", size = 3) + geom_line(aes(year, count1), colour = "blue", size = 1) gp2 gp3 <- gp2 + geom_point(aes(year, count2), colour = "red", size = 3) + geom_line(aes(year, count2), colour = "red", size = 1) gp3 gp4 <- gp2 + geom_point(aes(year, count3), colour = "red", size = 3) + geom_line(aes(year, count3), colour = "red", size = 1, linetype = 2) gp4
```r
coef(adult.detect.1) fixef(adult.glmm.p)
summary(adult.detect.1) summary(yoy.detect.1) summary(adult.glmm.p)
recruit.coefs survival.coefs.adult survival.coefs.yoy detect.coefs
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.