Simplify multiple simulations and group them after computing quantile and median value (per species, fleet, metier, age, year). A selected simulation is kept to illustrate a possible way.
Usage
IAM.format_quant(var_format, probs = c(0.25, 0.75), select_indiv = 1)
Arguments
- var_format
Tibble or data.frame format produced by
IAM.format
.- probs
Quantile arguments for the values distribution once grouped. Vector of 2 numeric values in [0, 1].
- select_indiv
Single numeric value which allow to conserve a single simulation value for example. Default is 1.
Value
Format : long format for ggplot and dplyr analysis to facilitate filter and summary computations. If the variable is not defined for a specific dimension (column), this column is filled with NA.
- sim_name
Simulation name. chr.
- variable
Single value repeated, but is needed if multiple variables are assembled with
bind_row()
. chr vector- species
Species names, can contain dynamic and static species depending on the variable selected.. chr vector
- fleet
Fleet names. fct vector
- metier
Metier names. fct vector
- age
Ages for dynamic species. fct vector
- year
year step for the simulation. dbl vector
- quant1
First quantile from
probs
argument.- quant2
Second quantile from
probs
argument.- median
Median computed from the grouped values.
- value
Value of the variable for every column place indicated on the same row. dbl vector
Examples
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
library(magrittr)
data("IAM_input_2009")
data("IAM_argum_2009")
sim_statu_quo <- IAM::IAM.model(objArgs = IAM_argum_2009, objInput = IAM_input_2009)
res1 <- IAM.format(sim_statu_quo, c("SSB"), n = 1) %>%
dplyr::filter(species == "ARC", year < 2012)
res2 <- mutate(res1, n = 2, value = value + rnorm(1, sd = 100))
res <- rbind(res1, res2)
IAM.format_quant(res, c(0.025, 0.975), 2)
#> # A tibble: 3 × 12
#> sim_name variable species fleet metier age year quant1 quant2 median value
#> <chr> <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 NA SSB ARC NA NA NA 2009 18723. 18747. 18735. 18747.
#> 2 NA SSB ARC NA NA NA 2010 17991. 18014. 18002. 18015.
#> 3 NA SSB ARC NA NA NA 2011 17221. 17244. 17232. 17244.
#> # … with 1 more variable: nsim <int>