Skip to contents

Extracts consumption results from FB4 simulations with uncertainty propagation when available. Works with all fitting methods.

Usage

get_consumption_uncertainty(
  result,
  individual_id = NULL,
  confidence_level = 0.95
)

Arguments

result

FB4 result object

individual_id

Individual ID for hierarchical models (NULL for population mean)

confidence_level

Confidence level for intervals (default 0.95)

Value

A named list with eight elements:

estimate

Numeric. Total consumption estimate (g) for the simulation period; NA when unavailable.

se

Numeric. Standard error of the estimate; NA for methods without uncertainty quantification (e.g. "direct", "binary_search", "optim").

ci_lower

Numeric. Lower bound of the confidence interval; NA when se is unavailable.

ci_upper

Numeric. Upper bound of the confidence interval; NA when se is unavailable.

method

Character. Fitting method used (e.g. "direct", "mle", "hierarchical").

backend

Character. Computational backend ("r" or "tmb").

has_uncertainty

Logical. TRUE when standard errors and confidence intervals are populated.

individual_id

As supplied; the requested individual index, or NULL for the population mean.

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
result <- run_fb4(bio, strategy = "direct", p_value = 0.5, 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.
consumption <- get_consumption_uncertainty(result)
# }