Last compiled: 2022-04-26

1 Purpose

How many bootstraps is enough to estimate CIs around lambda?

2 Load Data

withr::with_dir(here::here(), tar_load(c(
  ipm_det_cf,
  ipm_det_ff,
  ipm_stoch_cf,
  ipm_stoch_ff,
  lambda_bt_det_cf,
  lambda_bt_det_ff,
  lambda_bt_stoch_cf,
  lambda_bt_stoch_ff
)))
## Attempting to load the environment 'package:ipmr'
## It looks like you've installed the development vesrion of ipmr from the repository 'levisc8/ipmr'.
## ipmr will soon be moving to the padrinoDB Github organization.
## In the future, you will need to install the development version from there.
## remotes::install_github('padrinoDB/ipmr')
est <- lambda(ipm_det_cf)
df <- seq_along(lambda_bt_det_cf) %>% 
  map_df(~bcpi(t0 = est, t = lambda_bt_det_cf[1:.x]), .id = "B") %>% 
  mutate(B = as.numeric(B))

ggplot(df,aes(x = B)) +
  geom_line(aes(y = lower), color = "red") +
  geom_line(aes(y = upper), color = "blue")

Looks like it does converge after like 200 bootstraps

est <- lambda(ipm_det_ff)
df <- seq_along(lambda_bt_det_ff) %>% 
  map_df(~bcpi(t0 = est, t = lambda_bt_det_ff[1:.x]), .id = "B") %>% 
  mutate(B = as.numeric(B))

ggplot(df,aes(x = B)) +
  geom_line(aes(y = lower), color = "red") +
  geom_line(aes(y = upper), color = "blue")

est <- lambda(ipm_stoch_cf, log = FALSE)
df <- seq_along(lambda_bt_stoch_cf) %>% 
  map_df(~bcpi(t0 = est, t = lambda_bt_stoch_cf[1:.x]), .id = "B") %>% 
  mutate(B = as.numeric(B))

ggplot(df,aes(x = B)) +
  geom_line(aes(y = lower), color = "red") +
  geom_line(aes(y = upper), color = "blue")

For stochastic it does take longer. Why the sudden leaps for the upper limit?

est <- lambda(ipm_stoch_ff, log = FALSE)
df <- seq_along(lambda_bt_stoch_ff) %>% 
  map_df(~bcpi(t0 = est, t = lambda_bt_stoch_ff[1:.x]), .id = "B") %>% 
  mutate(B = as.numeric(B))

ggplot(df,aes(x = B)) +
  geom_line(aes(y = lower), color = "red") +
  geom_line(aes(y = upper), color = "blue")