Learn R Programming

fb4package (version 2.0.0)

compare_individuals: Compare individuals from hierarchical models

Description

Compares performance metrics between individuals in hierarchical models. Provides statistical summaries and identifies outliers.

Usage

compare_individuals(result, metrics = "all", confidence_level = 0.95)

Value

A named list with at minimum three context elements:

n_individuals (integer), metrics_compared (character vector), and confidence_level (numeric). Depending on

metrics, the following sub-lists are appended; each is produced by an internal summary helper and contains metric_name,

n_valid, mean, sd, min, max,

median, cv, range, outliers, and

performance: consumption, efficiency, and

p_value. The growth element (when requested) is itself a list with two such summaries (total_growth and

relative_growth). A rankings

data.frame (one row per individual; columns for per-metric ranks, composite_rank, and

overall_rank) is always appended. Stops with an error if

result was not produced by the hierarchical method.

Arguments

result

FB4 result object from hierarchical method

metrics

Vector of metrics to compare ("consumption", "growth", "efficiency", "all")

confidence_level

Confidence level for comparisons (default 0.95)

Examples

Run this code
# \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)
)
bio$species_params$predator$ED_ini <- 5000
bio$species_params$predator$ED_end <- 5500
mr_data <- data.frame(
  individual_id  = paste0("fish_", 1:5),
  initial_weight = c(10, 12, 11, 13, 9),
  final_weight   = c(80, 95, 85, 100, 70)
)
result_hier <- run_fb4(bio, strategy = "hierarchical", backend = "tmb",
                       fit_to = "Weight", observed_weights = mr_data,
                       verbose = FALSE)
comparison <- compare_individuals(result_hier)
# }

Run the code above in your browser using DataLab