From f2a169d36e551fe86c44596ee17069faf5777e92 Mon Sep 17 00:00:00 2001 From: thierrychambert <thierry.chambert@gmail.com> Date: Thu, 12 Aug 2021 13:41:04 +0200 Subject: [PATCH] minor corrections on simul functions --- R/models.R | 12 ++++++------ man/run_simul.Rd | 6 +++--- man/run_simul_shiny.Rd | 4 ++-- run_analysis.R | 23 +++++------------------ 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/R/models.R b/R/models.R index 744b7c3..66b1b34 100644 --- a/R/models.R +++ b/R/models.R @@ -133,9 +133,9 @@ M3_WithDD_noDemoStoch <- function(N1, s, f, h, DD_params){ ## M3_WithDD_noDemoStoch # Extract DD parameters from list - rMAX = DD_params$rMAX - K = DD_params$K - theta = DD_params$theta + rMAX <- DD_params$rMAX + K <- DD_params$K + theta <- DD_params$theta # Apply density dependence effect lam_Nt <- 1 + rMAX*(1-(sum(N1)/K)^theta) @@ -208,9 +208,9 @@ M4_WithDD_WithDemoStoch <- function(N1, s, f, h, DD_params){ ## M4_WithDD_WithDemoStoch # Extract DD parameters from list - rMAX = DD_params$rMAX - K = DD_params$K - theta = DD_params$theta + rMAX <- DD_params$rMAX + K <- DD_params$K + theta <- DD_params$theta # Apply density dependence effect lam_Nt <- 1 + rMAX*(1-(sum(N1)/K)^theta) diff --git a/man/run_simul.Rd b/man/run_simul.Rd index e320bff..afb0db7 100644 --- a/man/run_simul.Rd +++ b/man/run_simul.Rd @@ -6,7 +6,7 @@ \usage{ run_simul( nsim, - cumuated_impacts, + cumulated_impacts, fatalities_mean, fatalities_se, onset_time, @@ -29,7 +29,7 @@ run_simul( \arguments{ \item{nsim}{number of simulation} -\item{cumuated_impacts}{Logical. If TRUE, we used the projection model for cumulated impacts.} +\item{cumulated_impacts}{Logical. If TRUE, we used the projection model for cumulated impacts.} \item{fatalities_mean}{a vector (numeric). Average number of fatalities, for each scenario.} @@ -111,7 +111,7 @@ carrying_capacity = 1200 theta = 1 rMAX_species <- 0.15 -run_simul(nsim = 10, cumuated_impacts = FALSE, +run_simul(nsim = 10, cumulated_impacts = FALSE, fatalities_mean, fatalities_se, onset_time = NULL, pop_size_mean, pop_size_se, pop_size_type, pop_growth_mean, pop_growth_se, diff --git a/man/run_simul_shiny.Rd b/man/run_simul_shiny.Rd index 1e8bc33..37a56f7 100644 --- a/man/run_simul_shiny.Rd +++ b/man/run_simul_shiny.Rd @@ -8,7 +8,7 @@ the simulation progress bar in Shiny (incProgress function)} \usage{ run_simul_shiny( nsim, - cumuated_impacts, + cumulated_impacts, fatalities_mean, fatalities_se, onset_time, @@ -31,7 +31,7 @@ run_simul_shiny( \arguments{ \item{nsim}{number of simulation} -\item{cumuated_impacts}{Logical. If TRUE, we used the projection model for cumulated impacts.} +\item{cumulated_impacts}{Logical. If TRUE, we used the projection model for cumulated impacts.} \item{fatalities_mean}{a vector (numeric). Average number of fatalities, for each scenario.} diff --git a/run_analysis.R b/run_analysis.R index ee7136d..e24bb75 100644 --- a/run_analysis.R +++ b/run_analysis.R @@ -1,6 +1,6 @@ rm(list = ls(all.names = TRUE)) graphics.off() - +library(popbio) ## Libraries library(eolpop) @@ -14,7 +14,7 @@ fatalities_se = c(0, 0.05, 0.05, 0.05) pop_size_mean = 200 pop_size_se = 25 -pop_growth_mean = 1 +pop_growth_mean = 1.1 pop_growth_se = 0 survivals <- c(0.5, 0.7, 0.8, 0.95) @@ -23,8 +23,8 @@ fecundities <- c(0, 0, 0.05, 0.55) model_demo = NULL # M2_noDD_WithDemoStoch #M1_noDD_noDemoStoch #M4_WithDD_WithDemoStoch #M3_WithDD_noDemoStoch # time_horzion = 50 coeff_var_environ = 0.10 -fatal_constant = "M" -pop_size_type = "Npair" +fatal_constant = "h" +pop_size_type = "Ntotal" cumulated_impacts = TRUE @@ -60,7 +60,7 @@ vr_calibrated <- calibrate_params(inits = inits, f = fecundities, s = survivals, s_calibrated <- head(vr_calibrated, length(survivals)) f_calibrated <- tail(vr_calibrated, length(fecundities)) -build_Leslie(s = s_calibrated, f = f_calibrated) %>% lambda +lambda( build_Leslie(s = s_calibrated, f = f_calibrated) ) @@ -84,16 +84,3 @@ names(run0) N <- run0$N ; dim(N) plot_traj(N, xlab = "Annee", ylab = "Taille de population (totale)") abline(h = K) - -colSums(N[,,,]) %>% max - -plot_impact(N, onset_year = onset_year , xlab = "Annee", ylab = "Impact relatif") - - -N <- run0$N -output <- get_metrics(N, cumuated_impacts = cumulated_impacts) -output$scenario$Pext - -#plot_impact(N = N, xlab = "year", ylab = "pop size") -#source("draws_histog.R") -#draws_histog(draws = run0$lambdas, mu = pop_growth_mean, se = pop_growth_se) -- GitLab