Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryanbthomas/reproducible-reserving
An example workflow for actuarial reserving using R/Rmarkdown
https://github.com/ryanbthomas/reproducible-reserving
Last synced: 9 days ago
JSON representation
An example workflow for actuarial reserving using R/Rmarkdown
- Host: GitHub
- URL: https://github.com/ryanbthomas/reproducible-reserving
- Owner: ryanbthomas
- License: apache-2.0
- Created: 2019-12-11T19:41:33.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-29T01:05:58.000Z (almost 5 years ago)
- Last Synced: 2024-08-13T07:15:23.081Z (4 months ago)
- Language: R
- Size: 46.9 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - ryanbthomas/reproducible-reserving - An example workflow for actuarial reserving using R/Rmarkdown (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>"
)
```# reproducible-reserving
Experiments that (hopefully) lead to an example workflow for actuarial reserving using R/Rmarkdown.
## Why a workflow in R/Rmarkdown?
Spreadsheets currently dominate the workflows of actuaries and the following pain points associated with them:
- Single files make it difficult for the distributed teams of the modern workplace to work in parallel.
- Spreadsheets are prone to reproducibility problems, as steps in analysis might be encoded several different ways (e.g., formula, macro, separate documentation, memory of analyst).
- Logic and orchestration embedded in macros is often opaque and difficult to maintain.
- Changes/errors may be difficult to spot because the model and view are on top of each other.
- Once created, spreadsheet based workflows are often brittle to changes in methodology or implementation.These are problems that can be addressed by moving to an R/RMarkdown based workflow supported by distributed version control (git).
## Example
Since my primary goal is investigate workflow alternatives, my initial example will be pretty simple, and consist of the following pieces:
- Simulate incremental paid data using [{simulationmachine}](https://blog.kasa.ai/posts/simulation-machine/) package.
- Clean, transform, filter, and aggregate claim data into form needed for analysis
- Data Diagnostics (examples)
- Large Claim movements
- Actual vs Expected
- Traditional reserve review including at least the following
- Chainladder
- BF
- Cape Cod
- Selection based on a rule (e.g. default method weights)
- Report
- Reserve Report (rmarkdown rendered to pdf)
- Summary Tables (spreadsheet)
- Deck for Board Presentation (rmarkdown rendered to slides)Although this analysis is quite straightforward, one of the benefits of an R/Rmarkdown workflow is the easy at which new methodologies can be incorporated. I intend to demostrate this as this project evolves.
## Try it yourself
### Note on gt package
This project makes use of two amazing amazing packages that currently have a small
conflict with each other. The renv package is used to control dependencies to lock
down the execution environment for this project, and the gt package which is used
to create presentation ready tables in Rmarkdown reports. As of this writing
(2019-12-29), gt is not on CRAN and so has to be installed from github, but there is currently an issue doing this directly into environments managed by renv (link)1. clone github repo to local machine
```{bash, eval=FALSE}
git clone https://github.com/rstudio/gt.git
```2. Run check and build gt package
```{r, eval=FALSE}
# install devtools if not already installed
# install.packages("devtools")# run R build check to confirm that all dependencies are present
devtools::check()# build gt package locally
pkg_path <- devtools::build()
```
3. Install the package localally```{r, eval=FALSE}
devtools::install_local(pkg_path)
```Once you have the gt package installed on your system you can setup this project
1. clone repo to you computer
```{bash, eval=FALSE}
git clone https://github.com/actuarialvoodoo/reproducible-reserving.git
```2. Open up Rstudio project and restore dependencies
```{r, eval=FALSE}
renv::restore()
```3. Run drake plan
```{r, eval=FALSE}
drake::r_make()
```