knitr::opts_knit$set(root.dir = 'C:/Users/adavi/Documents/Northwestern/Thesis/Besseya Data')
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(popbio)
library(lubridate)
library(kableExtra)
library(knitr)
#Cite all loaded packages (citations will automatically be added to end of document)
knitr::write_bib(c(.packages()), "packages.bib")
bbull_poc <- read.csv("besseyaBullii_monitoringReports_2021.12.07.csv")
head(sbull)
tail(sbull)
ncol(sbull)
nrow(sbull)
str(sbull)
sbull2 <- sbull %>%
filter(site_name == "LeRoy Oakes Forest Preserve") ## Should I rename the location?
sbull2$date_monitored <- mdy(sbull2$date_monitored)
sbull3 <- sbull2 %>%
mutate(year = year(date_monitored))
sbull4 <- sbull3 %>%
select(scientific_name, county, year, total_number_counted, count_range, percent_reproductive)
head(sbull4)
tail(sbull4)
shift <- function(x, n){
c(x[-(seq(n))], rep(NA, n))
}
sbull5 <- sbull4 %>%
mutate(next_year_count = shift(sbull4$total_number_counted, 1)) %>%
relocate(next_year_count, .after = total_number_counted)
sbull6 <- sbull5 %>%
mutate(growth_rate = (next_year_count - total_number_counted)/(total_number_counted))
sbull6
sbull_plot1 <- sbull6 %>%
ggplot(aes(year, total_number_counted)) +
geom_point() +
geom_smooth(method = "loess", se = F) +
labs(x = "Year",
y = "Population Size (N)",
caption = "Figure 1. Size of a Synthyris bullii population monitored from 2006 - 2021.") +
theme_classic()
sbull_plot1
sbull_plot2 <- sbull6 %>%
ggplot(aes(total_number_counted, growth_rate)) +
geom_point() +
geom_smooth(method = "lm", se = F) +
labs(x = "Population Size (N)",
y = "Annual Growth Rate",
caption = " Figure 2. Model of density dependence of a Synthyris bullii population. There is a significant \n negative relationship between size and annual growth rate (slope = -0.008, p <0.05).") +
geom_hline(yintercept = 0, lty = "dashed") +
theme_classic()
sbull_plot2
sbull_model1 <- lm(growth_rate ~ total_number_counted ,data = sbull6)
sbull_summary1 <- summary(sbull_model1)
sbull_summary2 <- coef(sbull_summary1)
row.names(sbull_summary2) <- c("Intercept", "Population Size (N)")
knitr::kable(sbull_summary2,
caption = "Table 1. Synthyris bullii population density dependence. Population size was used to predict annual growth rate. ",
col.names = c("Estimate", "Std. Error", "t-value", "p-value")) %>%
kable_minimal(full_width = F, html_font = "Cambria", position = "left")
| Estimate | Std. Error | t-value | p-value | |
|---|---|---|---|---|
| Intercept | 1.006495 | 0.4310899 | 2.334767 | 0.0362399 |
| Population Size (N) | -0.008831 | 0.0039811 | -2.218220 | 0.0449658 |
logN <- log(sbull5$total_number_counted[-1]/sbull5$total_number_counted[-16])
sbull_ext_5 <- countCDFxt(mu=mean(logN), sig2=var(logN), nt=15, tq=15, Nc=53, Ne=5, tmax = 15, Nboot = 100, plot = T)
Figure 3. Extinction risk of Synthyris bullii population with extinction threshold set to 5 individuals.
sbull_ext_10 <- countCDFxt(mu=mean(logN), sig2=var(logN), nt=15, tq=15, Nc=53, Ne=10, tmax = 15, Nboot = 100, plot = T)
Figure 4. Extinction risk of Synthyris bullii population with extinction threshold set to 10 individuals.
sbull_ext_20 <- countCDFxt(mu=mean(logN), sig2=var(logN), nt=15, tq=15, Nc=53, Ne=20, tmax = 15, Nboot = 100, plot = T)
Figure 5. Extinction risk of Synthyris bullii population with extinction threshold set to 20 individuals.