View source: R/15.4-analysis-uncertainty.R
| predict_consumption_bootstrap | R Documentation |
Propagates p-value uncertainty to consumption predictions using parametric bootstrap. Generates multiple samples from the p-value distribution and runs FB4 simulations for each sample. Provides full uncertainty distribution without linearity assumptions. Supports parallel processing for improved performance.
predict_consumption_bootstrap(
p_mean,
p_sd,
bio_obj,
n_sims = 1000,
first_day = 1,
last_day = 365,
parallel = FALSE,
n_cores = NULL,
confidence_level = 0.95,
verbose = FALSE
)
p_mean |
Mean of p-value distribution |
p_sd |
Standard deviation of p-value distribution |
bio_obj |
Bioenergetic object with simulation settings and environmental data |
n_sims |
Number of bootstrap simulations, default 1000 |
first_day |
First simulation day, default 1 |
last_day |
Last simulation day, default 365 |
parallel |
Use parallel processing, default FALSE |
n_cores |
Number of cores for parallel processing (NULL = auto-detect), default NULL |
confidence_level |
Confidence level for intervals, default 0.95 |
verbose |
Show progress messages, default FALSE |
The bootstrap method: 1. Samples p-values from Normal(p_mean, p_sd) 2. Constrains samples to valid range [0.01, 5.0] 3. Runs FB4 simulation for each p-value sample 4. Summarizes consumption distribution
Parallel processing can significantly reduce computation time for large n_sims. The method handles simulation failures gracefully and reports success rates.
A named list with elements:
methodCharacter string "bootstrap".
consumption_meanMean total consumption across bootstrap samples (g).
consumption_sdStandard deviation of consumption across samples (g).
consumption_ciNumeric vector of length 2 with lower and upper quantile-based confidence interval bounds (g).
consumption_samplesNumeric vector of all successful consumption estimates from bootstrap samples.
n_successfulNumber of bootstrap iterations that produced valid consumption estimates.
p_meanThe supplied p_mean value.
p_sdThe supplied p_sd value.
data(fish4_parameters)
sp <- fish4_parameters[["Oncorhynchus tshawytscha"]]$life_stages$adult
info <- fish4_parameters[["Oncorhynchus tshawytscha"]]$species_info
bio <- Bioenergetic(
species_params = sp,
species_info = info,
environmental_data = list(
temperature = data.frame(Day = 1:30, Temperature = rep(12, 30))
),
diet_data = list(
proportions = data.frame(Day = 1:30, Prey1 = 1.0),
energies = data.frame(Day = 1:30, Prey1 = 5000),
prey_names = "Prey1"
),
simulation_settings = list(initial_weight = 100, duration = 30)
)
bio$species_params$predator$ED_ini <- 5000
bio$species_params$predator$ED_end <- 5500
uncertainty_result <- predict_consumption_bootstrap(
p_mean = 0.5,
p_sd = 0.05,
bio_obj = bio,
n_sims = 20,
last_day = 30
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.