Description Usage Arguments Value Note Author(s) Examples
Function for forward and backward model selection algorithm using information criteria to obtain frequency and severity models for actuarial pricing models the routine also dynamically adjusts the categories for variables that are not significant. This function is intended for analysing categorical explanatory varibles.
1 2 3 | forwardBackStepAIC(ratingFact, countVar, sevVar, factLevels=1, timeVar, IC="BIC", consistThresh=60, theData,
analysisType="frequency", myDistr="poisson", theLink="log", exposureName="Exposure", handicap=0,
myDocumentTitle="Automated Pricing GLM", theAlg="forward", plotCharts=TRUE, ...)
|
|
this a character vector denoting the column headers of rating factors in your table ( |
|
this is a character denoting the claims count column |
|
this is a character denoting the column header of the severity variable |
|
this is a list of matrices (or data.frames) that denote the mapping of the rating factors from their current categories to their logical aggregatable variables |
|
this is a character denoting the column header of the year variable. This variable must be specified because time consistency analysis is carried out by using interaction terms with the year variable. |
|
This is a character string denoting whether the information criterion used should be AIC (Akaike Information Criterion) or BIC (Bayesian Information Criterion) |
|
Set this to the threshold for median consistency, denoting that the model fit of interaction
of the variables with Year is consistent to |
|
this is the data set that will be used for the analysis containing the rating factors, exposure, severity, claim counts, and year |
|
this is a character string denoting which distribution should be used in the analysis e.g. "poisson", "Gamma" |
|
this is the link function to be used in the analysis |
|
this is a character string denoting the column name of the exposure (in Years) |
|
extra penalty for the information criterion, it is added to the IC of the candiate model to alter how dificult it is to accept variables |
|
This is a character string for the title of the document |
|
this is the algorithm to be used either "forward" or "backward". |
|
this is a logical variable as to whether the charts should be plotted |
The output is the frequency or severity model from the chosen algorithm theAlg
please pay attention to the structure of the table requires, since it is non-standard as far as in most modelling systems a separate policy and claims table is used for the analysis
Chibisi Chima-Okereke cchima-okereke@mango-solutions.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #Loading the data
data(policyTable)
#Preparing rating factor names and mapping tables
myRatingFactors <- c("BonusMalus", "WeightClass", "Region", "Age", "Mileage", "Usage")
ratingFactorLevels <- lapply(myRatingFactors, function(x){matrix(as.character(levels(policyTable[,x])))})
names(ratingFactorLevels) <- myRatingFactors
ratingFactorLevels$Mileage <- cbind(ratingFactorLevels$Mileage, c("0-12500", "0-12500", "> 12500"))
# Example 1: Executing forward algorithm for poisson risk model
outputModelForwardFreq <- forwardBackStepAIC(ratingFact = myRatingFactors, countVar = "NoClaims",
sevVar = "GrossIncurred", factLevels = ratingFactorLevels, timeVar = "Year", IC = "BIC",
consistThresh = 60, theData = policyTable, analysisType = "frequency",
myDistr = "poisson", theLink = "log", exposureName = "Exposure",
handicap = 0, myDocumentTitle = "Automated Pricing GLM", theAlg = "forward",
plotCharts = TRUE)
# Example 2: Writing process to PDF and log file for documentation purposes
myFolder <- getwd()
pdf(file = file.path(paste(myFolder, "GLMOutput.pdf", sep = "")), height = 7, width = 11)
par(mfrow = c(1,1), cex.main = 1, cex.axis = .9, cex.lab = 1, cex = 1)
sink(file = file.path(paste(myFolder, "GLMOutput.doc", sep = "")))
outputModelForwardFreq <- forwardBackStepAIC(ratingFact = myRatingFactors, countVar = "NoClaims",
sevVar = "GrossIncurred", factLevels = ratingFactorLevels, timeVar = "Year", IC = "BIC",
consistThresh = 60, theData = policyTable, analysisType = "frequency",
myDistr = "poisson", theLink = "log", exposureName = "Exposure",
handicap = 0, myDocumentTitle = "Automated Pricing GLM", theAlg = "forward",
plotCharts = TRUE)
sink()
dev.off()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.