Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/kasaai/simulationmachine
- Owner: kasaai
- License: other
- Created: 2019-08-19T19:41:59.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-25T04:40:50.000Z (over 5 years ago)
- Last Synced: 2024-08-13T07:15:33.651Z (6 months ago)
- Topics: actuarial-science, neural-networks, reserving, rstats, simulation
- Language: R
- Homepage: https://blog.kasa.ai/posts/simulation-machine/
- Size: 385 KB
- Stars: 19
- Watchers: 2
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE.md
Awesome Lists containing this project
- jimsghstars - kasaai/simulationmachine - Individual claims history simulation machine (R)
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")
```
## ExampleFirst, 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.