diff --git a/Report.qmd b/Report.qmd index 204aaf8..3ed80b2 100644 --- a/Report.qmd +++ b/Report.qmd @@ -1,6 +1,6 @@ # Condor Populations Project 3 -Emily Fowler, Menna Ellaqanny, Michael Thomas +Emily Fowler, Menna Ellaqany, Michael Thomas ```{r} source("project.R") @@ -30,6 +30,11 @@ simulate_condor_population(0.659, 0.086, 0.086) simulate_condor_population(0.659, 0.138, 0.069) ``` +### Double Clutching +```{r} +simulate_condor_population(0.659, 0.138, 0.069, dc = TRUE) +``` + ## Part E. Consider year 1, immature, and adult mortalities of 0.659, 0.099, and 0.099, respectively. ```{r} diff --git a/project.R b/project.R index fce92aa..70197a8 100644 --- a/project.R +++ b/project.R @@ -42,6 +42,7 @@ simulate_condor_population_inner <- function(rd1, rdI, rdA, c_Y0, c_Y1, c_I, c_A, w_Y0, w_Y1, w_I, w_A, nyears, captive_dc) { + captive_prod <- if (captive_dc) captive_productivity_rate_dc else captive_productivity_rate for (t in (length(c_Y0) + 1):nyears) { # model captive population changes (year 1, immature, and adult) c_Y1[t] <- c_Y0[t - 1] - # last year's population @@ -57,7 +58,7 @@ simulate_condor_population_inner <- function(rd1, rdI, rdA, captive_immature_to_adult_rate * c_I[t - 1] # inflow from immature # model new births in captive population - c_Y0[t] <- captive_productivity_rate * (c_A[t] / 2) + c_Y0[t] <- captive_prod * (c_A[t] / 2) # sum of all population groups last_captive_population <- c_Y0[t - 1] + c_Y1[t - 1] + c_I[t - 1] + c_A[t - 1] @@ -70,25 +71,21 @@ simulate_condor_population_inner <- function(rd1, rdI, rdA, c_Y1[t] <- c_Y1[t] - released_to_wild # carrying capacity death rate - last_wild_population <- w_Y0[t - 1] + w_Y1[t - 1] + c_I[t - 1] + c_A[t - 1] - approx_wild_growth_rate <- (wild_productivity_rate * (w_A[t - 1] / 2) + released_to_wild) / last_wild_population - rd_carrying <- approx_wild_growth_rate * (last_wild_population / wild_carrying_capacity) # r * P / M + last_wild_population <- w_Y0[t - 1] + w_Y1[t - 1] + w_I[t - 1] + w_A[t - 1] + rd_carrying <- (last_wild_population / wild_carrying_capacity) # P / M - w_Y1[t] <- (w_Y0[t - 1] + # inflow from year zero - released_to_wild) * # inflow from captive - (1 - rd1) * # outflow to deaths (death rate) - (1 - rd_carrying) # outflow to deaths (carrying capacity) + w_Y1[t] <- w_Y0[t - 1] - # inflow from year zero + rd1 * w_Y1[t - 1] # outflow to deaths (death rate) w_I[t] <- w_I[t - 1] + # last year's population - w_Y1[t - 1] - # inflow from year one + w_Y1[t - 1] + # inflow from year one + released_to_wild * (1 - rd_carrying) - # inflow from captive w_I[t - 1] * wild_immature_to_adult_rate - # outflow to adult - w_I[t - 1] * rdI - # outflow to deaths (death rate) - w_I[t - 1] * rd_carrying # outflow to deaths (carrying capacity) + w_I[t - 1] * rdI # outflow to deaths (death rate) w_A[t] <- w_A[t - 1] + # last year's population w_I[t - 1] * wild_immature_to_adult_rate - # inflow from immature - w_A[t - 1] * rdA - # outflow to deaths (death rate) - w_A[t - 1] * rd_carrying # outflow to deaths (carrying capacity) + w_A[t - 1] * rdA # outflow to deaths (death rate) w_Y0[t] <- wild_productivity_rate * (w_A[t] / 2) * (1 - rd_carrying) # deaths due to carrying capacity @@ -123,7 +120,7 @@ plot_populations <- function(c_Y0, c_Y1, c_I, c_A, plot( years, w_Y0, - ylim = c(0, wild_carrying_capacity + 100), + ylim = c(0, wild_carrying_capacity), col = "red", main = "Condor Population in the Wild", xlab = "Time (years)", @@ -133,13 +130,15 @@ plot_populations <- function(c_Y0, c_Y1, c_I, c_A, points(years, w_I, col = "darkgreen") points(years, w_A, col = "blue") points(years, wild_population) + + print(wild_population) } # Simulates the Condor population over time using the given parameters. # * `rd1` - death rate of year one birds # * `rdI` - death rate of immature birds # * `rdA` - death rate of adult birds -simulate_condor_population <- function(rd1, rdI, rdA) { +simulate_condor_population <- function(rd1, rdI, rdA, dc = FALSE) { # captive population groups c_Y0 <- c(30) c_Y1 <- c(30) @@ -147,16 +146,16 @@ simulate_condor_population <- function(rd1, rdI, rdA) { c_A <- c(30) # wild population groups - w_Y0 <- c(100) - w_Y1 <- c(100) - w_I <- c(100) - w_A <- c(100) + w_Y0 <- c(30) + w_Y1 <- c(30) + w_I <- c(30) + w_A <- c(30) list2env(simulate_condor_population_inner( rd1, rdI, rdA, c_Y0, c_Y1, c_I, c_A, w_Y0, w_Y1, w_I, w_A, - simulation_years, FALSE + simulation_years, dc ), envir = environment()) plot_populations( @@ -173,29 +172,31 @@ simulate_part_f <- function(rd1, rdI, rdA) { c_A <- c(30) # wild population groups - w_Y0 <- c(100) - w_Y1 <- c(100) - w_I <- c(100) - w_A <- c(100) + w_Y0 <- c(30) + w_Y1 <- c(30) + w_I <- c(30) + w_A <- c(30) + + sdc <- 5 # simulate first 5 years list2env(simulate_condor_population_inner( rd1, rdI, rdA, c_Y0, c_Y1, c_I, c_A, w_Y0, w_Y1, w_I, w_A, - 5, TRUE + sdc, TRUE ), envir = environment()) # release all in captivity - w_Y0[5] <- w_Y0[5] + c_Y0[5] - w_Y1[5] <- w_Y1[5] + c_Y1[5] - w_I[5] <- w_I[5] + c_I[5] - w_A[5] <- w_A[5] + c_A[5] + w_Y0[sdc] <- w_Y0[sdc] + c_Y0[sdc] + w_Y1[sdc] <- w_Y1[sdc] + c_Y1[sdc] + w_I[sdc] <- w_I[sdc] + c_I[sdc] + w_A[sdc] <- w_A[sdc] + c_A[sdc] - c_Y0[5] <- 0 - c_Y1[5] <- 0 - c_I[5] <- 0 - c_A[5] <- 0 + c_Y0[sdc] <- 0 + c_Y1[sdc] <- 0 + c_I[sdc] <- 0 + c_A[sdc] <- 0 # continue simulation list2env(simulate_condor_population_inner(