Install the Package from GitHub

# install.packages("devtools")

remotes::install_github("kwb-r/kwb.resilience", dependencies = TRUE, build_vignettes = TRUE)

note: this will also install two handy KWB packages kwb.event and kwb.plot and their CRAN dependencies.

Load the Package


Use the Package

The following sections demonstrate the three main functions of the package:

Severity and Resilience

The function resilience.severity calculates severity as outlined in Matzinger et al. (2018). The following example applies the function for scenario 4 of the test data set, using Pa = 2 mg/L as a lower threshold (for river fish) and Pmax = 0 mg/L as worst possible performance. Note: The function also works for upper thresholds.

The resilience index Res0 can then be calculated as 1-severity:

Resilience Indices Separate for Each Event

A time series can contain several events when performance P(t) violates acceptable threshold Pa. The function allows calculation of resilience indices separately for each event. Each line in the resulting data.frame shows one event. Again, let’s make an example for scenario 4:

Let’s plot the two failure events of scenario 4 (beginning and end is marked by vertical grey lines). The red line shows Pa = 2 mg/L. For the evaluation of resilience indices severity and Res0, only the area below Pa is integrated (in the case of an upper threshold it would be the area above Pa).

Resilience indices for entire time series

The function resi.summary allows calculating resilience indices from Matzinger et al. (2018) for entire time series. The function combines complete integration of time series (e.g., for Res0) with event means (such as mean recovery time in per cent mean_trec_percent). In the case of resilience.summary all the time series (scenarios in test data) are evaluated. Each line of result shows result for one time series: