Skip to content

Instantly share code, notes, and snippets.

View ryanbthomas's full-sized avatar

Ryan Thomas ryanbthomas

View GitHub Profile
@ryanbthomas
ryanbthomas / example.R
Created June 17, 2020 03:02
Vectorize Example
library(microbenchmark)
library(purrr)
library(tibble)
num_sims <- 1000
lambda <- 0.15
mu <- 7
sigma <- 2
---
title: "R Notebook"
output: html_notebook
---
```{r}
# setup
library(readr)
library(dplyr)
library(forcats)
@ryanbthomas
ryanbthomas / safely_iterate.R
Created February 11, 2020 14:50
Iteration Safely over functions
# Rules
library(purrr)
library(dplyr)
library(tibble)
dat <- tibble(x = 1:3, y = 4:6)
f1 <- function(tbl) {
mutate(tbl, z = x*y) %>% select(z)
x <- rnorm(1000, 7, 2)
noise <- rnorm(1000)
y <- 5 + 2 * x + noise
df <- data.frame(x = x, y = y)
test_idx <- sample(1000, 100)
test_df <- df[test_idx, ]
@ryanbthomas
ryanbthomas / rsvr_design.md
Last active May 13, 2019 02:41
rsvr_design

Rsvr

This is document is an attempt to define the minimum viable product for a data structure which reserving methodologies can be built off of. The final section has some ideas about the API for rsvr.

tri_df (triangle dataframe)

A tabular data structure (a subset of tibble), used to hold historical claim data that is an input to reserving analysis. It has the following columns:

  • cohort: (integer or string) [required] A variable that groups claims, or policies together whose development is tracked over time. For example, this might be accident year or underwriting quarter.
Missouri DOI allows you to request zip code level aggregated datasets for several lines of business. This has to be requested via email.
If combined with Census Information on income/race it could be used as a monitor for redlining.
https://insurance.mo.gov/reports/