TODO

# S4 method for FLQuants
performance(
  x,
  statistics,
  refpts = FLPar(),
  years = setNames(list(dimnames(x[[1]])$year), nm = dims(x[[1]])$maxyear),
  probs = c(0.1, 0.25, 0.5, 0.75, 0.9),
  mp = NULL
)

# S4 method for FLStock
performance(
  x,
  statistics,
  refpts = FLPar(),
  years = as.character(seq(dims(x)$minyear, dims(x)$maxyear)),
  metrics = FLCore::metrics(x),
  probs = NULL,
  mp = NULL
)

# S4 method for FLStocks
performance(
  x,
  statistics,
  refpts = FLPar(),
  years = dims(x[[1]])$maxyear,
  metrics = FLCore::metrics,
  probs = NULL,
  grid = missing,
  mp = NULL,
  mc.cores = 1
)

# S4 method for list
performance(
  x,
  statistics,
  refpts = FLPar(),
  years = dims(x[[1]])$maxyear,
  probs = NULL,
  grid = "missing",
  mp = NULL,
  mc.cores = 1,
  ...
)

# S4 method for FLom
performance(x, refpts = x@refpts, ...)

Arguments

statistics

statistics to be computed, as formula, name and description, list

refpts

Reference points for calculations, list

years

Years on which statistics should be computed, defaults to last year of input FLQuants

run

Object holding the results of forward projections, as a named FLQuants

Value

data.table Results of computing performance statistics.

Details

Each statistics is an object of class list object, with three elements, the first two of them compulsory:

  • An unnamed element of class formula, e.g. yearMeans(SB/SB0).

  • name: A short name to be output on tables and plots, of class character, e.g. "SB/SB0".

  • desc: A longer description of the statistics, of class character, e.g. "Mean spawner biomass relative to unfished"

Each statistic formula is evaluated against the metrics and refpts used in the function call. Formulas can thus use (i) the names of the FLQuants object or of the object returned by the call to metrics(), (ii) of the params in the refpts object and, for all classes but FLQuants, (iii) functions that can be called on object. See examples below for the necessary matching between metrics, refpts and the statistics formulas.

See also

FLQuants

Author

Iago Mosqueira, EC JRC

Examples


# LOAD example FLmse object
data(sol274)
#> Warning: namespace ‘DBI’ is not available and has been replaced
#> by .GlobalEnv when processing object ‘om’
# GENERATE pseudo-run from last 20 years of OM
run <- window(stock(om), start=2012, end=2021)
# DEFINE statistics
statistics <- list(
  dCatch=list(~yearMeans(C[, -1]/C[, -dims(C)$year]),
    name="mean(C[t] / C[t-1])",
    desc="Mean absolute proportional change in catch"),
  varCatch=list(~yearVars(C),
    name="var(C)",
    desc="Variance in catch"),
  varF=list(~yearVars(F),
    name="var(F)",
    desc="Variance in fishing mortality"))
# COMPUTE performance
performance(run, statistics, refpts=FLPar(MSY=110000),
  metrics=list(C=catch, F=fbar), years=list(2016:2021))
#>      statistic year        data iter                name
#>   1:    dCatch 2021 0.902979992    1 mean(C[t] / C[t-1])
#>   2:    dCatch 2021 0.902979992    2 mean(C[t] / C[t-1])
#>   3:    dCatch 2021 0.902979992    3 mean(C[t] / C[t-1])
#>   4:    dCatch 2021 0.902979992    4 mean(C[t] / C[t-1])
#>   5:    dCatch 2021 0.902979992    5 mean(C[t] / C[t-1])
#>  ---                                                    
#> 296:      varF 2021 0.022486666   96              var(F)
#> 297:      varF 2021 0.007926315   97              var(F)
#> 298:      varF 2021 0.011982839   98              var(F)
#> 299:      varF 2021 0.012743466   99              var(F)
#> 300:      varF 2021 0.015744298  100              var(F)
# Minimum statistic, named list with formula and name
performance(run, statistics=list(CMSY=list(~yearMeans(C/MSY), name="CMSY")),
  refpts=FLPar(MSY=110000), metrics=list(C=catch, F=fbar),
  years=list(2012:2021))
#>      statistic year      data iter name
#>   1:      CMSY 2021 0.1193508    1 CMSY
#>   2:      CMSY 2021 0.1193508    2 CMSY
#>   3:      CMSY 2021 0.1193508    3 CMSY
#>   4:      CMSY 2021 0.1193508    4 CMSY
#>   5:      CMSY 2021 0.1193508    5 CMSY
#>   6:      CMSY 2021 0.1193508    6 CMSY
#>   7:      CMSY 2021 0.1193508    7 CMSY
#>   8:      CMSY 2021 0.1193508    8 CMSY
#>   9:      CMSY 2021 0.1193508    9 CMSY
#>  10:      CMSY 2021 0.1193508   10 CMSY
#>  11:      CMSY 2021 0.1193508   11 CMSY
#>  12:      CMSY 2021 0.1193508   12 CMSY
#>  13:      CMSY 2021 0.1193508   13 CMSY
#>  14:      CMSY 2021 0.1193508   14 CMSY
#>  15:      CMSY 2021 0.1193508   15 CMSY
#>  16:      CMSY 2021 0.1193508   16 CMSY
#>  17:      CMSY 2021 0.1193508   17 CMSY
#>  18:      CMSY 2021 0.1193508   18 CMSY
#>  19:      CMSY 2021 0.1193508   19 CMSY
#>  20:      CMSY 2021 0.1193508   20 CMSY
#>  21:      CMSY 2021 0.1193508   21 CMSY
#>  22:      CMSY 2021 0.1193508   22 CMSY
#>  23:      CMSY 2021 0.1193508   23 CMSY
#>  24:      CMSY 2021 0.1193508   24 CMSY
#>  25:      CMSY 2021 0.1193508   25 CMSY
#>  26:      CMSY 2021 0.1193508   26 CMSY
#>  27:      CMSY 2021 0.1193508   27 CMSY
#>  28:      CMSY 2021 0.1193508   28 CMSY
#>  29:      CMSY 2021 0.1193508   29 CMSY
#>  30:      CMSY 2021 0.1193508   30 CMSY
#>  31:      CMSY 2021 0.1193508   31 CMSY
#>  32:      CMSY 2021 0.1193508   32 CMSY
#>  33:      CMSY 2021 0.1193508   33 CMSY
#>  34:      CMSY 2021 0.1193508   34 CMSY
#>  35:      CMSY 2021 0.1193508   35 CMSY
#>  36:      CMSY 2021 0.1193508   36 CMSY
#>  37:      CMSY 2021 0.1193508   37 CMSY
#>  38:      CMSY 2021 0.1193508   38 CMSY
#>  39:      CMSY 2021 0.1193508   39 CMSY
#>  40:      CMSY 2021 0.1193508   40 CMSY
#>  41:      CMSY 2021 0.1193508   41 CMSY
#>  42:      CMSY 2021 0.1193508   42 CMSY
#>  43:      CMSY 2021 0.1193508   43 CMSY
#>  44:      CMSY 2021 0.1193508   44 CMSY
#>  45:      CMSY 2021 0.1193508   45 CMSY
#>  46:      CMSY 2021 0.1193508   46 CMSY
#>  47:      CMSY 2021 0.1193508   47 CMSY
#>  48:      CMSY 2021 0.1193508   48 CMSY
#>  49:      CMSY 2021 0.1193508   49 CMSY
#>  50:      CMSY 2021 0.1193508   50 CMSY
#>  51:      CMSY 2021 0.1193508   51 CMSY
#>  52:      CMSY 2021 0.1193508   52 CMSY
#>  53:      CMSY 2021 0.1193508   53 CMSY
#>  54:      CMSY 2021 0.1193508   54 CMSY
#>  55:      CMSY 2021 0.1193508   55 CMSY
#>  56:      CMSY 2021 0.1193508   56 CMSY
#>  57:      CMSY 2021 0.1193508   57 CMSY
#>  58:      CMSY 2021 0.1193508   58 CMSY
#>  59:      CMSY 2021 0.1193508   59 CMSY
#>  60:      CMSY 2021 0.1193508   60 CMSY
#>  61:      CMSY 2021 0.1193508   61 CMSY
#>  62:      CMSY 2021 0.1193508   62 CMSY
#>  63:      CMSY 2021 0.1193508   63 CMSY
#>  64:      CMSY 2021 0.1193508   64 CMSY
#>  65:      CMSY 2021 0.1193508   65 CMSY
#>  66:      CMSY 2021 0.1193508   66 CMSY
#>  67:      CMSY 2021 0.1193508   67 CMSY
#>  68:      CMSY 2021 0.1193508   68 CMSY
#>  69:      CMSY 2021 0.1193508   69 CMSY
#>  70:      CMSY 2021 0.1193508   70 CMSY
#>  71:      CMSY 2021 0.1193508   71 CMSY
#>  72:      CMSY 2021 0.1193508   72 CMSY
#>  73:      CMSY 2021 0.1193508   73 CMSY
#>  74:      CMSY 2021 0.1193508   74 CMSY
#>  75:      CMSY 2021 0.1193508   75 CMSY
#>  76:      CMSY 2021 0.1193508   76 CMSY
#>  77:      CMSY 2021 0.1193508   77 CMSY
#>  78:      CMSY 2021 0.1193508   78 CMSY
#>  79:      CMSY 2021 0.1193508   79 CMSY
#>  80:      CMSY 2021 0.1193508   80 CMSY
#>  81:      CMSY 2021 0.1193508   81 CMSY
#>  82:      CMSY 2021 0.1193508   82 CMSY
#>  83:      CMSY 2021 0.1193508   83 CMSY
#>  84:      CMSY 2021 0.1193508   84 CMSY
#>  85:      CMSY 2021 0.1193508   85 CMSY
#>  86:      CMSY 2021 0.1193508   86 CMSY
#>  87:      CMSY 2021 0.1193508   87 CMSY
#>  88:      CMSY 2021 0.1193508   88 CMSY
#>  89:      CMSY 2021 0.1193508   89 CMSY
#>  90:      CMSY 2021 0.1193508   90 CMSY
#>  91:      CMSY 2021 0.1193508   91 CMSY
#>  92:      CMSY 2021 0.1193508   92 CMSY
#>  93:      CMSY 2021 0.1193508   93 CMSY
#>  94:      CMSY 2021 0.1193508   94 CMSY
#>  95:      CMSY 2021 0.1193508   95 CMSY
#>  96:      CMSY 2021 0.1193508   96 CMSY
#>  97:      CMSY 2021 0.1193508   97 CMSY
#>  98:      CMSY 2021 0.1193508   98 CMSY
#>  99:      CMSY 2021 0.1193508   99 CMSY
#> 100:      CMSY 2021 0.1193508  100 CMSY
#>      statistic year      data iter name
# return quantiles
performance(run, statistics, refpts=FLPar(MSY=110000),
  metrics=list(C=catch, F=fbar), years=list(2012:2021),
  probs =  c(0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 0.95))
#>     statistic year                name         data prob
#>  1:    dCatch 2021 mean(C[t] / C[t-1]) 9.516750e-01 0.05
#>  2:    dCatch 2021 mean(C[t] / C[t-1]) 9.516750e-01 0.10
#>  3:    dCatch 2021 mean(C[t] / C[t-1]) 9.516750e-01 0.25
#>  4:    dCatch 2021 mean(C[t] / C[t-1]) 9.516750e-01 0.50
#>  5:    dCatch 2021 mean(C[t] / C[t-1]) 9.516750e-01 0.75
#>  6:    dCatch 2021 mean(C[t] / C[t-1]) 9.516750e-01 0.90
#>  7:    dCatch 2021 mean(C[t] / C[t-1]) 9.516750e-01 0.95
#>  8:  varCatch 2021              var(C) 5.537231e+06 0.05
#>  9:  varCatch 2021              var(C) 5.537231e+06 0.10
#> 10:  varCatch 2021              var(C) 5.537231e+06 0.25
#> 11:  varCatch 2021              var(C) 5.537231e+06 0.50
#> 12:  varCatch 2021              var(C) 5.537231e+06 0.75
#> 13:  varCatch 2021              var(C) 5.537231e+06 0.90
#> 14:  varCatch 2021              var(C) 5.537231e+06 0.95
#> 15:      varF 2021              var(F) 4.429523e-03 0.05
#> 16:      varF 2021              var(F) 5.405319e-03 0.10
#> 17:      varF 2021              var(F) 7.461941e-03 0.25
#> 18:      varF 2021              var(F) 9.273349e-03 0.50
#> 19:      varF 2021              var(F) 1.140404e-02 0.75
#> 20:      varF 2021              var(F) 1.303102e-02 0.90
#> 21:      varF 2021              var(F) 1.449680e-02 0.95
#>     statistic year                name         data prob
# DEFINE statistics without summaries
statistics <- list(
  CMSY=list(~yearMeans(C/MSY),
    name="CMSY",
    desc="Catch over MSY"))
# COMPUTE performance
perf <- performance(run, statistics, refpts=FLPar(MSY=110000),
  metrics=list(C=catch), years=list(2012:2021))
# COMPUTE summaries
perf[, .(CMSY=mean(data))]
#>         CMSY
#> 1: 0.1193508
perf <- performance(FLStocks(B=run, A=run), statistics, refpts=FLPar(MSY=110000),
   metrics=list(C=catch), years=list(2000:2015))
#> Error in .local(x, ...): years must be present in input object 'x' dimensions.