# Scenario Weights for Importance Measurement (**SWIM**) – an **R** package for sensitivity analysis

10. January 2020

^{2}University of Toronto,^{3}Assicurazioni Generali S.p.A,^{4}DEAMS, University of Trieste,^{5}Cass Business School, City, University of London10. January 2020

Abstract

The**SWIM**package implements a flexible sensitivity analysis framework, based primarily on results and tools developed by Pesenti, Millossovich, and Tsanakas (2019).

**SWIM**provides a stressed version of a stochastic model, subject to model components (random variables) fulfilling given probabilistic constraints (stresses). Possible stresses can be applied on moments, probabilities of given events, and risk measures such as Value-at-Risk and Expected Shortfall.

**SWIM**operates upon a single set of simulated scenarios from a stochastic model, returning scenario weights, which encode the required stress and allow monitoring the impact of the stress on all model components. The scenario weights are calculated to minimise the relative entropy with respect to the baseline model, subject to the stress applied. As well as calculating scenario weights, the package provides tools for the analysis of stressed models, including plotting facilities and evaluation of sensitivity measures.

**SWIM**does not require additional evaluations of the simulation model or explicit knowledge of its underlying statistical and functional relations; hence it is suitable for the analysis of black box models. The capabilities of

**SWIM**are demonstrated through a case study of a credit portfolio model.

# 1 Introduction

## 1.1 Background and contribution

Complex quantitative models are used extensively in actuarial and financial risk management applications, as well as in wider fields such as environmental risk modelling (Tsanakas and Millossovich 2016; Borgonovo and Plischke 2016; Pesenti, Millossovich, and Tsanakas 2019). The complexity of such models (high dimensionality of inputs; non-linear relationships) motivates the performance of sensitivity analyses, with the aim of providing insight into the ways that model inputs interact and impact upon the model output.

When model inputs are subject to uncertainty, *global* sensitivity methods are often used, considering the full space of (randomly generated) multivariate scenarios, which represent possible configurations of the model input vector. The particular task of ranking the importance of different model inputs leads to the use of sensitivity measures, which assign a score to each model input. A rich literature on global sensitivity analysis exists, with variance decomposition methods being particularly prominent; see Saltelli et al. (2008) and Borgonovo and Plischke (2016) for wide-ranging reviews. The **R** package **sensitivity** (Iooss, Janon, and Pujol 2019) implements a wide range of sensitivity analysis approaches and measures.

We introduce an alternative approach to sensitivity analysis called *Scenario Weights for Importance Measurement* (**SWIM**) and present the **R** package implementing it (Pesenti et al. 2020). The aim of this paper is to provide an accessible introduction to the concepts underlying **SWIM** and a vignette demonstrating how the package is used. **SWIM** quantifies how distorting a particular model component (which could be a model input, output, or an intermediate quantity) impacts all other model components. The **SWIM** approach can be summarised as follows:

The starting point is a table of simulated scenarios, each column containing realisations of a different model component. This table forms the

*baseline model*as well as the dataset on which the**SWIM**bases its calculations.A

*stress*is defined as a particular modification of a model component (or group of components). This could relate to a change in moments, probabilities of events of interest, or risk measures, such as Value-at-Risk or Expected Shortfall (e.g. McNeil, Frey, and Embrechts (2015)).**SWIM**calculates a set of*scenario weights*, acting upon the simulated scenarios and thus modifying the relative probabilities of scenarios occurring. Scenario weights are derived such that the defined stress on model components is fulfilled, while keeping the distortion to the baseline model to a minimum, as quantified by the Kullback-Leibler divergence (relative entropy).Given the calculated scenario weights, the impact of the stress on the distributions of all model components is worked out and sensitivity measures, useful for ranking model components, are evaluated.

A key benefit of **SWIM** are that it provides a sensitivity analysis framework that is economical both computationally and in terms of the information needed to perform the analysis. Specifically, sensitivity analysis is performed using only one set of simulated scenarios. No further simulations are needed, thus eliminating the need for repeated evaluation of the model, which could be numerically expensive. Furthermore, the user of **SWIM** needs to know neither the explicit form of the joint distribution of model components nor the exact form of functional relations between them. Hence, **SWIM** is appropriate for the analysis of *black box* models, thus having a wide scope of applications.

The **SWIM** approach is largely based on Pesenti, Millossovich, and Tsanakas (2019) and uses theoretical results on risk measures and sensitivity measures developed in that paper. An early sensitivity analysis approach based on scenario weighting was proposed by Beckman and McKay (1987). The Kullback-Leibler divergence has been used extensively in the financial risk management literature – papers that are conceptually close to **SWIM** include Weber (2007); Breuer and Csiszár (2013); and Cambou and Filipović (2017). Some foundational results related to the minimisation of the Kullback-Leibler divergence are provided in Csiszár (1975).

## 1.2 Installation

The **SWIM** package can be installed from CRAN or through GitHub:

```
# directly from CRAN
install.packages("SWIM")
# and the development version from GitHub
devtools::install_github("spesenti/SWIM")
```

## 1.3 Structure of the paper

Section 2 provides an introduction to **SWIM**, illustrating key concepts and basic functionalities of the package on a simple example. Section
3 contains technical background on the optimisations that underlay the **SWIM** package implementation. Furthermore, Section 3 includes a brief reference guide, providing an overview of implemented **R** functions, objects, and graphical/analysis tools. Finally, a detailed case study of a credit risk portfolio is presented in Section 4. Through this case study, advanced capabilities of **SWIM** for sensitivity analysis are demonstrated.

Correspondence to Silvana Pesenti, Department of Statistical Sciences, University of Toronto, Canada. silvana.pesenti@utoronto.ca↩