knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
This package implements the claims history simulation algorithm detailed in An Individual Claims History Simulation Machine 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.
You can install the development version from GitHub with:
# install.packages("remotes") remotes::install_github("kasaai/simulationmachine")
First, we can specify the parameters of a simulation using simulation_machine()
:
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.
library(dplyr) records <- conjure(charm, seed = 100) glimpse(records)
Let's see how many claims we drew:
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. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.