Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kasaai/simulationmachine

Individual claims history simulation machine
https://github.com/kasaai/simulationmachine

actuarial-science neural-networks reserving rstats simulation

Last synced: about 2 months ago
JSON representation

Individual claims history simulation machine

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# simulationmachine

[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![Travis build status](https://travis-ci.org/kasaai/simulationmachine.svg?branch=master)](https://travis-ci.org/kasaai/simulationmachine)

This package implements the claims history simulation algorithm detailed in [*An Individual Claims History Simulation Machine*](https://www.mdpi.com/2227-9091/6/2/29) by Andrea Gabrielli and Mario V. Wüthrich. The goal is to provide an easy-to-use interface for generating claims data that can be used for loss reserving research.

## Installation

You can install the development version from [GitHub](https://github.com/) with:

``` r
# install.packages("remotes")
remotes::install_github("kasaai/simulationmachine")
```
## Example

First, we can specify the parameters of a simulation using `simulation_machine()`:

```{r}
library(simulationmachine)

charm <- simulation_machine(
num_claims = 50000,
lob_distribution = c(0.25, 0.25, 0.30, 0.20),
inflation = c(0.01, 0.01, 0.01, 0.01),
sd_claim = 0.85,
sd_recovery = 0.85
)

charm
```

Once we have the charm object, we can use `conjure()` to perform the simulation.

```{r, message=FALSE}
library(dplyr)
records <- conjure(charm, seed = 100)
glimpse(records)
```

Let's see how many claims we drew:

```{r}
records %>%
distinct(claim_id) %>%
count()
```

If you prefer to have each row of the dataset to correspond to a claim, you can simply pivot the data with tidyr:

```{r}
records_wide <- records %>%
tidyr::pivot_wider(
names_from = development_year,
values_from = c(paid_loss, claim_status_open),
values_fill = list(paid_loss = 0)
)

glimpse(records_wide)
````

-----

Please note that this project is released with a [Contributor Code of Conduct](https://github.com/kasaai/community/blob/master/CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.