Last compiled: 2022-05-03
To figure out the minimum number of meshpoints needed to accurately (precisely?) model population growth.
::with_dir(here::here(), {
withrtar_load(vit_list_det_ff)
tar_load(vit_list_stoch_ff)
tar_load(pop_vec_ff)
})
<- make_proto_ipm_det(vit_list_det_ff, pop_vec = pop_vec_ff) proto_det
Ok, so let’s alter the number of meshpoints systematically and see where lambda converges
<-
proto_det_list seq(20, 150, 5) %>%
map(~{
%>%
proto_det define_domains(log_size = c(0, 8.018296, .x)) %>%
#arbitrary starting population state
define_pop_state(n_log_size = runif(.x), n_sdlg = .1)
})<- proto_det_list %>%
lambdas_det map_dbl(~make_ipm(.x, usr_funs = list(get_scat_params = get_scat_params)) %>% lambda())
plot(x =seq(20, 150, 5), y = lambdas_det, ylab = "lambda", xlab = "meshpoints")
plot(x = seq(20, 150, 5), y = lambdas_det - lag(lambdas_det), ylab = "∆lambda", xlab = "meshpoints")
Looks like 100 is probably the best. Could maybe do 80.
Let’s try with stochastic IPM.
<- make_proto_ipm_stoch(vit_list_stoch_ff, pop_vec = pop_vec_ff) proto_stoch
<-
proto_stoch_list seq(20, 140, 10) %>%
map(~{
%>%
proto_stoch define_domains(log_size = c(0, 8.018296, .x)) %>%
#replace starting pop vector with uniform one with correct number of meshpts
define_pop_state(n_log_size = rep(1/(.x + 1), .x), n_sdlg = 1/.x)
})
<- sample(2000:2009, 1000, replace = TRUE)
year_seq
<-
ipm_list %>%
proto_stoch_list map( ~ make_ipm(
.x,iterations = 1000,
kernel_seq = year_seq,
usr_funs = list(get_scat_params = get_scat_params)
))
<- ipm_list %>% map_dbl(~lambda(.x, log = FALSE))
lambdas_stoch
plot(x = seq(20, 140, 10), y = lambdas_stoch, ylab = "stochastic lambda", xlab = "meshpoints")
plot(x = seq(20, 140, 10), y = lambdas_stoch - lag(lambdas_stoch), ylab = "∆lambda", xlab = "meshpoints")
Ok, looks about the same for the stochastic model, which makes sense.