Skip to contents

Compares multiple FB4 simulation results across different scenarios, parameters, or methods. Useful for comparing alternative models or experimental conditions.

Usage

compare_scenarios(
  result_list,
  metrics = c("consumption", "growth", "efficiency"),
  confidence_level = 0.95
)

Arguments

result_list

Named list of FB4 result objects

metrics

Vector of metrics to compare

confidence_level

Confidence level for comparisons

Value

A named list with five elements:

n_scenarios

Integer. Number of scenarios compared.

scenario_names

Character vector of scenario names.

metrics_compared

Character vector of metrics requested.

confidence_level

Numeric. Confidence level as supplied.

scenario_data

data.frame with one row per scenario. Always contains scenario, method, backend, and converged. Additional *_est and *_se columns are appended for each requested metric (consumption, growth, efficiency, p_value).

When at least two scenarios provide uncertainty estimates, statistical_tests is appended (list of pairwise test results). best_performers (named list of scenario names with highest estimated value per metric) is always appended.

Examples

# \donttest{
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)
)
#> Bioenergetic object created for: Oncorhynchus tshawytscha
bio$species_params$predator$ED_ini <- 5000
bio$species_params$predator$ED_end <- 5500
r1 <- run_fb4(bio, strategy = "direct", p_value = 0.4, verbose = FALSE)
#> Validation warnings:
#> Missing optional parameters (will be calculated): CG1, CG2
#> Object is ready for simulation
#> Validation warnings:
#> Missing optional parameters (will be calculated): CG1, CG2
#> Object is ready for simulation
#> Processing species parameters...
#> Processing temporal data...
#> No indigestible fraction data provided, using default 0% for all prey (FB4 default)
#> Processing simulation settings...
#> Simulation data preparation complete. Ready for simulation.
r2 <- run_fb4(bio, strategy = "direct", p_value = 0.7, verbose = FALSE)
#> Validation warnings:
#> Missing optional parameters (will be calculated): CG1, CG2
#> Object is ready for simulation
#> Validation warnings:
#> Missing optional parameters (will be calculated): CG1, CG2
#> Object is ready for simulation
#> Processing species parameters...
#> Processing temporal data...
#> No indigestible fraction data provided, using default 0% for all prey (FB4 default)
#> Processing simulation settings...
#> Simulation data preparation complete. Ready for simulation.
comparison <- compare_scenarios(list(low_p = r1, high_p = r2))
# }