library(tidyverse)library(targets)library(GGally)library(kableExtra)# load "R/*" scripts and saved R objects from the targets pipelinetar_source()tar_load(c(exp1_data, exp2_data, exp1_data_agg, exp2_data_agg, exp3_data_agg))set.seed(213)# make sure that if the model fails to converge, it doesn't stop the whole processsafe_boot_est <- purrr::safely(boot_est)
---title: "Bootstrap fits to estimate uncertainty"format: htmldraft: true---```{r}#| label: init#| message: falselibrary(tidyverse)library(targets)library(GGally)library(kableExtra)# load "R/*" scripts and saved R objects from the targets pipelinetar_source()tar_load(c(exp1_data, exp2_data, exp1_data_agg, exp2_data_agg, exp3_data_agg))set.seed(213)# make sure that if the model fails to converge, it doesn't stop the whole processsafe_boot_est <- purrr::safely(boot_est)```## Bootstrap the original model```{r}res_asy <-run_or_load(t(replicate(1000, safe_boot_est(exp1_data)$result))[1, , ],"output/res_boot1000_asy.rds")res_asy_exp2 <-run_or_load(t(replicate(1000, safe_boot_est(exp2_data)$result))[1, , ],"output/res_boot1000_asy_exp2.rds" )res_lin <-run_or_load(t(replicate(1000, safe_boot_est(exp1_data, model ="linear")$result))[1, , ],"output/res_boot1000_lin.rds" )res_lin_exp2 <-run_or_load(t(replicate(1000, safe_boot_est(exp2_data, model ="linear")$result))[1, , ],"output/res_boot1000_lin_exp2.rds" )```plot the results```{r}plot_bootstrap_results(res_asy)plot_bootstrap_results(res_asy_exp2)plot_bootstrap_results(res_lin)plot_bootstrap_results(res_lin_exp2)``````{r}library(HDInterval)hdi(unlist(res_asy[,'rate']))hdi(unlist(res_asy_exp2[,'rate']))hdi(unlist(res_lin[,'rate']))hdi(unlist(res_lin_exp2[,'rate'])) ```