knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
The package and site are still under construction...
The goal of brixtools is to make it easier to model non-life insurance data with deductibles using maximum likelihood methods. The package is currently in its infancy and many more features can be implemented.
You can currently install brixtools from github with:
# install.packages("devtools") devtools::install_github("kbrix/brixtools")
Included in the package is a simulated data set of 10000 policies. See the documentation for normal_poisson_policy
. Below is one of the policies with two losses, but only one (reported) claim:
library(brixtools) occurrence <- lapply(normal_poisson_policy, function(x) unlist(x["occurrence"])) reported <- lapply(normal_poisson_policy, function(x) unlist(x["reported"])) set <- intersect(which(occurrence == 2), which(reported == 1))[1] normal_poisson_policy[[set]]
Since the losses (and therefore also claims) within each policy are assumed i.i.d., we can simplify the indexing of the data to ease numerical procedures, see normal_poisson_x
and normal_poisson_n
.
The Normal-Poisson log-likelihood is called using normal_poisson_log_likelihood
and can be used with brix_simple
to find the optimum yielding the maximum likelihood estimates of the parameters:
model <- brix_simple(optimizer = optim, fn = normal_poisson_log_likelihood, X = normal_poisson_x, N = normal_poisson_n, par = rep(1, 3), control = list(fnscale = -1), method = "Nelder-Mead", hessian = TRUE) summary(model)
The true parameter values are 1.5 for the mean and standard deviation for the normal distribution and the mean for the non-thinned Poisson is 0.1. The model can be augmented with the unobserved claims, i.e., the losses smaller that the deductibles. This is advantageous for performing various tests on the claims, e.g. the claim distribution assumption (is it really normal?). This is done using augment
:
model_augmented <- augment(model) print(model_augmented)
Checking the p-values, we see that they are large and it is fair to say that the normal distribution fits well. This is not surpirsing, as the data was normal to begin with. We may also compare Q-Q plots as follows:
plot(model_augmented) plot(model_augmented, augment = FALSE)
The augmented Q-Q plots looks great.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.