Title: | Casualty Actuarial Society Individual Claim Simulator |
---|---|
Description: | It is an open source insurance claim simulation engine sponsored by the Casualty Actuarial Society. It generates individual insurance claims including open claims, reopened claims, incurred but not reported claims and future claims. It also includes claim data fitting functions to help set simulation assumptions. It is useful for claim level reserving analysis. Parodi (2013) <https://www.actuaries.org.uk/documents/triangle-free-reserving-non-traditional-framework-estimating-reserves-and-reserve-uncertainty>. |
Authors: | Robert Bear [aut], Kailan Shang [aut, cre], Hai You [aut], Brian Fannin [ctb] |
Maintainer: | Kailan Shang <[email protected]> |
License: | GPL-3 |
Version: | 0.4 |
Built: | 2024-11-19 03:55:09 UTC |
Source: | https://github.com/cran/cascsim |
Plotting the CDF of data and fitted distribution
CDFPlot(object, ...) ## S4 method for signature 'FitDist' CDFPlot(object, n = missing)
CDFPlot(object, ...) ## S4 method for signature 'FitDist' CDFPlot(object, n = missing)
object |
FitDist Object |
... |
Additional function arguments |
n |
Number of samples, should not be used in current setting |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput CDFPlot(xFit)
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput CDFPlot(xFit)
Chi-Squared Test
ChiSqrTest(object, ...) ## S4 method for signature 'FitDist' ChiSqrTest(object)
ChiSqrTest(object, ...) ## S4 method for signature 'FitDist' ChiSqrTest(object)
object |
FitDist Object |
... |
Additional function arguments |
A dataset containing about 10,000 simulated claim records from 2012 to 2016 for illustration. The variables are as follows:
data(claimdata)
data(claimdata)
A data frame with 10030 rows and 15 variables
ClaimID. Claim ID
LoB. Line of Business (Auto, Liab, Property)
Type. Claim Type (N: Normal, H: High)
status. Current Claim Status (Closed, Open)
occurrenceDate. Claim Occurrence Date
reportDate. Claim Report Date
incurredLoss. Incurred Loss. For closed claim, it is the ultimate loss. For open claim, it is the estimated or booked loss.
osRatio. Outstanding Ratio
settlementDate. Claim Settlement Date.
Paid. Paid Loss by the valuation date. It equals incurredLoss * (1-osRatio)
totalLoss. Total loss before deductible and limit. If not available, it will be set as incurredLoss and not used for fitting.
Deductible. Deductible applied to the claim.
Limit. Limit applied to the claim.
LAE. Loss adjustment expense at the claim level. It can be omitted if idemnity and LAE are modeled together as incurred loss.
claimLiability. Indicating whether the claim is invalid and leads to zero payment. It excludes valid claims that are smaller than deductibles.
Claim data fitting analysis at line/type/status level
claimFitting(object, claimData, ...) ## S4 method for signature 'Simulation,data.frame' claimFitting(object, claimData, startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"), lineList = object@lines, typeList = object@types, discreteDist = c("Poisson", "NegativeBinomial", "Geometric"), continuousDist = c("Normal", "Lognormal", "Pareto", "Weibull", "Gamma", "Uniform", "Exponential"), copulaList = c("normal"), fReportLag = TRUE, fSettlementLag = TRUE, fFrequency = TRUE, fSeverity = TRUE, fSSRCorrelation = TRUE, fFreqCorrelation = TRUE, copulaTest = TRUE, iTotalLoss = TRUE, fDeductible = TRUE, fLimit = TRUE, check = TRUE)
claimFitting(object, claimData, ...) ## S4 method for signature 'Simulation,data.frame' claimFitting(object, claimData, startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"), lineList = object@lines, typeList = object@types, discreteDist = c("Poisson", "NegativeBinomial", "Geometric"), continuousDist = c("Normal", "Lognormal", "Pareto", "Weibull", "Gamma", "Uniform", "Exponential"), copulaList = c("normal"), fReportLag = TRUE, fSettlementLag = TRUE, fFrequency = TRUE, fSeverity = TRUE, fSSRCorrelation = TRUE, fFreqCorrelation = TRUE, copulaTest = TRUE, iTotalLoss = TRUE, fDeductible = TRUE, fLimit = TRUE, check = TRUE)
object |
Simulation object |
claimData |
claim data including existing claims for RBNER and claim reopenness analysis |
... |
Additional parameters that may or may not be used. |
startDate |
Date after which claims are analyzed; |
evaluationDate |
Date of evaluation for existing claims and IBNR; |
lineList |
List of business lines to be included in claim fitting; |
typeList |
List of claim types to be included in claim fitting; |
discreteDist |
List of discrete distributions to try fitting (report lag, settlemet lag, frequency); |
continuousDist |
List of continuous distribution to try fitting (severity); |
copulaList |
List of copula to try fitting; |
fReportLag |
Boolean variable to indicate whether report lag needs to be fitted; |
fSettlementLag |
Boolean variable to indicate whether settlement lag needs to be fitted; |
fFrequency |
Boolean variable to indicate whether monthly frequency needs to be fitted; |
fSeverity |
Boolean variable to indicate whether severity needs to be fitted; |
fSSRCorrelation |
Boolean variable to indicate whether copula among severity, report lag and settlement lag needs to be fitted; |
fFreqCorrelation |
Boolean variable to indicate whether copula among frequencies of business lines needs to be fitted. |
copulaTest |
Whether to test copula. The testing could take a very long time; |
iTotalLoss |
Boolean variable to indicate whether total loss before deductible and limit is available for severity fitting; |
fDeductible |
Boolean variable to indicate whether deductible empirical distribution needs to be fitted; |
fLimit |
Boolean variable to indicate whether limit empirical distribution needs to be fitted; |
check |
Boolean variable to indicate whether graph of each tried distribution fitting needs to be generated and saved. |
library(cascsim) data(claimdata) lines<-c("Auto") types<-c("N") #exposure index index1 <- new("Index",monthlyIndex=c(rep(1,11),cumprod(c(1,rep(1.5^(1/12),11))), cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),rep(1.4,301))) #severity index index2 <- new("Index",monthlyIndex=c(cumprod(c(1,rep(1.03^(1/12),59))),rep(1.03^(5),300))) objan <- new("ClaimType", line="Auto",claimType="N",exposureIndex=index1,severityIndex=index2) objlist <- list(objan) simobj <- new("Simulation",lines=lines,types=types,claimobjs=objlist,iFit=TRUE, iCopula=FALSE, iReport=TRUE, workingFolder=tempdir()) simobj <- claimFitting(simobj,claimdata,fSSRCorrelation = FALSE, fSettlementLag = FALSE)
library(cascsim) data(claimdata) lines<-c("Auto") types<-c("N") #exposure index index1 <- new("Index",monthlyIndex=c(rep(1,11),cumprod(c(1,rep(1.5^(1/12),11))), cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),rep(1.4,301))) #severity index index2 <- new("Index",monthlyIndex=c(cumprod(c(1,rep(1.03^(1/12),59))),rep(1.03^(5),300))) objan <- new("ClaimType", line="Auto",claimType="N",exposureIndex=index1,severityIndex=index2) objlist <- list(objan) simobj <- new("Simulation",lines=lines,types=types,claimobjs=objlist,iFit=TRUE, iCopula=FALSE, iReport=TRUE, workingFolder=tempdir()) simobj <- claimFitting(simobj,claimdata,fSSRCorrelation = FALSE, fSettlementLag = FALSE)
Claim simulation at line/type/status level
claimSample(object, ...) ## S4 method for signature 'ClaimType' claimSample(object, claimData = data.frame(), startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"))
claimSample(object, ...) ## S4 method for signature 'ClaimType' claimSample(object, claimData = data.frame(), startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"))
object |
ClaimType object |
... |
Additional parameters that may or may not be used. |
claimData |
claim data including existing claims for RBNER and claim reopenness analysis; |
startDate |
Date from which claim data is included in the analysis; |
evaluationDate |
Date of evaluation. |
#run time is about 12s(>10s) and is commented out here to avoid long waiting time #library(cascsim) #data(claimdata) ##IBNR simulation #claimobj <- new("ClaimType", line="Auto",claimType="N",iRBNER=FALSE,iROPEN=FALSE, #iIBNR=TRUE,iUPR=FALSE, #IBNRfreqIndex=new("Index",startDate=as.Date("2016-01-01"), #monthlyIndex=rep(30,12)),iCopula=TRUE) #ibnrdata <- claimSample(claimobj,claimdata) #ibnrdata
#run time is about 12s(>10s) and is commented out here to avoid long waiting time #library(cascsim) #data(claimdata) ##IBNR simulation #claimobj <- new("ClaimType", line="Auto",claimType="N",iRBNER=FALSE,iROPEN=FALSE, #iIBNR=TRUE,iUPR=FALSE, #IBNRfreqIndex=new("Index",startDate=as.Date("2016-01-01"), #monthlyIndex=rep(30,12)),iCopula=TRUE) #ibnrdata <- claimSample(claimobj,claimdata) #ibnrdata
Claim simulation at line/type/status level
claimSimulation(object, ...) ## S4 method for signature 'Simulation' claimSimulation(object, claimData = data.frame(), startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31"), append = TRUE)
claimSimulation(object, ...) ## S4 method for signature 'Simulation' claimSimulation(object, claimData = data.frame(), startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31"), append = TRUE)
object |
Simulation object |
... |
Additional parameters that may or may not be used. |
claimData |
claim data including existing claims for RBNER and claim reopenness analysis; |
startDate |
Date after which claims are analyzed; |
evaluationDate |
Date of evaluation for existing claims and IBNR; |
futureDate |
Date of evaluation for UPR (future claims). |
append |
Boolean variable to indicate whether existing simulation results need to be kept. |
library(cascsim) data(claimdata) lines <- c("Auto") types <- c("N") AutoN <- new("ClaimType", line = "Auto", claimType = "N") AutoN@exposureIndex <- setIndex(new("Index",indexID="I1",tabulate= FALSE, startDate=as.Date("2012-01-01"), annualizedRate = 0)) # level exposure across time AutoN@frequency <- new("Poisson", p1 =50) AutoN@severityIndex <- setIndex(new("Index",indexID="I2",tabulate= FALSE, startDate=as.Date("2012-01-01"), annualizedRate = 0.02)) #assuming a 2% annual inflation AutoN@severity <- new("Lognormal", p1 =2, p2 =3) AutoN@deductible <- new("Empirical", empirical=matrix(c(0,1,100,100),2,2)) AutoN@limit <- new("Empirical", empirical=matrix(c(0,1,1e8,1e8),2,2)) AutoN@p0<-new("DevFac",meanList=c(0,0),volList=c(0,0)) AutoN@reportLag <- new("Exponential", p1 =0.1) AutoN@settlementLag <- new("Exponential", p1 =0.05) AutoN@iCopula <- TRUE #use copula AutoN@ssrCopula <- new("CopulaObj", type ="normal", dimension = 3, param = c(0.1,0.2,0.1))#A Gaussian Copula AutoN@ssrCopula@marginal <- c(AutoN@severity,AutoN@settlementLag,AutoN@reportLag) AutoN@laeDevFac <- new("DevFac",FacID="F1",FacModel= TRUE,fun="linear", paras =c(5,1.5,0.005,1.2,3)) AutoN@fIBNER <- new("DevFac",FacID="D1",FacModel= FALSE, meanList =c(1.2,1.15,1.1,1.05,1),volList =c(0,0,0,0,0)) AutoN@reopen <- new("DevFac",FacID="D2",FacModel= FALSE, meanList =c(0.02,0.015,0.01,0.005,0),volList =c(0.003, 0.002, 0.001, 0.001, 0)) AutoN@roDevFac <- new("DevFac",FacID="D3",FacModel= FALSE, meanList =c(1.05,1.1,1,1,1),volList =c(0.00589,0.0037,0.00632,0.00815,0)) AutoN@reopenLag <- new("Exponential", p1 =0.01) AutoN@resettleLag <- new("Exponential", p1 =0.25) simobj <- new("Simulation", lines=lines, types=types, claimobjs= list(AutoN),workingFolder=tempdir()) simobj@simNo <- 1 simobj@iRBNER <-FALSE simobj@iROPEN <-FALSE simobj@iIBNR <-TRUE simobj@iUPR <-FALSE simdata <- claimSimulation(simobj,claimdata, startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31"))
library(cascsim) data(claimdata) lines <- c("Auto") types <- c("N") AutoN <- new("ClaimType", line = "Auto", claimType = "N") AutoN@exposureIndex <- setIndex(new("Index",indexID="I1",tabulate= FALSE, startDate=as.Date("2012-01-01"), annualizedRate = 0)) # level exposure across time AutoN@frequency <- new("Poisson", p1 =50) AutoN@severityIndex <- setIndex(new("Index",indexID="I2",tabulate= FALSE, startDate=as.Date("2012-01-01"), annualizedRate = 0.02)) #assuming a 2% annual inflation AutoN@severity <- new("Lognormal", p1 =2, p2 =3) AutoN@deductible <- new("Empirical", empirical=matrix(c(0,1,100,100),2,2)) AutoN@limit <- new("Empirical", empirical=matrix(c(0,1,1e8,1e8),2,2)) AutoN@p0<-new("DevFac",meanList=c(0,0),volList=c(0,0)) AutoN@reportLag <- new("Exponential", p1 =0.1) AutoN@settlementLag <- new("Exponential", p1 =0.05) AutoN@iCopula <- TRUE #use copula AutoN@ssrCopula <- new("CopulaObj", type ="normal", dimension = 3, param = c(0.1,0.2,0.1))#A Gaussian Copula AutoN@ssrCopula@marginal <- c(AutoN@severity,AutoN@settlementLag,AutoN@reportLag) AutoN@laeDevFac <- new("DevFac",FacID="F1",FacModel= TRUE,fun="linear", paras =c(5,1.5,0.005,1.2,3)) AutoN@fIBNER <- new("DevFac",FacID="D1",FacModel= FALSE, meanList =c(1.2,1.15,1.1,1.05,1),volList =c(0,0,0,0,0)) AutoN@reopen <- new("DevFac",FacID="D2",FacModel= FALSE, meanList =c(0.02,0.015,0.01,0.005,0),volList =c(0.003, 0.002, 0.001, 0.001, 0)) AutoN@roDevFac <- new("DevFac",FacID="D3",FacModel= FALSE, meanList =c(1.05,1.1,1,1,1),volList =c(0.00589,0.0037,0.00632,0.00815,0)) AutoN@reopenLag <- new("Exponential", p1 =0.01) AutoN@resettleLag <- new("Exponential", p1 =0.25) simobj <- new("Simulation", lines=lines, types=types, claimobjs= list(AutoN),workingFolder=tempdir()) simobj@simNo <- 1 simobj@iRBNER <-FALSE simobj@iROPEN <-FALSE simobj@iIBNR <-TRUE simobj@iUPR <-FALSE simdata <- claimSimulation(simobj,claimdata, startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31"))
An S4 class to represent a claim type.
simno
The simulation index.
line
A string to identify the business line that the claim belongs to.
claimType
A string to identify the type of the claim. It further classifies the claims within a business line. For example, the type could be based on the size of the loss.
iRBNER
A Boolean variable to indicate whether RBNER (open claims) should be simulated.
iROPEN
A Boolean variable to indicate whether claim reopen should be simulated.
iIBNR
A Boolean variable to indicate whether IBNR claims should be simulated.
iUPR
A Boolean variable to indicate whether future claims should be simulated.
fIBNER
IBNER development factor.
severity
Severity distribution.
frequency
Frequency distribution.
reportLag
Report lag distribution.
settlementLag
Settlement lag distribution.
reopen
Claim reopen probability based on the number of years after settlement till valuation date.
reopenLag
Reopen lag distribution.
resettleLag
Resettlement lag distribution.
roDevFac
Reopened claim development factor.
ioDevFac
A numeric variable to indicate the method of loss development for open claim severity. 1: Conditional distribution based on paid loss; 2: conditional distribution based on incurred loss; 3: year-to-year development factors
irDevFac
A numeric variable to indicate the method of loss development for claim reopen severity simulation. 1: Conditional distribution based on paid loss; 2: conditional distribution based on incurred loss; 3: year-to-year development factors
freqIndex
Frequency distribution time index.
severityIndex
Severity distribution time index.
exposureIndex
Exposure time index for IBNR or UPR.
iCopula
Whether copula is used to model severity, report lag and settlement lag.
ssrCopula
Copula object used for severity, report lag and settlement lag.
sdata
Indicating whether only closed claims (CLOSED) or closed + open claims (ALL) will be used for severity fitting.
p0
An yearly table that controls the probability of invalid claim, excluding these valid claims less than deductible based on development year. It is based on the DevFac class.
Experience data plotting.
copulaDataPlot(object, ...) ## S4 method for signature 'CopulaObj' copulaDataPlot(object)
copulaDataPlot(object, ...) ## S4 method for signature 'CopulaObj' copulaDataPlot(object)
object |
Copula Object |
... |
Additional parameters that may or may not be used |
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) nom.cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) setObservation(nom.cop)<-copulaSample(nom.cop,100) copulaDataPlot(nom.cop)
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) nom.cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) setObservation(nom.cop)<-copulaSample(nom.cop,100) copulaDataPlot(nom.cop)
Copula fitting
copulaFit(object, ...) ## S4 method for signature 'CopulaObj' copulaFit(object)
copulaFit(object, ...) ## S4 method for signature 'CopulaObj' copulaFit(object)
object |
Copula Object |
... |
Additional parameters that may or may not be used |
library(cascsim) #Prepare pseudo observation data library(copula) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) dist3<-new("Lognormal",p1=2,p2=1,min=0,max=100,truncated=TRUE) normal.cop <- normalCopula(c(0.6, 0.36, 0.6), dim=3, dispstr="un") x <- rCopula(1000, normal.cop) x[,1]<-Quantile(dist1,x[,1]) x[,2]<-Quantile(dist2,x[,2]) x[,3]<-Quantile(dist3,x[,3]) #Create Copula Object and Fit it to observation data without goodness of fit test nom.cop <- new("CopulaObj", param=c(0.5,0.5,0.5),marginal=list(dist1=dist1,dist2=dist2,dist3=dist3), dimension=3,observation=x,fittest=FALSE) nom.cop <- copulaFit(nom.cop) nom.cop@coutput #Create Copula Object and Fit it to observation data with goodness of fit test clayton.cop <- claytonCopula(c(3), dim=2) x <- rCopula(1000, clayton.cop) x[,1]<-Quantile(dist1,x[,1]) x[,2]<-Quantile(dist2,x[,2]) cla.cop <- new("CopulaObj", type="clayton",param=c(3), marginal=list(dist1=dist1,dist2=dist2),dimension=2,observation=x,fittest=TRUE) cla.cop <- copulaFit(cla.cop) cla.cop@coutput
library(cascsim) #Prepare pseudo observation data library(copula) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) dist3<-new("Lognormal",p1=2,p2=1,min=0,max=100,truncated=TRUE) normal.cop <- normalCopula(c(0.6, 0.36, 0.6), dim=3, dispstr="un") x <- rCopula(1000, normal.cop) x[,1]<-Quantile(dist1,x[,1]) x[,2]<-Quantile(dist2,x[,2]) x[,3]<-Quantile(dist3,x[,3]) #Create Copula Object and Fit it to observation data without goodness of fit test nom.cop <- new("CopulaObj", param=c(0.5,0.5,0.5),marginal=list(dist1=dist1,dist2=dist2,dist3=dist3), dimension=3,observation=x,fittest=FALSE) nom.cop <- copulaFit(nom.cop) nom.cop@coutput #Create Copula Object and Fit it to observation data with goodness of fit test clayton.cop <- claytonCopula(c(3), dim=2) x <- rCopula(1000, clayton.cop) x[,1]<-Quantile(dist1,x[,1]) x[,2]<-Quantile(dist2,x[,2]) cla.cop <- new("CopulaObj", type="clayton",param=c(3), marginal=list(dist1=dist1,dist2=dist2),dimension=2,observation=x,fittest=TRUE) cla.cop <- copulaFit(cla.cop) cla.cop@coutput
Visualization Copula fitting
copulaFitPlot(object, ...) ## S4 method for signature 'CopulaObj' copulaFitPlot(object)
copulaFitPlot(object, ...) ## S4 method for signature 'CopulaObj' copulaFitPlot(object)
object |
Copula Object |
... |
Additional parameters that may or may not be used |
library(cascsim) #Prepare pseudo observation data library(copula) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) dist3<-new("Lognormal",p1=2,p2=1,min=0,max=100,truncated=TRUE) normal.cop <- normalCopula(c(0.6, 0.36, 0.6), dim=3, dispstr="un") x <- rCopula(1000, normal.cop) x[,1]<-Quantile(dist1,x[,1]) x[,2]<-Quantile(dist2,x[,2]) x[,3]<-Quantile(dist3,x[,3]) #Create Copula Object and Fit it to observation data without goodness of fit test nom.cop <- new("CopulaObj", param=c(0.5,0.5,0.5),marginal=list(dist1=dist1,dist2=dist2,dist3=dist3), dimension=3,observation=x,fittest=FALSE) nom.cop <- copulaFit(nom.cop) copulaFitPlot(nom.cop) #Create Copula Object and Fit it to observation data with goodness of fit test clayton.cop <- claytonCopula(c(3), dim=2) x <- rCopula(1000, clayton.cop) x[,1]<-Quantile(dist1,x[,1]) x[,2]<-Quantile(dist2,x[,2]) cla.cop <- new("CopulaObj", type="clayton",param=c(3),marginal=list(dist1=dist1,dist2=dist2), dimension=2,observation=x,fittest=TRUE) cla.cop <- copulaFit(cla.cop) copulaFitPlot(cla.cop)
library(cascsim) #Prepare pseudo observation data library(copula) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) dist3<-new("Lognormal",p1=2,p2=1,min=0,max=100,truncated=TRUE) normal.cop <- normalCopula(c(0.6, 0.36, 0.6), dim=3, dispstr="un") x <- rCopula(1000, normal.cop) x[,1]<-Quantile(dist1,x[,1]) x[,2]<-Quantile(dist2,x[,2]) x[,3]<-Quantile(dist3,x[,3]) #Create Copula Object and Fit it to observation data without goodness of fit test nom.cop <- new("CopulaObj", param=c(0.5,0.5,0.5),marginal=list(dist1=dist1,dist2=dist2,dist3=dist3), dimension=3,observation=x,fittest=FALSE) nom.cop <- copulaFit(nom.cop) copulaFitPlot(nom.cop) #Create Copula Object and Fit it to observation data with goodness of fit test clayton.cop <- claytonCopula(c(3), dim=2) x <- rCopula(1000, clayton.cop) x[,1]<-Quantile(dist1,x[,1]) x[,2]<-Quantile(dist2,x[,2]) cla.cop <- new("CopulaObj", type="clayton",param=c(3),marginal=list(dist1=dist1,dist2=dist2), dimension=2,observation=x,fittest=TRUE) cla.cop <- copulaFit(cla.cop) copulaFitPlot(cla.cop)
An S4 class to represent a copula object to model the correlation.
type
The type of the copula object.
para
A numeric vector that contains copula parameter(s).
marginal
A list of Distribution objects.
dispstr
The format of symmetric positive definite matrix used by elliptical copula (Normal Copula, t Copula). The default is "un" for unstructured. Other choices include "ex" for exchangeable, "ar1" for AR(1), and "toep" for Toeplitz (toeplitz).
df
The number of degrees of freedom used in t Copula.
observation
A matrix that contains the experience data for copula fitting.
fitmethod
The method of copula fitting. Default is "mpl":maximum pseudo-likelihood estimator. Others include "ml": maximum likelihood assuming it is the true distribution; "itau": inversion of Kendall’s tau estimator; "irho": inversion of Spearman’s rho estimator.
fittest
Whether to run goodness of fit test for copula fitting. Goodness of fit test could take a long time to finish.
fitsucc
Whether a copula fitting is successful.
coutput
Goodness of fit results.
info
A character string that contains additional information of the copula to identify line/type/frequency/time lag/severity.
Copula plotting. Only for 2 or 3 variables
copulaPlot(object, ...) ## S4 method for signature 'CopulaObj' copulaPlot(object)
copulaPlot(object, ...) ## S4 method for signature 'CopulaObj' copulaPlot(object)
object |
Copula Object |
... |
Additional parameters that may or may not be used |
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) nom.cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) copulaPlot(nom.cop)
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) nom.cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) copulaPlot(nom.cop)
Copula sampling. It will generate correlated variables or percentiles when marginal distributions are not specified.
copulaSample(object, n, ...) ## S4 method for signature 'CopulaObj,numeric' copulaSample(object, n)
copulaSample(object, n, ...) ## S4 method for signature 'CopulaObj,numeric' copulaSample(object, n)
object |
Copula Object |
n |
Number of samples |
... |
Additional parameters that may or may not be used |
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) nom.cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) copulaSample(nom.cop,100)
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) nom.cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) copulaSample(nom.cop,100)
Density function.
Density(object, x, ...) ## S4 method for signature 'Normal' Density(object, x, log = FALSE) ## S4 method for signature 'Beta' Density(object, x, log = FALSE) ## S4 method for signature 'Exponential' Density(object, x, log = FALSE) ## S4 method for signature 'Gamma' Density(object, x, log = FALSE) ## S4 method for signature 'Geometric' Density(object, x, log = FALSE) ## S4 method for signature 'Lognormal' Density(object, x, log = FALSE) ## S4 method for signature 'NegativeBinomial' Density(object, x, log = FALSE) ## S4 method for signature 'Pareto' Density(object, x, log = FALSE) ## S4 method for signature 'Poisson' Density(object, x, log = FALSE) ## S4 method for signature 'Uniform' Density(object, x, log = FALSE) ## S4 method for signature 'Weibull' Density(object, x, log = FALSE) ## S4 method for signature 'Empirical' Density(object, x, log = FALSE)
Density(object, x, ...) ## S4 method for signature 'Normal' Density(object, x, log = FALSE) ## S4 method for signature 'Beta' Density(object, x, log = FALSE) ## S4 method for signature 'Exponential' Density(object, x, log = FALSE) ## S4 method for signature 'Gamma' Density(object, x, log = FALSE) ## S4 method for signature 'Geometric' Density(object, x, log = FALSE) ## S4 method for signature 'Lognormal' Density(object, x, log = FALSE) ## S4 method for signature 'NegativeBinomial' Density(object, x, log = FALSE) ## S4 method for signature 'Pareto' Density(object, x, log = FALSE) ## S4 method for signature 'Poisson' Density(object, x, log = FALSE) ## S4 method for signature 'Uniform' Density(object, x, log = FALSE) ## S4 method for signature 'Weibull' Density(object, x, log = FALSE) ## S4 method for signature 'Empirical' Density(object, x, log = FALSE)
object |
Distribution Object |
x |
Variable value |
... |
Additional function arguments |
log |
Boolean variable to indicate whether to return log of probability |
xPareto <- new("Pareto",p1=20,p2=3) Density(xPareto,50)
xPareto <- new("Pareto",p1=20,p2=3) Density(xPareto,50)
An S4 class to represent a loss development schedule.
FacID
A character string to identify the loss development schedule.
FacModel
A boolean to indicate whether the loss development schedule is described as a model (TRUE) or a list of value (FALSE).
fun
A character string that indicates the model format in link function. Currently identity(linear), inverse(reciprocal linear), log(exponential), and exponential(loglinear) link functions(models) are supported. It is only used when model == TRUE.
distType
A character string that indicates the distribution of development factors. Currently normal, lognormal, and gamma distributions are supported. It is only used when model == FALSE.
xname
A vector that includes the names of explanatory variables. They will have to be matched exactly to the claim data file. It is only used when model == TRUE.
paras
A vector that contains the parameters of the model. It is only used when model == TRUE.
meanList
A vector that contains the mean yearly development factor if distribution type is Normal. It is mu for Lognormal distribution and shape for Gamma distribution. It is only used when model == FALSE.
volList
A vector that contains the volatility of yearly development factor if distribution type is Normal. It is sigma for Lognormal distribution and scale for Gamma distribution. It is used for simulating IBNER factors. It is only used when model == FALSE.
An S4 class to represent a distribution, either parametric or non-parametric.
p1
A number for the value of the first parameter (default: 0.8).
p2
A number for the value of the second parameter (default: 1).
p3
A number for the value of the third parameter (default: 0).
empirical
A matrix that defines an empirical distribution with values and probabilities.
min
A number that defines the minimum value of the variable (default: 1e-8 considering it is used for frequency and severity modeling).
max
A number that defines the maximum value of the variable (default: 1e8).
fitsucc
Whether a distribution fitting is successful.
info
A character string that contains additional information of the distribution to identify line/type/frequency or severity.
Plot function.
doPlot(object, ...) ## S4 method for signature 'Distribution' doPlot(object)
doPlot(object, ...) ## S4 method for signature 'Distribution' doPlot(object)
object |
Object |
... |
Additional function arguments |
xPareto <- new("Pareto",p1=20,p2=3) doPlot(xPareto)
xPareto <- new("Pareto",p1=20,p2=3) doPlot(xPareto)
Sampling from the distribution.
doSample(object, n, ...) ## S4 method for signature 'Normal,numeric' doSample(object, n) ## S4 method for signature 'Beta,numeric' doSample(object, n) ## S4 method for signature 'Exponential,numeric' doSample(object, n) ## S4 method for signature 'Gamma,numeric' doSample(object, n) ## S4 method for signature 'Lognormal,numeric' doSample(object, n) ## S4 method for signature 'Pareto,numeric' doSample(object, n) ## S4 method for signature 'Poisson,numeric' doSample(object, n) ## S4 method for signature 'NegativeBinomial,numeric' doSample(object, n) ## S4 method for signature 'Geometric,numeric' doSample(object, n) ## S4 method for signature 'Uniform,numeric' doSample(object, n) ## S4 method for signature 'Weibull,numeric' doSample(object, n) ## S4 method for signature 'Empirical,numeric' doSample(object, n)
doSample(object, n, ...) ## S4 method for signature 'Normal,numeric' doSample(object, n) ## S4 method for signature 'Beta,numeric' doSample(object, n) ## S4 method for signature 'Exponential,numeric' doSample(object, n) ## S4 method for signature 'Gamma,numeric' doSample(object, n) ## S4 method for signature 'Lognormal,numeric' doSample(object, n) ## S4 method for signature 'Pareto,numeric' doSample(object, n) ## S4 method for signature 'Poisson,numeric' doSample(object, n) ## S4 method for signature 'NegativeBinomial,numeric' doSample(object, n) ## S4 method for signature 'Geometric,numeric' doSample(object, n) ## S4 method for signature 'Uniform,numeric' doSample(object, n) ## S4 method for signature 'Weibull,numeric' doSample(object, n) ## S4 method for signature 'Empirical,numeric' doSample(object, n)
object |
A Distribution Object |
n |
Number of samples |
... |
Additional function arguments |
xPareto <- new("Pareto",p1=20,p2=3) doSample(xPareto,10000)
xPareto <- new("Pareto",p1=20,p2=3) doSample(xPareto,10000)
Density function of Truncated Beta Distribution
Cumulative probability function of Truncated Beta Distribution
Quantile function of Truncated Beta Distribution max(0,min(claim,limit)-deductible)
Random generation of Truncated Beta Distribution max(0,min(claim,limit)-deductible)
dtbeta(x, shape1, shape2, ncp = 0, min = 0, max = 1) ptbeta(q, shape1, shape2, ncp = 0, min = 0, max = 1) qtbeta(p, shape1, shape2, ncp = 0, min = 0, max = 1) rtbeta(n, shape1, shape2, ncp = 0, min = 0, max = 1)
dtbeta(x, shape1, shape2, ncp = 0, min = 0, max = 1) ptbeta(q, shape1, shape2, ncp = 0, min = 0, max = 1) qtbeta(p, shape1, shape2, ncp = 0, min = 0, max = 1) rtbeta(n, shape1, shape2, ncp = 0, min = 0, max = 1)
x |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
shape1 |
distribution parameter |
shape2 |
distribution parameter |
ncp |
non-centrality parameter (Default: 0) |
min |
Left truncation deductible |
max |
Right truncation limit |
q |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
p |
Value of the probability |
n |
Number of samples |
dtbeta(0.6,1,2) ptbeta(0.5,1,2) qtbeta(0.5,1,2) rtbeta(100,1,2)
dtbeta(0.6,1,2) ptbeta(0.5,1,2) qtbeta(0.5,1,2) rtbeta(100,1,2)
Density function of truncated empirical distribution
Cumulative probability function of truncated empirical distribution
Quantile function of truncated empirical distribution max(0,min(claim,limit)-deductible)
Random generation of Truncated empirical distribution max(0,min(claim,limit)-deductible)
dtempirical(x, cdf, min = 0, max = 1e+09) ptempirical(q, cdf, min = 0, max = 1e+05) qtempirical(p, cdf, min = 0, max = 1e+05) rtempirical(n, cdf, min = 0, max = 1e+05)
dtempirical(x, cdf, min = 0, max = 1e+09) ptempirical(q, cdf, min = 0, max = 1e+05) qtempirical(p, cdf, min = 0, max = 1e+05) rtempirical(n, cdf, min = 0, max = 1e+05)
x |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
cdf |
empirical distribution (cdf for continuous distribution and pmf for discrete distribution) |
min |
Left truncation deductible |
max |
Right truncation limit |
q |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
p |
Value of the probability |
n |
Number of samples |
#discrete distribution dtempirical(3,matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2),3,100) #continuous distribution dtempirical(30,matrix(c(seq(0.01,1,0.01),qnorm(seq(0.01,1,0.01),30,20)),100,2),200,10000000) #discrete distribution ptempirical(c(3,5,10),matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2),3,100) #continuous distribution ptempirical(350,matrix(c(seq(0.01,1,0.01),cumprod(c(1,rep(1.1,99)))),100,2),200,10000000) #discrete distribution qtempirical(c(0.3,0.65,1),matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2),3,100) #continuous distribution qtempirical(c(0.3,0.65,0.8),matrix(c(seq(0.01,1,0.01), cumprod(c(1,rep(1.1,99)))),100,2),200,10000000) #discrete distribution rtempirical(100,matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2),3,100) #continuous distribution rtempirical(100,matrix(c(seq(0.01,1,0.01),cumprod(c(1,rep(1.1,99)))),100,2),200,10000000)
#discrete distribution dtempirical(3,matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2),3,100) #continuous distribution dtempirical(30,matrix(c(seq(0.01,1,0.01),qnorm(seq(0.01,1,0.01),30,20)),100,2),200,10000000) #discrete distribution ptempirical(c(3,5,10),matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2),3,100) #continuous distribution ptempirical(350,matrix(c(seq(0.01,1,0.01),cumprod(c(1,rep(1.1,99)))),100,2),200,10000000) #discrete distribution qtempirical(c(0.3,0.65,1),matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2),3,100) #continuous distribution qtempirical(c(0.3,0.65,0.8),matrix(c(seq(0.01,1,0.01), cumprod(c(1,rep(1.1,99)))),100,2),200,10000000) #discrete distribution rtempirical(100,matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2),3,100) #continuous distribution rtempirical(100,matrix(c(seq(0.01,1,0.01),cumprod(c(1,rep(1.1,99)))),100,2),200,10000000)
Density function of Truncated Exponential Distribution
Cumulative probability function of Truncated Exponential Distribution
Quantile function of Truncated Exponential Distribution max(0,min(claim,limit)-deductible)
Random generation of Truncated Exponential Distribution max(0,min(claim,limit)-deductible)
dtexp(x, rate, min = 0, max = 1e+09) ptexp(q, rate, min = 0, max = 1e+09) qtexp(p, rate, min = 0, max = 1e+09) rtexp(n, rate, min = 0, max = 1e+09)
dtexp(x, rate, min = 0, max = 1e+09) ptexp(q, rate, min = 0, max = 1e+09) qtexp(p, rate, min = 0, max = 1e+09) rtexp(n, rate, min = 0, max = 1e+09)
x |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
rate |
Distribution parameter |
min |
Left truncation deductible |
max |
Right truncation limit |
q |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
p |
Value of the probability |
n |
Number of samples |
dtexp(5,0.1) ptexp(5,0.1) qtexp(0.5,0.1) rtexp(100,0.1)
dtexp(5,0.1) ptexp(5,0.1) qtexp(0.5,0.1) rtexp(100,0.1)
Density function of Truncated Gamma Distribution
Cumulative probability function of Truncated Gamma Distribution
Quantile function of Truncated Gamma Distribution max(0,min(claim,limit)-deductible)
Random generation of Truncated Gamma Distribution max(0,min(claim,limit)-deductible)
dtgamma(x, shape, scale, min = 0, max = 1e+09) ptgamma(q, shape, scale, min = 0, max = 1e+09) qtgamma(p, shape, scale, min = 0, max = 1e+09) rtgamma(n, shape, scale, min = 0, max = 1e+09)
dtgamma(x, shape, scale, min = 0, max = 1e+09) ptgamma(q, shape, scale, min = 0, max = 1e+09) qtgamma(p, shape, scale, min = 0, max = 1e+09) rtgamma(n, shape, scale, min = 0, max = 1e+09)
x |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
shape |
Shape parameter |
scale |
Scale parameter |
min |
Left truncation deductible |
max |
Right truncation limit |
q |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
p |
Value of the probability |
n |
Number of samples |
dtgamma(2,3,2) ptgamma(2,3,2) qtgamma(0.5,3,2) rtgamma(100,3,2)
dtgamma(2,3,2) ptgamma(2,3,2) qtgamma(0.5,3,2) rtgamma(100,3,2)
Density function of Truncated Geometric Distribution
Cumulative probability function of Truncated Geometric Distribution
Quantile function of Truncated Geometric Distribution max(0,min(claim,limit)-deductible)
Random generation of Truncated Geometric Distribution max(0,min(claim,limit)-deductible)
dtgeom(x, prob, min = 0, max = 1e+09) ptgeom(q, prob, min = 0, max = 1e+09) qtgeom(p, prob, min = 0, max = 1e+09) rtgeom(n, prob, min = 0, max = 1e+09)
dtgeom(x, prob, min = 0, max = 1e+09) ptgeom(q, prob, min = 0, max = 1e+09) qtgeom(p, prob, min = 0, max = 1e+09) rtgeom(n, prob, min = 0, max = 1e+09)
x |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
prob |
Distribution parameter |
min |
Left truncation deductible |
max |
Right truncation limit |
q |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
p |
Value of the probability |
n |
Number of samples |
dtgeom(3,0.3) ptgeom(3,0.3) qtgeom(0.7,0.3) rtgeom(100,0.3)
dtgeom(3,0.3) ptgeom(3,0.3) qtgeom(0.7,0.3) rtgeom(100,0.3)
Density function of Truncated Lognormal Distribution
Cumulative probability function of Truncated Lognormal Distribution
Quantile function of Truncated Lognormal Distribution max(0,min(claim,limit)-deductible)
Random generation of Truncated Lognormal Distribution max(0,min(claim,limit)-deductible)
dtlnorm(x, meanlog, sdlog, min = 0, max = 1e+09) ptlnorm(q, meanlog, sdlog, min = 0, max = 1e+09) qtlnorm(p, meanlog, sdlog, min = 0, max = 1e+09) rtlnorm(n, meanlog, sdlog, min = 0, max = 1e+09)
dtlnorm(x, meanlog, sdlog, min = 0, max = 1e+09) ptlnorm(q, meanlog, sdlog, min = 0, max = 1e+09) qtlnorm(p, meanlog, sdlog, min = 0, max = 1e+09) rtlnorm(n, meanlog, sdlog, min = 0, max = 1e+09)
x |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
meanlog |
Mean of the log of the distribution |
sdlog |
Standard deviation of the log of the distribution |
min |
Left truncation deductible |
max |
Right truncation limit |
q |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
p |
Value of the probability |
n |
Number of samples |
dtlnorm(20,3,0.5) ptlnorm(20,3,0.5) qtlnorm(0.5,3,0.5) rtlnorm(100,3,0.5)
dtlnorm(20,3,0.5) ptlnorm(20,3,0.5) qtlnorm(0.5,3,0.5) rtlnorm(100,3,0.5)
Density function of Truncated Negative Binomial Distribution
Cumulative probability function of Truncated Negative Binomial Distribution
Quantile function of Truncated Negative Binomial Distribution max(0,min(claim,limit)-deductible)
Random generation of Truncated Negative Binomial Distribution max(0,min(claim,limit)-deductible)
dtnbinom(x, size, prob, min = 0, max = 1e+09) ptnbinom(q, size, prob, min = 0, max = 1e+09) qtnbinom(p, size, prob, min = 0, max = 1e+09) rtnbinom(n, size, prob, min = 0, max = 1e+09)
dtnbinom(x, size, prob, min = 0, max = 1e+09) ptnbinom(q, size, prob, min = 0, max = 1e+09) qtnbinom(p, size, prob, min = 0, max = 1e+09) rtnbinom(n, size, prob, min = 0, max = 1e+09)
x |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
size |
Number of successful trials |
prob |
Probability of success in each trial |
min |
Left truncation deductible |
max |
Right truncation limit |
q |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
p |
Value of the probability |
n |
Number of samples |
dtnbinom(230,100,0.3) ptnbinom(230,100,0.3) qtnbinom(0.5,100,0.3) rtnbinom(500,100,0.3)
dtnbinom(230,100,0.3) ptnbinom(230,100,0.3) qtnbinom(0.5,100,0.3) rtnbinom(500,100,0.3)
Density function of Truncated Normal Distribution
Cumulative probability function of Truncated Normal Distribution
Quantile function of Truncated Normal Distribution max(0,min(claim,limit)-deductible)
Random generation of Truncated Normal Distribution max(0,min(claim,limit)-deductible)
dtnorm(x, mean, sd, min = 0, max = 1e+09) ptnorm(q, mean, sd, min = 0, max = 1e+09) qtnorm(p, mean, sd, min = 0, max = 1e+09) rtnorm(n, mean, sd, min = 0, max = 1e+09)
dtnorm(x, mean, sd, min = 0, max = 1e+09) ptnorm(q, mean, sd, min = 0, max = 1e+09) qtnorm(p, mean, sd, min = 0, max = 1e+09) rtnorm(n, mean, sd, min = 0, max = 1e+09)
x |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
mean |
Mean of the untruncated Normal distribution |
sd |
Standard deviation of the untruncated Normal distribution |
min |
Left truncation (like deductible) |
max |
Right truncation (like limit) |
q |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
p |
Value of the probability |
n |
Number of samples |
dtnorm(0.5,1,2) ptnorm(0.5,1,2) qtnorm(0.5,1,2) rtnorm(100,1,2)
dtnorm(0.5,1,2) ptnorm(0.5,1,2) qtnorm(0.5,1,2) rtnorm(100,1,2)
Density function of Truncated Pareto Distribution
Cumulative probability function of Truncated Pareto Distribution
Quantile function of Truncated Pareto Distribution max(0,min(claim,limit)-deductible)
Random generation of Truncated Pareto Distribution max(0,min(claim,limit)-deductible)
dtpareto(x, xm, alpha, min = xm, max = 1e+09) ptpareto(q, xm, alpha, min = xm, max = 1e+09) qtpareto(p, xm, alpha, min = xm, max = 1e+09) rtpareto(n, xm, alpha, min = xm, max = 1e+09)
dtpareto(x, xm, alpha, min = xm, max = 1e+09) ptpareto(q, xm, alpha, min = xm, max = 1e+09) qtpareto(p, xm, alpha, min = xm, max = 1e+09) rtpareto(n, xm, alpha, min = xm, max = 1e+09)
x |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
xm |
Threshold value |
alpha |
Model parameter |
min |
Left truncation deductible |
max |
Right truncation limit |
q |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
p |
Value of the probability |
n |
Number of samples |
dtpareto(500,1000,2) ptpareto(500,1000,2) qtpareto(0.5,1000,2) rtpareto(100,1000,2)
dtpareto(500,1000,2) ptpareto(500,1000,2) qtpareto(0.5,1000,2) rtpareto(100,1000,2)
Density function of Truncated Poisson Distribution
Cumulative probability function of Truncated Poisson Distribution
Quantile function of Truncated Poisson Distribution max(0,min(claim,limit)-deductible)
Random generation of Truncated Poisson Distribution max(0,min(claim,limit)-deductible)
dtpois(x, lambda, min = 0, max = 1e+09) ptpois(q, lambda, min = 0, max = 1e+09) qtpois(p, lambda, min = 0, max = 1e+09) rtpois(n, lambda, min = 0, max = 1e+09)
dtpois(x, lambda, min = 0, max = 1e+09) ptpois(q, lambda, min = 0, max = 1e+09) qtpois(p, lambda, min = 0, max = 1e+09) rtpois(n, lambda, min = 0, max = 1e+09)
x |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
lambda |
Distribution parameter |
min |
Left truncation deductible |
max |
Right truncation limit |
q |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
p |
Value of the probability |
n |
Number of samples |
dtpois(3,5) ptpois(3,5) qtpois(0.6,5) rtpois(100,5)
dtpois(3,5) ptpois(3,5) qtpois(0.6,5) rtpois(100,5)
Density function of Truncated Weibull Distribution
Cumulative probability function of Truncated Weibull Distribution
Quantile function of Truncated Weibull Distribution max(0,min(claim,limit)-deductible)
Random generation of Truncated Weibull Distribution max(0,min(claim,limit)-deductible)
dtweibull(x, shape, scale, min = 0, max = 1e+09) ptweibull(q, shape, scale, min = 0, max = 1e+09) qtweibull(p, shape, scale, min = 0, max = 1e+09) rtweibull(n, shape, scale, min = 0, max = 1e+09)
dtweibull(x, shape, scale, min = 0, max = 1e+09) ptweibull(q, shape, scale, min = 0, max = 1e+09) qtweibull(p, shape, scale, min = 0, max = 1e+09) rtweibull(n, shape, scale, min = 0, max = 1e+09)
x |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
shape |
Shape parameter |
scale |
Scale parameter |
min |
Left truncation deductible |
max |
Right truncation limit |
q |
Value of the variable after deductible and limit max(0,min(claim,limit)-deductible) |
p |
Value of the probability |
n |
Number of samples |
dtweibull(2.5,2,3) ptweibull(2.5,2,3) qtweibull(0.5,2,3) rtweibull(100,2,3)
dtweibull(2.5,2,3) ptweibull(2.5,2,3) qtweibull(0.5,2,3) rtweibull(100,2,3)
Get the expected P0 based on settlement/close year.
expectZeros(closeYear, zeroProb)
expectZeros(closeYear, zeroProb)
closeYear |
Development years that claims are settled. It could be a number or a numeric vector. |
zeroProb |
A vector that contains the P(0) based on development year. |
zeroprob<-c(0.02,0.01,0.005,0.005,0.003,0) expectZeros(c(2,3,6,9,100,1,2,3,4),zeroprob)
zeroprob<-c(0.02,0.01,0.005,0.005,0.003,0) expectZeros(c(2,3,6,9,100,1,2,3,4),zeroprob)
An S4 class to represent distribution fitting.
observation
Raw data input containing loss sizes for severity analysis and number of losses for frequency analysis.
fitdata
Processed data for distribution fitting. Frequency data may be provided as occurrence dates. The class will transform them into frequency data before distribution fitting.
trend
Index object for detrending the data.
startDate
Start date of claim data used for distribution fitting. The trend Index should also start from the same date (year-month).
endDate
End date of claim data used for distribution fitting.
trail
Trial Distribution object to start fitting.
fitted
Fitted Distribution object.
reportLag
Report lag distribution to adjust frequency data.
iLag
Whether to adjust the frequency data with report lag distribution.
method
Distribution fitting method. Maximum likelihood estimation (mle), moment matching estimation(mme) and quantile matching estimation(qme) are available.
probs
A vector containing the percentiles to be matched if qme is used for fitting.
ifreq
A boolean indicating whether it is frequency data or severity data.
idate
A boolean indicating whether frequency data is provided as occurrence dates (TRUE) or number of occurrences (FALSE).
datelist
A vector containing occurrence dates. It could be a data field in a claim file.
freq
A character string indicating the frequency: "Annual" or "Monthly".
iDL
A boolean indicating whether deductible and limit is considered in distribution fitting.
limit
A vector containing the limit for each claim.
deductible
A vector containing the deductible for each claim.
p0
A number that is the probability of having a zero-amount claim after deductible.
dof
Degree of freedom.
psd
A vector containing the standard deviation of parameter estimation. It is only available for mle.
aic
Akaike information criterion.
bic
Bayesian information criterion.
chisq
Chi-Squared Test Statistic.
pchisq
p-value of Chi-Squared Test.
kstest
K-S Test Statistic. Only used for continuous distribution.
pkstest
p-value of K-S Test. Only used for continuous distribution.
soutput
Distribution fitting summary.
Compare the raw data and fitted distribution on density, CDF, Q-Q plot and P-P plot
fitPlot(object, ...) ## S4 method for signature 'FitDist' fitPlot(object, n = missing)
fitPlot(object, ...) ## S4 method for signature 'FitDist' fitPlot(object, n = missing)
object |
FitDist Object |
... |
Additional function arguments |
n |
Number of samples, should not be used in current setting |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput fitPlot(xFit)
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput fitPlot(xFit)
Get the R copula object.
getCopula(object, ...) ## S4 method for signature 'CopulaObj' getCopula(object)
getCopula(object, ...) ## S4 method for signature 'CopulaObj' getCopula(object)
object |
R copula object |
... |
Additional parameters that may or may not be used |
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) nom.cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) getCopula(nom.cop)
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) nom.cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) getCopula(nom.cop)
getIndex
get a time index to reflect inflation, underwriting cycle or seasonality.
getIndex(object, ...) ## S4 method for signature 'Index' getIndex(object, dates)
getIndex(object, ...) ## S4 method for signature 'Index' getIndex(object, dates)
object |
Index Object |
... |
Additional function arguments |
dates |
dates to get index information |
xindex <- new("Index", indexID = "IDX1", tabulate = FALSE, annualizedRate = 0.03) xindex<-setIndex(xindex) xindex@monthlyIndex dates<-as.Date("2015-12-31") getIndex(xindex,dates)
xindex <- new("Index", indexID = "IDX1", tabulate = FALSE, annualizedRate = 0.03) xindex<-setIndex(xindex) xindex@monthlyIndex dates<-as.Date("2015-12-31") getIndex(xindex,dates)
Get input data from an object.
getObservation(object, ...) ## S4 method for signature 'FitDist' getObservation(object)
getObservation(object, ...) ## S4 method for signature 'FitDist' getObservation(object)
object |
Object |
... |
Additional function arguments |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") getObservation(xFit)
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") getObservation(xFit)
Get the trend index.
getTrend(object, ...) ## S4 method for signature 'FitDist' getTrend(object)
getTrend(object, ...) ## S4 method for signature 'FitDist' getTrend(object)
object |
Object |
... |
Additional function arguments |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") getTrend(xFit)
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") getTrend(xFit)
An S4 class to represent a time index for frequency or severity distribution.
indexID
A string to identify the index.
startDate
The date the index starts. It is expected to be consistent with the start date of the claim analysis.
tabulate
A boolean to indicate whether the index is determined by a constant rate (FALSE) or a series of index values (TRUE).
annualizedRate
A yearly index growth rate. It is only used when tabulate == FALSE.
yearlyIndex
A vector that contains index value on a yearly basis.
monthlyIndex
A vector that contains index value on a monthly basis.
seasonality
A vector that contains seasonal adjustment factor on a monthly basis.
K-S Test
KSTest(object, ...) ## S4 method for signature 'FitDist' KSTest(object, n = missing)
KSTest(object, ...) ## S4 method for signature 'FitDist' KSTest(object, n = missing)
object |
FitDist Object |
... |
Additional function arguments |
n |
Number of samples, should not be used in current setting |
Moment function of Pareto Distribution (PDF: alpha*xm^alpha/x^(alpha+1))
Density function of Pareto Distribution (PDF: alpha*xm^alpha/x^(alpha+1))
Cumulative probability function of Pareto Distribution (CDF: 1-(xm/x)^alpha)
Quantile function of Pareto Distribution
Random generation of Pareto Distribution
mpareto(order, xm, alpha = 3) dpareto(x, xm, alpha = 3) ppareto(q, xm, alpha = 3) qpareto(p, xm, alpha = 3) rpareto(n, xm, alpha = 3)
mpareto(order, xm, alpha = 3) dpareto(x, xm, alpha = 3) ppareto(q, xm, alpha = 3) qpareto(p, xm, alpha = 3) rpareto(n, xm, alpha = 3)
order |
Order of moment |
xm |
Threshold value |
alpha |
Default=3 |
x |
Value of the variable |
q |
Value of the variable |
p |
Value of the probability |
n |
Number of samples |
mpareto(1,1000,2) dpareto(1500,1000,2) ppareto(1500,1000,2) qpareto(0.5,1000,2) rpareto(100,1000,2)
mpareto(1,1000,2) dpareto(1500,1000,2) ppareto(1500,1000,2) qpareto(0.5,1000,2) rpareto(100,1000,2)
Negative Loglikelihood.
nloglik(paras, dist, fitdata, deductible, limit)
nloglik(paras, dist, fitdata, deductible, limit)
paras |
A vector contain distribution parameters. |
dist |
A Distribution Object. |
fitdata |
A vector of loss data for fitting. |
deductible |
A vector of deductible data for all loss data. |
limit |
A vector of limit data for all loss data. |
paras<-c(1,1) dist<-new("Normal") fitdata<-rtnorm(1000,3,2,1,10) deductible<-rep(1,1000) limit<-rep(9,1000) nloglik(paras,dist,fitdata,deductible,limit) paras<-c(3,2) nloglik(paras,dist,fitdata,deductible,limit)
paras<-c(1,1) dist<-new("Normal") fitdata<-rtnorm(1000,3,2,1,10) deductible<-rep(1,1000) limit<-rep(9,1000) nloglik(paras,dist,fitdata,deductible,limit) paras<-c(3,2) nloglik(paras,dist,fitdata,deductible,limit)
Plotting the data for distribution fitting
observationPlot(object, ...) ## S4 method for signature 'FitDist' observationPlot(object)
observationPlot(object, ...) ## S4 method for signature 'FitDist' observationPlot(object)
object |
FitDist Object |
... |
Additional function arguments |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput observationPlot(xFit)
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput observationPlot(xFit)
Plotting the PDF of data and fitted distribution
PDFPlot(object, ...) ## S4 method for signature 'FitDist' PDFPlot(object, n = missing)
PDFPlot(object, ...) ## S4 method for signature 'FitDist' PDFPlot(object, n = missing)
object |
FitDist Object |
... |
Additional function arguments |
n |
Number of samples, should not be used in current setting |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput PDFPlot(xFit)
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput PDFPlot(xFit)
Cumulative probability function of empirical distribution using linear interpolation
Quantile function of Empirical Distribution
Random generation function of Empirical Distribution
Density function of Empirical Distribution based on simulation
pempirical(q, cdf) qempirical(p, cdf) rempirical(n, cdf) dempirical(x, cdf)
pempirical(q, cdf) qempirical(p, cdf) rempirical(n, cdf) dempirical(x, cdf)
q |
Value of the variable |
cdf |
empirical distribution (cdf for continuous distribution and pmf for discrete distribution) |
p |
Value of the probability |
n |
Number of samples |
x |
Value of the variable |
#discrete distribution pempirical(c(3,5,10),matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2)) #continuous distribution pempirical(350,matrix(c(seq(0.01,1,0.01),cumprod(c(1,rep(1.1,99)))),100,2)) #discrete distribution qempirical(c(0.3,0.65,1),matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2)) #continuous distribution qempirical(c(0.3,0.65,0.8),matrix(c(seq(0.01,1,0.01),cumprod(c(1,rep(1.1,99)))),100,2)) #discrete distribution rempirical(100,matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2)) #continuous distribution rempirical(100,matrix(c(seq(0.01,1,0.01),cumprod(c(1,rep(1.1,99)))),100,2)) #discrete distribution dempirical(3,matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2)) #continuous distribution dempirical(30,matrix(c(seq(0.01,1,0.01),qnorm(seq(0.01,1,0.01),30,20)),100,2))
#discrete distribution pempirical(c(3,5,10),matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2)) #continuous distribution pempirical(350,matrix(c(seq(0.01,1,0.01),cumprod(c(1,rep(1.1,99)))),100,2)) #discrete distribution qempirical(c(0.3,0.65,1),matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2)) #continuous distribution qempirical(c(0.3,0.65,0.8),matrix(c(seq(0.01,1,0.01),cumprod(c(1,rep(1.1,99)))),100,2)) #discrete distribution rempirical(100,matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2)) #continuous distribution rempirical(100,matrix(c(seq(0.01,1,0.01),cumprod(c(1,rep(1.1,99)))),100,2)) #discrete distribution dempirical(3,matrix(c(0.1,0.2,0.3,0.05,0.05,0.2,0.1,1:6,10),7,2)) #continuous distribution dempirical(30,matrix(c(seq(0.01,1,0.01),qnorm(seq(0.01,1,0.01),30,20)),100,2))
Plot text content
plotText(content)
plotText(content)
content |
A string to plot |
plotText("You are awesome!")
plotText("You are awesome!")
P-P Plot of data and fitted distribution
PPPlot(object, ...) ## S4 method for signature 'FitDist' PPPlot(object, n = missing)
PPPlot(object, ...) ## S4 method for signature 'FitDist' PPPlot(object, n = missing)
object |
FitDist Object |
... |
Additional function arguments |
n |
Number of samples, should not be used in current setting |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput observationPlot(xFit) PPPlot(xFit)
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput observationPlot(xFit) PPPlot(xFit)
Probability function.
Probability(object, q, ...) ## S4 method for signature 'Normal' Probability(object, q) ## S4 method for signature 'Beta' Probability(object, q) ## S4 method for signature 'Exponential' Probability(object, q) ## S4 method for signature 'Gamma' Probability(object, q) ## S4 method for signature 'Geometric' Probability(object, q) ## S4 method for signature 'Lognormal' Probability(object, q) ## S4 method for signature 'NegativeBinomial' Probability(object, q) ## S4 method for signature 'Pareto' Probability(object, q) ## S4 method for signature 'Poisson' Probability(object, q) ## S4 method for signature 'Uniform' Probability(object, q) ## S4 method for signature 'Weibull' Probability(object, q) ## S4 method for signature 'Empirical' Probability(object, q)
Probability(object, q, ...) ## S4 method for signature 'Normal' Probability(object, q) ## S4 method for signature 'Beta' Probability(object, q) ## S4 method for signature 'Exponential' Probability(object, q) ## S4 method for signature 'Gamma' Probability(object, q) ## S4 method for signature 'Geometric' Probability(object, q) ## S4 method for signature 'Lognormal' Probability(object, q) ## S4 method for signature 'NegativeBinomial' Probability(object, q) ## S4 method for signature 'Pareto' Probability(object, q) ## S4 method for signature 'Poisson' Probability(object, q) ## S4 method for signature 'Uniform' Probability(object, q) ## S4 method for signature 'Weibull' Probability(object, q) ## S4 method for signature 'Empirical' Probability(object, q)
object |
Distribution Object |
q |
Variable value |
... |
Additional function arguments |
xPareto <- new("Pareto",p1=20,p2=3) Probability(xPareto,50)
xPareto <- new("Pareto",p1=20,p2=3) Probability(xPareto,50)
Q-Q Plot of data and fitted distribution
QQPlot(object, ...) ## S4 method for signature 'FitDist' QQPlot(object, n = missing)
QQPlot(object, ...) ## S4 method for signature 'FitDist' QQPlot(object, n = missing)
object |
FitDist Object |
... |
Additional function arguments |
n |
Number of samples, should not be used in current setting |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput QQPlot(xFit)
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput QQPlot(xFit)
Quantile function.
Quantile(object, p, ...) ## S4 method for signature 'Normal' Quantile(object, p) ## S4 method for signature 'Beta' Quantile(object, p) ## S4 method for signature 'Exponential' Quantile(object, p) ## S4 method for signature 'Gamma' Quantile(object, p) ## S4 method for signature 'Geometric' Quantile(object, p) ## S4 method for signature 'Lognormal' Quantile(object, p) ## S4 method for signature 'NegativeBinomial' Quantile(object, p) ## S4 method for signature 'Pareto' Quantile(object, p) ## S4 method for signature 'Poisson' Quantile(object, p) ## S4 method for signature 'Uniform' Quantile(object, p) ## S4 method for signature 'Weibull' Quantile(object, p) ## S4 method for signature 'Empirical' Quantile(object, p)
Quantile(object, p, ...) ## S4 method for signature 'Normal' Quantile(object, p) ## S4 method for signature 'Beta' Quantile(object, p) ## S4 method for signature 'Exponential' Quantile(object, p) ## S4 method for signature 'Gamma' Quantile(object, p) ## S4 method for signature 'Geometric' Quantile(object, p) ## S4 method for signature 'Lognormal' Quantile(object, p) ## S4 method for signature 'NegativeBinomial' Quantile(object, p) ## S4 method for signature 'Pareto' Quantile(object, p) ## S4 method for signature 'Poisson' Quantile(object, p) ## S4 method for signature 'Uniform' Quantile(object, p) ## S4 method for signature 'Weibull' Quantile(object, p) ## S4 method for signature 'Empirical' Quantile(object, p)
object |
Distribution Object |
p |
Probability |
... |
Additional function arguments |
xPareto <- new("Pareto",p1=20,p2=3) Quantile(xPareto,0.6)
xPareto <- new("Pareto",p1=20,p2=3) Quantile(xPareto,0.6)
Simulate whether closed claims will be reopened or not.
rreopen(closeYear, reopenProb)
rreopen(closeYear, reopenProb)
closeYear |
Years after claim closure. It could be a number or a numeric vector. |
reopenProb |
A vector that contains the reopen probability based on closeYear. |
reopenprob<-c(0.02,0.01,0.005,0.005,0.003,0) rreopen(rep(2,1000),reopenprob)
reopenprob<-c(0.02,0.01,0.005,0.005,0.003,0) rreopen(rep(2,1000),reopenprob)
Calculate the excess kurtosis of 10000 sampled values from the distribution.
sampleKurtosis(object, ...) ## S4 method for signature 'Distribution' sampleKurtosis(object)
sampleKurtosis(object, ...) ## S4 method for signature 'Distribution' sampleKurtosis(object)
object |
A Distribution Object |
... |
Additional function arguments |
xLognormal <- new("Lognormal",p1=2,p2=3) sampleKurtosis(xLognormal)
xLognormal <- new("Lognormal",p1=2,p2=3) sampleKurtosis(xLognormal)
Calculate the mean of 100000 sampled values from the distribution.
sampleMean(object, ...) ## S4 method for signature 'Distribution' sampleMean(object)
sampleMean(object, ...) ## S4 method for signature 'Distribution' sampleMean(object)
object |
A Distribution Object |
... |
Additional function arguments |
xLognormal <- new("Lognormal",p1=2,p2=3) sampleMean(xLognormal)
xLognormal <- new("Lognormal",p1=2,p2=3) sampleMean(xLognormal)
Calculate the standard deviation of 10000 sampled values from the distribution.
sampleSd(object, ...) ## S4 method for signature 'Distribution' sampleSd(object)
sampleSd(object, ...) ## S4 method for signature 'Distribution' sampleSd(object)
object |
A Distribution Object |
... |
Additional function arguments |
xLognormal <- new("Lognormal",p1=2,p2=3) sampleSd(xLognormal)
xLognormal <- new("Lognormal",p1=2,p2=3) sampleSd(xLognormal)
Calculate the skewness of 10000 sampled values from the distribution.
sampleSkew(object, ...) ## S4 method for signature 'Distribution' sampleSkew(object)
sampleSkew(object, ...) ## S4 method for signature 'Distribution' sampleSkew(object)
object |
A Distribution Object |
... |
Additional function arguments |
xLognormal <- new("Lognormal",p1=2,p2=3) sampleSkew(xLognormal)
xLognormal <- new("Lognormal",p1=2,p2=3) sampleSkew(xLognormal)
Set the annualized level rate to construct the index. Only used when tabulate == FALSE.
setAnnualizedRate(this, ...) <- value ## S4 replacement method for signature 'Index,numeric' setAnnualizedRate(this) <- value
setAnnualizedRate(this, ...) <- value ## S4 replacement method for signature 'Index,numeric' setAnnualizedRate(this) <- value
this |
Index Object |
... |
Additional function arguments |
value |
Numeric Value (default:0.02) |
xindex <- new("Index") setID(xindex)<-"IDX1" setTabulate(xindex)<-FALSE setAnnualizedRate(xindex)<-0.03 xindex<-setIndex(xindex) xindex@monthlyIndex
xindex <- new("Index") setID(xindex)<-"IDX1" setTabulate(xindex)<-FALSE setAnnualizedRate(xindex)<-0.03 xindex<-setIndex(xindex) xindex@monthlyIndex
Set copula parameters.
setCopulaParam(this, ...) <- value ## S4 replacement method for signature 'CopulaObj,numeric' setCopulaParam(this) <- value
setCopulaParam(this, ...) <- value ## S4 replacement method for signature 'CopulaObj,numeric' setCopulaParam(this) <- value
this |
Copula Object |
... |
Additional function arguments |
value |
The copula parameters |
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) setCopulaParam(cop) <- 0.6
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) setCopulaParam(cop) <- 0.6
Set copula type.
setCopulaType(this, ...) <- value ## S4 replacement method for signature 'CopulaObj,character' setCopulaType(this) <- value
setCopulaType(this, ...) <- value ## S4 replacement method for signature 'CopulaObj,character' setCopulaType(this) <- value
this |
Copula Object |
... |
Additional function arguments |
value |
The copula type |
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) setCopulaType(cop) <- "joe"
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) setCopulaType(cop) <- "joe"
setDevFac
sets a loss development schedule, from either a predictive model or a year-to-year factor vector.
setDevFac(object, ...) ## S4 method for signature 'DevFac' setDevFac(object)
setDevFac(object, ...) ## S4 method for signature 'DevFac' setDevFac(object)
object |
DevFac Object |
... |
Additional function arguments |
xIBNERFactor <- new("DevFac", FacID = "IF1", FacModel = FALSE, meanList = c(1.26,1.1,1.05,1.02,1), volList = rep(0.02,5)) xIBNERFactor<-setDevFac(xIBNERFactor) xIBNERFactor xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-TRUE setFun(xIBNERFactor)<-"identity" setXname(xIBNERFactor)<- c("x1","x2","x3") setParas(xIBNERFactor)<-c(0.6,-0.2,0.01,-0.3,0.02,0.03,0.01,0.02) xIBNERFactor<-setDevFac(xIBNERFactor) xIBNERFactor
xIBNERFactor <- new("DevFac", FacID = "IF1", FacModel = FALSE, meanList = c(1.26,1.1,1.05,1.02,1), volList = rep(0.02,5)) xIBNERFactor<-setDevFac(xIBNERFactor) xIBNERFactor xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-TRUE setFun(xIBNERFactor)<-"identity" setXname(xIBNERFactor)<- c("x1","x2","x3") setParas(xIBNERFactor)<-c(0.6,-0.2,0.01,-0.3,0.02,0.03,0.01,0.02) xIBNERFactor<-setDevFac(xIBNERFactor) xIBNERFactor
Set the degree of freedom for t Copula.
setDf(this, ...) <- value ## S4 replacement method for signature 'CopulaObj,numeric' setDf(this) <- value
setDf(this, ...) <- value ## S4 replacement method for signature 'CopulaObj,numeric' setDf(this) <- value
this |
Copula Object |
... |
Additional function arguments |
value |
The degree of freedom. The default value is 3. |
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) cop <- new("CopulaObj", type="t", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) setDf(cop) <- 5
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) cop <- new("CopulaObj", type="t", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) setDf(cop) <- 5
Set the dimension of the copula.
setDimension(this, ...) <- value ## S4 replacement method for signature 'CopulaObj,numeric' setDimension(this) <- value
setDimension(this, ...) <- value ## S4 replacement method for signature 'CopulaObj,numeric' setDimension(this) <- value
this |
Copula Object |
... |
Additional function arguments |
value |
The dimension of the copula. It can also be set by providing marginal distributions |
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) dist3<-new("Pareto",p1=10,p2=3) setDimension(cop) <- 3 setMarginal(cop) <- list(dist1=dist1,dist2=dist2,dist3=dist3)
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) dist3<-new("Pareto",p1=10,p2=3) setDimension(cop) <- 3 setMarginal(cop) <- list(dist1=dist1,dist2=dist2,dist3=dist3)
Set parameter matrix format of Elliptical copula.
setDispstr(this, ...) <- value ## S4 replacement method for signature 'CopulaObj,character' setDispstr(this) <- value
setDispstr(this, ...) <- value ## S4 replacement method for signature 'CopulaObj,character' setDispstr(this) <- value
this |
Copula Object |
... |
Additional function arguments |
value |
The matrix format. The default is "un" for unstructured. Other choices include "ex" for exchangeable, "ar1" for AR(1), and "toep" for Toeplitz (toeplitz). |
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) setDispstr(cop) <- "ex"
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) setDispstr(cop) <- "ex"
Set the list of values and corresponding probabilities (Pr(X<value) for continuous variable and Pr(X==value) for discrete variable). It is only used for empirical distribution.
setEmpirical(this, ...) <- value ## S4 replacement method for signature 'Distribution,matrix' setEmpirical(this) <- value
setEmpirical(this, ...) <- value ## S4 replacement method for signature 'Distribution,matrix' setEmpirical(this) <- value
this |
Distribution Object |
... |
Additional function arguments. |
value |
Two-column matrix with values and probabilities dist <- new("Normal") setEmpirical(dist) <- matrix(c(0.01,0.25,0.5,0.75,0.99, 11,12,13,14,15), nrow = 5, ncol = 2) dist |
Determine whether the development factor is determined by a predictive model or a fixed schedule by development year
setFacModel(this, ...) <- value ## S4 replacement method for signature 'DevFac,logical' setFacModel(this) <- value
setFacModel(this, ...) <- value ## S4 replacement method for signature 'DevFac,logical' setFacModel(this) <- value
this |
DevFac Object |
... |
Additional function arguments |
value |
Logical Value (default:FALSE) |
xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-TRUE setFun(xIBNERFactor)<-"identity" setXname(xIBNERFactor)<- c("x1","x2","x3") setParas(xIBNERFactor)<-c(0.6,-0.2,0.01,-0.3,0.02,0.03,0.01,0.02) xIBNERFactor<-setDevFac(xIBNERFactor) xIBNERFactor
xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-TRUE setFun(xIBNERFactor)<-"identity" setXname(xIBNERFactor)<- c("x1","x2","x3") setParas(xIBNERFactor)<-c(0.6,-0.2,0.01,-0.3,0.02,0.03,0.01,0.02) xIBNERFactor<-setDevFac(xIBNERFactor) xIBNERFactor
Preparing the input data (observation) for distribution fitting, including detrending, translating occurrence dates to frequency data, etc.
setFitdata(object, ...) ## S4 method for signature 'FitDist' setFitdata(object)
setFitdata(object, ...) ## S4 method for signature 'FitDist' setFitdata(object)
object |
FitDist Object |
... |
Additional function arguments |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) xFit@fitdata
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) xFit@fitdata
Set distribution fitting method.
setfitmethod(this, ...) <- value ## S4 replacement method for signature 'FitDist,character' setfitmethod(this) <- value
setfitmethod(this, ...) <- value ## S4 replacement method for signature 'FitDist,character' setfitmethod(this) <- value
this |
FitDist Object |
... |
Additional function arguments |
value |
A character string: "mle", "mme", or "qme" |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") setfitmethod(xFit) <- "mme" xFit@method
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") setfitmethod(xFit) <- "mme" xFit@method
Directly set the fitted distribution without fitting it to the data.
setFittedDist(this) <- value ## S4 replacement method for signature 'FitDist,Distribution' setFittedDist(this) <- value
setFittedDist(this) <- value ## S4 replacement method for signature 'FitDist,Distribution' setFittedDist(this) <- value
this |
FitDist Object |
value |
Fitted distribution |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@fitted
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@fitted
Set the data frequency.
setfreq(this, ...) <- value ## S4 replacement method for signature 'FitDist,character' setfreq(this) <- value
setfreq(this, ...) <- value ## S4 replacement method for signature 'FitDist,character' setfreq(this) <- value
this |
FitDist Object |
... |
Additional function arguments |
value |
A character string: "Annual" or "Monthly" |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Annual") setfreq(xFit) <- "Monthly" xFit@freq
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Annual") setfreq(xFit) <- "Monthly" xFit@freq
Set the model format/link function (identity/inverse/log/exponential). Only used when FacModel == TRUE.
setFun(this, ...) <- value ## S4 replacement method for signature 'DevFac,character' setFun(this) <- value
setFun(this, ...) <- value ## S4 replacement method for signature 'DevFac,character' setFun(this) <- value
this |
DevFac Object |
... |
Additional function arguments |
value |
String Value (default:"identity") |
xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-TRUE setFun(xIBNERFactor)<-"identity" setXname(xIBNERFactor)<- c("x1","x2","x3") setParas(xIBNERFactor)<-c(0.6,-0.2,0.01,-0.3,0.02,0.03,0.01,0.02) xIBNERFactor<-setDevFac(xIBNERFactor) xIBNERFactor
xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-TRUE setFun(xIBNERFactor)<-"identity" setXname(xIBNERFactor)<- c("x1","x2","x3") setParas(xIBNERFactor)<-c(0.6,-0.2,0.01,-0.3,0.02,0.03,0.01,0.02) xIBNERFactor<-setDevFac(xIBNERFactor) xIBNERFactor
setID Set the ID for an object
setID(this, ...) <- value ## S4 replacement method for signature 'Index,character' setID(this) <- value ## S4 replacement method for signature 'DevFac,character' setID(this) <- value
setID(this, ...) <- value ## S4 replacement method for signature 'Index,character' setID(this) <- value ## S4 replacement method for signature 'DevFac,character' setID(this) <- value
this |
Self |
... |
Additional function arguments |
value |
ID |
xindex <- new("Index") setID(xindex)<-"IDX1" xindex@indexID
xindex <- new("Index") setID(xindex)<-"IDX1" xindex@indexID
Set whether occurrence dates will be used for frequency data.
setidate(this, ...) <- value ## S4 replacement method for signature 'FitDist,logical' setidate(this) <- value
setidate(this, ...) <- value ## S4 replacement method for signature 'FitDist,logical' setidate(this) <- value
this |
FitDist Object |
... |
Additional function arguments |
value |
A boolean |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=FALSE, freq="Monthly") setidate(xFit) <- TRUE xFit@idate
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=FALSE, freq="Monthly") setidate(xFit) <- TRUE xFit@idate
Set the data type: frequency or severity/time lag.
setifreq(this, ...) <- value ## S4 replacement method for signature 'FitDist,logical' setifreq(this) <- value
setifreq(this, ...) <- value ## S4 replacement method for signature 'FitDist,logical' setifreq(this) <- value
this |
FitDist Object |
... |
Additional function arguments |
value |
A boolean |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") setifreq(xFit) <- FALSE xFit@ifreq
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") setifreq(xFit) <- FALSE xFit@ifreq
setIndex
sets a time index to reflect inflation, underwriting cycle or seasonality.
setIndex(object, ...) ## S4 method for signature 'Index' setIndex(object)
setIndex(object, ...) ## S4 method for signature 'Index' setIndex(object)
object |
Index Object |
... |
Additional function arguments |
xindex <- new("Index", indexID = "IDX1", tabulate = FALSE, annualizedRate = 0.03) xindex<-setIndex(xindex) xindex@monthlyIndex xindex <- new("Index") setID(xindex)<-"IDX1" setTabulate(xindex)<-TRUE setAnnualizedRate(xindex)<-0.03 setYearlyIndex(xindex)<- c(1,1.05,1.2,0.95,1.3) set.seed(123) setSeasonality(xindex)<-rnorm(12,mean=1,sd=0.03) xindex<-setIndex(xindex) xindex@monthlyIndex
xindex <- new("Index", indexID = "IDX1", tabulate = FALSE, annualizedRate = 0.03) xindex<-setIndex(xindex) xindex@monthlyIndex xindex <- new("Index") setID(xindex)<-"IDX1" setTabulate(xindex)<-TRUE setAnnualizedRate(xindex)<-0.03 setYearlyIndex(xindex)<- c(1,1.05,1.2,0.95,1.3) set.seed(123) setSeasonality(xindex)<-rnorm(12,mean=1,sd=0.03) xindex<-setIndex(xindex) xindex@monthlyIndex
Set the marginal distributions of the copula.
setMarginal(this, ...) <- value ## S4 replacement method for signature 'CopulaObj,list' setMarginal(this) <- value
setMarginal(this, ...) <- value ## S4 replacement method for signature 'CopulaObj,list' setMarginal(this) <- value
this |
Copula Object |
... |
Additional function arguments |
value |
The list of marginal distributions. |
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) dist3<-new("Pareto",p1=10,p2=3) dist4<-new("Normal",p1=2,p2=3,min=0,max=20,truncated=TRUE) setMarginal(cop) <- list(dist1=dist3,dist2=dist4)
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) dist3<-new("Pareto",p1=10,p2=3) dist4<-new("Normal",p1=2,p2=3,min=0,max=20,truncated=TRUE) setMarginal(cop) <- list(dist1=dist3,dist2=dist4)
setMeanList<-
sets expected year-to-year loss development factor. Years after It is only used when ibnerfModel == FALSE.
setMeanList(this, ...) <- value ## S4 replacement method for signature 'DevFac,vector' setMeanList(this) <- value
setMeanList(this, ...) <- value ## S4 replacement method for signature 'DevFac,vector' setMeanList(this) <- value
this |
DevFac Object |
... |
Additional function arguments |
value |
Numeric Vector |
xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-FALSE setMeanList(xIBNERFactor)<-c(1.26,1.1,1.05,1.02,1) setVolList(xIBNERFactor)<-rep(0.02,5) xIBNERFactor
xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-FALSE setMeanList(xIBNERFactor)<-c(1.26,1.1,1.05,1.02,1) setVolList(xIBNERFactor)<-rep(0.02,5) xIBNERFactor
Set the minimum of the distribution. For example, the distribution of settlement lag for open claims
setMin(object, ...) ## S4 method for signature 'Distribution' setMin(object, minval)
setMin(object, ...) ## S4 method for signature 'Distribution' setMin(object, minval)
object |
A Distribution Object |
... |
Additional function arguments. |
minval |
The minimum value. |
xLognormal <- new("Lognormal",p1=2,p2=3) xLognormal <- setMin(xLognormal,50)
xLognormal <- new("Lognormal",p1=2,p2=3) xLognormal <- setMin(xLognormal,50)
setMonthlyIndex<-
sets monthly index values.
setMonthlyIndex(this, ...) <- value ## S4 replacement method for signature 'Index,vector' setMonthlyIndex(this) <- value
setMonthlyIndex(this, ...) <- value ## S4 replacement method for signature 'Index,vector' setMonthlyIndex(this) <- value
this |
Index Object |
... |
Additional function arguments |
value |
Numeric Vector |
xindex <- new("Index") setID(xindex)<-"IDX1" setTabulate(xindex)<-TRUE setMonthlyIndex(xindex)<- rep(1,360) xindex<-setIndex(xindex) xindex@monthlyIndex
xindex <- new("Index") setID(xindex)<-"IDX1" setTabulate(xindex)<-TRUE setMonthlyIndex(xindex)<- rep(1,360) xindex<-setIndex(xindex) xindex@monthlyIndex
Input the raw data.
setObservation(this) <- value ## S4 replacement method for signature 'CopulaObj,matrix' setObservation(this) <- value ## S4 replacement method for signature 'FitDist,matrix' setObservation(this) <- value
setObservation(this) <- value ## S4 replacement method for signature 'CopulaObj,matrix' setObservation(this) <- value ## S4 replacement method for signature 'FitDist,matrix' setObservation(this) <- value
this |
FitDist Object or Copula Object |
value |
A data frame or a matrix. For FitDist object, it could be a two-column data frame with the occurrence date and loss size/number of occurrence. Or a one-column data frame with loss size (ifreq == FALSE) or number of occurrence (ifreq == TRUE && idate == FALSE) or occurrence dates (ifreq == TRUE && idate == TRUE). For Copula object, it could be a matrix with each column contains the experience data of a variable. |
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) nom.cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) setObservation(nom.cop)<-copulaSample(nom.cop,100) nom.cop@observation
library(cascsim) dist1<-new("Pareto",p1=20,p2=3) dist2<-new("Normal",p1=5,p2=3,min=0,max=20,truncated=TRUE) nom.cop <- new("CopulaObj", param=c(0.5),marginal=list(dist1=dist1,dist2=dist2),dimension=2) setObservation(nom.cop)<-copulaSample(nom.cop,100) nom.cop@observation
Set distribution parameters.
setParams(this, ...) <- value ## S4 replacement method for signature 'Distribution,numeric' setParams(this) <- value
setParams(this, ...) <- value ## S4 replacement method for signature 'Distribution,numeric' setParams(this) <- value
this |
Distribution Object |
... |
Additional function arguments. |
value |
Numeric vector containing parameters examples dist <- new("Normal") setParams(dist) <- c(2,3) dist |
setParas<-
sets model parameters. Their order must match the order of c("Intercept","DevelopmentYear","IncurredLoss","OSRatio",xname,"Volatility"). "Volatility" stands for the volatility of the error term in the model and used to simulate IBNER development factors. The parameter vector is only used when ibnerfModel == TRUE.
setParas(this, ...) <- value ## S4 replacement method for signature 'DevFac,vector' setParas(this) <- value
setParas(this, ...) <- value ## S4 replacement method for signature 'DevFac,vector' setParas(this) <- value
this |
DevFac Object |
... |
Additional function arguments |
value |
Numeric Vector |
xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-TRUE setFun(xIBNERFactor)<-"identity" setXname(xIBNERFactor)<- c("x1","x2","x3") setParas(xIBNERFactor)<-c(0.6,-0.2,0.01,-0.3,0.02,0.03,0.01,0.02) xIBNERFactor<-setDevFac(xIBNERFactor) xIBNERFactor
xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-TRUE setFun(xIBNERFactor)<-"identity" setXname(xIBNERFactor)<- c("x1","x2","x3") setParas(xIBNERFactor)<-c(0.6,-0.2,0.01,-0.3,0.02,0.03,0.01,0.02) xIBNERFactor<-setDevFac(xIBNERFactor) xIBNERFactor
Set the percentiles to be matched. Only used when qme is chosen for fitting method.
setprobs(this, ...) <- value ## S4 replacement method for signature 'FitDist,vector' setprobs(this) <- value
setprobs(this, ...) <- value ## S4 replacement method for signature 'FitDist,vector' setprobs(this) <- value
this |
FitDist Object |
... |
Additional function arguments |
value |
A numeric vector with values between 0 and 1. |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") setprobs(xFit) <- c(0.1,0.5,0.9) xFit@probs
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") setprobs(xFit) <- c(0.1,0.5,0.9) xFit@probs
Set the min and max of the variable.
setRange(this, ...) <- value ## S4 replacement method for signature 'Distribution,numeric' setRange(this) <- value
setRange(this, ...) <- value ## S4 replacement method for signature 'Distribution,numeric' setRange(this) <- value
this |
Distribution Object |
... |
Additional function arguments. |
value |
a two-element vector contains min and max. |
setRectangle
sets up the rectangle based on a data file.
setRectangle(object, data, ...) ## S4 method for signature 'Triangle,data.frame' setRectangle(object, data, evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31"), lob = "Total", ctype = "Total")
setRectangle(object, data, ...) ## S4 method for signature 'Triangle,data.frame' setRectangle(object, data, evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31"), lob = "Total", ctype = "Total")
object |
Triangle Object |
data |
Simulated Data |
... |
Additional function arguments. |
evaluationDate |
Evaluation Date; |
futureDate |
End of projection date; |
lob |
Line of Business; |
ctype |
Claim Type. |
setSeasonality<-
sets monthly multiplier to reflect seasonal impact.
setSeasonality(this, ...) <- value ## S4 replacement method for signature 'Index,vector' setSeasonality(this) <- value
setSeasonality(this, ...) <- value ## S4 replacement method for signature 'Index,vector' setSeasonality(this) <- value
this |
Index Object |
... |
Additional function arguments |
value |
Numeric Vector (default:rep(1,12)) |
xindex <- new("Index") setID(xindex)<-"IDX1" setTabulate(xindex)<-TRUE setAnnualizedRate(xindex)<-0.03 setYearlyIndex(xindex)<- c(1,1.05,1.2,0.95,1.3) set.seed(123) setSeasonality(xindex)<-rnorm(12,mean=1,sd=0.03) xindex<-setIndex(xindex) xindex@monthlyIndex
xindex <- new("Index") setID(xindex)<-"IDX1" setTabulate(xindex)<-TRUE setAnnualizedRate(xindex)<-0.03 setYearlyIndex(xindex)<- c(1,1.05,1.2,0.95,1.3) set.seed(123) setSeasonality(xindex)<-rnorm(12,mean=1,sd=0.03) xindex<-setIndex(xindex) xindex@monthlyIndex
Set the start date for the claim simulation exercise
setStartDate(this, ...) <- value ## S4 replacement method for signature 'Index,Date' setStartDate(this) <- value
setStartDate(this, ...) <- value ## S4 replacement method for signature 'Index,Date' setStartDate(this) <- value
this |
Self |
... |
Additional function arguments |
value |
Start Date |
Determine whether the index values are constructed from a constant rate or provided directly
setTabulate(this, ...) <- value ## S4 replacement method for signature 'Index,logical' setTabulate(this) <- value
setTabulate(this, ...) <- value ## S4 replacement method for signature 'Index,logical' setTabulate(this) <- value
this |
Index Object |
... |
Additional function arguments |
value |
Logical Value (default:FALSE) |
xindex <- new("Index") setID(xindex)<-"IDX1" setTabulate(xindex)<-FALSE setAnnualizedRate(xindex)<-0.03 xindex<-setIndex(xindex) xindex@monthlyIndex
xindex <- new("Index") setID(xindex)<-"IDX1" setTabulate(xindex)<-FALSE setAnnualizedRate(xindex)<-0.03 xindex<-setIndex(xindex) xindex@monthlyIndex
Set the trend with an Index Object.
setTrend(this, ...) <- value ## S4 replacement method for signature 'FitDist,Index' setTrend(this) <- value
setTrend(this, ...) <- value ## S4 replacement method for signature 'FitDist,Index' setTrend(this) <- value
this |
FitDist Object |
... |
Additional function arguments |
value |
An Index Object |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") setTrend(xFit) <- findex xFit@trend
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") setTrend(xFit) <- findex xFit@trend
Distribution fitting and testing.
setTrialDist(this) <- value ## S4 replacement method for signature 'FitDist,Distribution' setTrialDist(this) <- value
setTrialDist(this) <- value ## S4 replacement method for signature 'FitDist,Distribution' setTrialDist(this) <- value
this |
FitDist Object |
value |
Distribution to fit to |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput observationPlot(xFit) fitPlot(xFit)
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDist(xFit) <- new("Poisson") xFit@soutput observationPlot(xFit) fitPlot(xFit)
Distribution fitting and testing. Same as setTrialDist except for error tolerance.
setTrialDistErr(this) <- value ## S4 replacement method for signature 'FitDist,Distribution' setTrialDistErr(this) <- value
setTrialDistErr(this) <- value ## S4 replacement method for signature 'FitDist,Distribution' setTrialDistErr(this) <- value
this |
FitDist Object |
value |
Distribution to fit to |
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDistErr(xFit) <- new("Poisson") xFit@soutput observationPlot(xFit) fitPlot(xFit)
library(cascsim) data(claimdata) #frequecy fitting example findex <- new("Index", startDate = as.Date("2012-01-01"), tabulate=TRUE, monthlyIndex = c(rep(1,11), cumprod(c(1,rep(1.5^(1/12),11))),cumprod(c(1.5,rep((1.3/1.5)^(1/12),11))), cumprod(c(1.3,rep((1.35/1.3)^(1/12),11))),cumprod(c(1.35,rep((1.4/1.35)^(1/12),11))),1.4)) rawdata <- as.data.frame(as.Date(claimdata[(claimdata[,"LoB"]=="Auto" & claimdata[,"Type"]=="H"),]$occurrenceDate)) colnames(rawdata)<-"occurrenceDate" xFit <- new("FitDist", observation=rawdata, trend=findex,startDate = as.Date("2012-01-01"), method="mle",ifreq=TRUE,idate=TRUE, freq="Monthly") xFit <- setFitdata(xFit) setTrialDistErr(xFit) <- new("Poisson") xFit@soutput observationPlot(xFit) fitPlot(xFit)
Set the indicator of truncated distribution.
setTruncated(this, ...) <- value ## S4 replacement method for signature 'Distribution,logical' setTruncated(this) <- value
setTruncated(this, ...) <- value ## S4 replacement method for signature 'Distribution,logical' setTruncated(this) <- value
this |
Distribution Object |
... |
Additional function arguments. |
value |
Boolean to indicate whether the distribution is truncated by min and max or not. |
setUpperKeep
sets up the upper triangle for non-simulated data.
setUpperKeep(object, data, ...) ## S4 method for signature 'Triangle,data.frame' setUpperKeep(object, data, evaluationDate = as.Date("2016-12-31"), lob = "Total", ctype = "Total")
setUpperKeep(object, data, ...) ## S4 method for signature 'Triangle,data.frame' setUpperKeep(object, data, evaluationDate = as.Date("2016-12-31"), lob = "Total", ctype = "Total")
object |
Triangle Object |
data |
Claim Data |
... |
Additional function arguments. |
evaluationDate |
Evaluation Date; |
lob |
Line of Business; |
ctype |
Claim Type. |
library(cascsim) data(claimdata) xTri <- new("Triangle", triID = "TRI1", type = "reportedCount", startDate=as.Date("2012-01-01"), frequency="yearly", sim=1, percentile=50, iRBNER=TRUE, iROPEN=TRUE) xTri<-setUpperTriangle(xTri,claimdata) xTri<-setUpperKeep(xTri,claimdata) xTri@upperkeep xTri <- new("Triangle", triID = "TRI1", type = "closedCount", startDate=as.Date("2012-01-01"), frequency="quarterly", sim=1, percentile=50, iRBNER=FALSE, iROPEN=TRUE) xTri<-setUpperTriangle(xTri,claimdata) xTri<-setUpperKeep(xTri,claimdata) xTri@upperkeep xTri <- new("Triangle", triID = "TRI1", type = "incurredLoss", startDate=as.Date("2012-01-01"), frequency="yearly", sim=1, percentile=50, iRBNER=TRUE, iROPEN=FALSE) xTri<-setUpperTriangle(xTri,claimdata) xTri<-setUpperKeep(xTri,claimdata,lob="Auto",ctype="H") xTri@upperkeep
library(cascsim) data(claimdata) xTri <- new("Triangle", triID = "TRI1", type = "reportedCount", startDate=as.Date("2012-01-01"), frequency="yearly", sim=1, percentile=50, iRBNER=TRUE, iROPEN=TRUE) xTri<-setUpperTriangle(xTri,claimdata) xTri<-setUpperKeep(xTri,claimdata) xTri@upperkeep xTri <- new("Triangle", triID = "TRI1", type = "closedCount", startDate=as.Date("2012-01-01"), frequency="quarterly", sim=1, percentile=50, iRBNER=FALSE, iROPEN=TRUE) xTri<-setUpperTriangle(xTri,claimdata) xTri<-setUpperKeep(xTri,claimdata) xTri@upperkeep xTri <- new("Triangle", triID = "TRI1", type = "incurredLoss", startDate=as.Date("2012-01-01"), frequency="yearly", sim=1, percentile=50, iRBNER=TRUE, iROPEN=FALSE) xTri<-setUpperTriangle(xTri,claimdata) xTri<-setUpperKeep(xTri,claimdata,lob="Auto",ctype="H") xTri@upperkeep
setUpperTriangle
sets up the upper triangle based on a data file.
setUpperTriangle(object, data, ...) ## S4 method for signature 'Triangle,data.frame' setUpperTriangle(object, data, evaluationDate = as.Date("2016-12-31"), lob = "Total", ctype = "Total")
setUpperTriangle(object, data, ...) ## S4 method for signature 'Triangle,data.frame' setUpperTriangle(object, data, evaluationDate = as.Date("2016-12-31"), lob = "Total", ctype = "Total")
object |
Triangle Object |
data |
Claim Data |
... |
Additional function arguments. |
evaluationDate |
Evaluation Date; |
lob |
Line of Business; |
ctype |
Claim Type. |
library(cascsim) data(claimdata) xTri <- new("Triangle", triID = "TRI1", type = "reportedCount", startDate=as.Date("2012-01-01"), frequency="yearly", sim=1, percentile=50) xTri<-setUpperTriangle(xTri,claimdata) xTri@upper xTri <- new("Triangle", triID = "TRI1", type = "closedCount", startDate=as.Date("2012-01-01"), frequency="quarterly", sim=1, percentile=50) xTri<-setUpperTriangle(xTri,claimdata) xTri@upper xTri <- new("Triangle", triID = "TRI1", type = "incurredLoss", startDate=as.Date("2012-01-01"), frequency="yearly", sim=1, percentile=50) xTri<-setUpperTriangle(xTri,claimdata,lob="Auto",ctype="H") xTri@upper xTri <- new("Triangle", triID = "TRI1", type = "paidLoss", startDate=as.Date("2012-01-01"), frequency="yearly", sim=1, percentile=50) xTri<-setUpperTriangle(xTri,claimdata,lob="Auto",ctype="H") xTri@upper
library(cascsim) data(claimdata) xTri <- new("Triangle", triID = "TRI1", type = "reportedCount", startDate=as.Date("2012-01-01"), frequency="yearly", sim=1, percentile=50) xTri<-setUpperTriangle(xTri,claimdata) xTri@upper xTri <- new("Triangle", triID = "TRI1", type = "closedCount", startDate=as.Date("2012-01-01"), frequency="quarterly", sim=1, percentile=50) xTri<-setUpperTriangle(xTri,claimdata) xTri@upper xTri <- new("Triangle", triID = "TRI1", type = "incurredLoss", startDate=as.Date("2012-01-01"), frequency="yearly", sim=1, percentile=50) xTri<-setUpperTriangle(xTri,claimdata,lob="Auto",ctype="H") xTri@upper xTri <- new("Triangle", triID = "TRI1", type = "paidLoss", startDate=as.Date("2012-01-01"), frequency="yearly", sim=1, percentile=50) xTri<-setUpperTriangle(xTri,claimdata,lob="Auto",ctype="H") xTri@upper
setMeanList<-
sets year-to-year loss development factor volatility. It is used to simulate loss development factor assuming a normal distribution. It can be set to zero for deterministic estimation. It is only used when ibnerfModel == FALSE.
setVolList(this, ...) <- value ## S4 replacement method for signature 'DevFac,vector' setVolList(this) <- value
setVolList(this, ...) <- value ## S4 replacement method for signature 'DevFac,vector' setVolList(this) <- value
this |
DevFac Object |
... |
Additional function arguments |
value |
Numeric Vector |
xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-FALSE setMeanList(xIBNERFactor)<-c(1.26,1.1,1.05,1.02,1) setVolList(xIBNERFactor)<-rep(0.02,5) xIBNERFactor
xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-FALSE setMeanList(xIBNERFactor)<-c(1.26,1.1,1.05,1.02,1) setVolList(xIBNERFactor)<-rep(0.02,5) xIBNERFactor
setXname<-
sets explanatory variable names in addition to "Intercept","DevelopmentYear","IncurredLoss", and "OSRatio". Additional variable names must match exactly with claim data. The xname vector is only used when ibnerfModel == TRUE.
setXname(this, ...) <- value ## S4 replacement method for signature 'DevFac,vector' setXname(this) <- value
setXname(this, ...) <- value ## S4 replacement method for signature 'DevFac,vector' setXname(this) <- value
this |
DevFac Object |
... |
Additional function arguments |
value |
Character Vector |
xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-TRUE setFun(xIBNERFactor)<-"identity" setXname(xIBNERFactor)<- c("x1","x2","x3") setParas(xIBNERFactor)<-c(0.6,-0.2,0.01,-0.3,0.02,0.03,0.01,0.02) xIBNERFactor<-setDevFac(xIBNERFactor) xIBNERFactor
xIBNERFactor <- new("DevFac") setID(xIBNERFactor)<-"IF1" setFacModel(xIBNERFactor)<-TRUE setFun(xIBNERFactor)<-"identity" setXname(xIBNERFactor)<- c("x1","x2","x3") setParas(xIBNERFactor)<-c(0.6,-0.2,0.01,-0.3,0.02,0.03,0.01,0.02) xIBNERFactor<-setDevFac(xIBNERFactor) xIBNERFactor
setYearlyIndex<-
sets yearly index values. Monthly index will be constructed assuming constant growth rate during a year.
setYearlyIndex(this, ...) <- value ## S4 replacement method for signature 'Index,vector' setYearlyIndex(this) <- value
setYearlyIndex(this, ...) <- value ## S4 replacement method for signature 'Index,vector' setYearlyIndex(this) <- value
this |
Index Object |
... |
Additional function arguments |
value |
Numeric Vector |
xindex <- new("Index") setID(xindex)<-"IDX1" setTabulate(xindex)<-TRUE setYearlyIndex(xindex)<- c(1,1.05,1.2,0.95,1.3) xindex@yearlyIndex
xindex <- new("Index") setID(xindex)<-"IDX1" setTabulate(xindex)<-TRUE setYearlyIndex(xindex)<- c(1,1.05,1.2,0.95,1.3) xindex@yearlyIndex
Shift monthly index with a new start date and replace the unknown index value with zero.
shiftIndex(object, ...) ## S4 method for signature 'Index' shiftIndex(object, newStartDate, endDate)
shiftIndex(object, ...) ## S4 method for signature 'Index' shiftIndex(object, newStartDate, endDate)
object |
Index Object |
... |
Additional function arguments |
newStartDate |
new start date |
endDate |
end date |
xindex <- new("Index", indexID = "IDX1", tabulate = FALSE, annualizedRate = 0.03) xindex<-setIndex(xindex) xindex@monthlyIndex shiftIndex(xindex,as.Date("2016-10-15"),as.Date("2018-10-15")) shiftIndex(xindex,as.Date("2010-10-15"),as.Date("2013-10-15"))
xindex <- new("Index", indexID = "IDX1", tabulate = FALSE, annualizedRate = 0.03) xindex<-setIndex(xindex) xindex@monthlyIndex shiftIndex(xindex,as.Date("2016-10-15"),as.Date("2018-10-15")) shiftIndex(xindex,as.Date("2010-10-15"),as.Date("2013-10-15"))
Simulate whether claims will have zero payment.
simP0(devYear, zeroProb)
simP0(devYear, zeroProb)
devYear |
Development Year. It could be a number or a numeric vector. |
zeroProb |
A vector that contains the probability of zero payment based on development year. |
zeroprob<-c(0.02,0.01,0.005,0.005,0.003,0) simP0(rep(2,1000),zeroprob)
zeroprob<-c(0.02,0.01,0.005,0.005,0.003,0) simP0(rep(2,1000),zeroprob)
Generate claim simulation result report in html
simReport(object, simSummary, ...) ## S4 method for signature 'Simulation,data.frame' simReport(object, simSummary, simTriangle = NA, startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31"), iYear = FALSE)
simReport(object, simSummary, ...) ## S4 method for signature 'Simulation,data.frame' simReport(object, simSummary, simTriangle = NA, startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31"), iYear = FALSE)
object |
ClaimType object |
simSummary |
simulation result summary generated by simSummary |
... |
Additional parameters that may or may not be used. |
simTriangle |
triangle summary generated by simTriangle; |
startDate |
Date after which claims are analyzed; |
evaluationDate |
Date of evaluation for existing claims and IBNR; |
futureDate |
Date of evaluation for UPR (future claims); |
iYear |
Boolean that indicates whether summary by accident year should be produced in the report. |
#run time is about 30s(>10s) and is commented out here to avoid long waiting time #library(cascsim) #data(claimdata) #lines <- c("Auto") #types <- c("N") #AutoN <- new("ClaimType", line = "Auto", claimType = "N") #AutoN@exposureIndex <- setIndex(new("Index",indexID="I1",tabulate= FALSE, #startDate=as.Date("2012-01-01"), annualizedRate = 0)) # level exposure across time #AutoN@frequency <- new("Poisson", p1 =50) #AutoN@severityIndex <- setIndex(new("Index",indexID="I2",tabulate= FALSE, #startDate=as.Date("2012-01-01"), annualizedRate = 0.02)) #assuming a 2% annual inflation #AutoN@severity <- new("Lognormal", p1 =2, p2 =3) #AutoN@deductible <- new("Empirical", empirical=matrix(c(0,1,100,100),2,2)) #AutoN@limit <- new("Empirical", empirical=matrix(c(0,1,1e8,1e8),2,2)) #AutoN@p0<-new("DevFac",meanList=c(0,0),volList=c(0,0)) #AutoN@reportLag <- new("Exponential", p1 =0.1) #AutoN@settlementLag <- new("Exponential", p1 =0.05) #AutoN@iCopula <- TRUE #use copula #AutoN@ssrCopula <- new("CopulaObj", type ="normal", dimension = 3, #param = c(0.1,0.2,0.1))#A Gaussian Copula #AutoN@ssrCopula@marginal <- c(AutoN@severity,AutoN@settlementLag,AutoN@reportLag) #AutoN@laeDevFac <- new("DevFac",FacID="F1",FacModel= TRUE,fun="linear", #paras =c(5,1.5,0.005,1.2,3)) #AutoN@fIBNER <- new("DevFac",FacID="D1",FacModel= FALSE, #meanList =c(1.2,1.15,1.1,1.05,1),volList =c(0,0,0,0,0)) #AutoN@reopen <- new("DevFac",FacID="D2",FacModel= FALSE, #meanList =c(0.02,0.015,0.01,0.005,0),volList =c(0.003, 0.002, 0.001, 0.001, 0)) #AutoN@roDevFac <- new("DevFac",FacID="D3",FacModel= FALSE, #meanList =c(1.05,1.1,1,1,1),volList =c(0.00589,0.0037,0.00632,0.00815,0)) #AutoN@reopenLag <- new("Exponential", p1 =0.01) #AutoN@resettleLag <- new("Exponential", p1 =0.25) #simobj <- new("Simulation", lines=lines, types=types, #claimobjs= list(AutoN),workingFolder=tempdir()) #simobj@simNo <- 1 #simobj@iRBNER <-FALSE #simobj@iROPEN <-FALSE #simobj@iIBNR <-TRUE #simobj@iUPR <-FALSE #simdata <- claimSimulation(simobj,claimdata, startDate = as.Date("2012-01-01"), #evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31")) #simSummary <- simSummary(simobj,simdata, startDate = as.Date("2012-01-01")) #simTriangle <- simTriangle(simobj,claimdata,simdata, startDate = as.Date("2016-01-01")) #simReport(simobj, simSummary, simTriangle, startDate = as.Date("2012-01-01"))
#run time is about 30s(>10s) and is commented out here to avoid long waiting time #library(cascsim) #data(claimdata) #lines <- c("Auto") #types <- c("N") #AutoN <- new("ClaimType", line = "Auto", claimType = "N") #AutoN@exposureIndex <- setIndex(new("Index",indexID="I1",tabulate= FALSE, #startDate=as.Date("2012-01-01"), annualizedRate = 0)) # level exposure across time #AutoN@frequency <- new("Poisson", p1 =50) #AutoN@severityIndex <- setIndex(new("Index",indexID="I2",tabulate= FALSE, #startDate=as.Date("2012-01-01"), annualizedRate = 0.02)) #assuming a 2% annual inflation #AutoN@severity <- new("Lognormal", p1 =2, p2 =3) #AutoN@deductible <- new("Empirical", empirical=matrix(c(0,1,100,100),2,2)) #AutoN@limit <- new("Empirical", empirical=matrix(c(0,1,1e8,1e8),2,2)) #AutoN@p0<-new("DevFac",meanList=c(0,0),volList=c(0,0)) #AutoN@reportLag <- new("Exponential", p1 =0.1) #AutoN@settlementLag <- new("Exponential", p1 =0.05) #AutoN@iCopula <- TRUE #use copula #AutoN@ssrCopula <- new("CopulaObj", type ="normal", dimension = 3, #param = c(0.1,0.2,0.1))#A Gaussian Copula #AutoN@ssrCopula@marginal <- c(AutoN@severity,AutoN@settlementLag,AutoN@reportLag) #AutoN@laeDevFac <- new("DevFac",FacID="F1",FacModel= TRUE,fun="linear", #paras =c(5,1.5,0.005,1.2,3)) #AutoN@fIBNER <- new("DevFac",FacID="D1",FacModel= FALSE, #meanList =c(1.2,1.15,1.1,1.05,1),volList =c(0,0,0,0,0)) #AutoN@reopen <- new("DevFac",FacID="D2",FacModel= FALSE, #meanList =c(0.02,0.015,0.01,0.005,0),volList =c(0.003, 0.002, 0.001, 0.001, 0)) #AutoN@roDevFac <- new("DevFac",FacID="D3",FacModel= FALSE, #meanList =c(1.05,1.1,1,1,1),volList =c(0.00589,0.0037,0.00632,0.00815,0)) #AutoN@reopenLag <- new("Exponential", p1 =0.01) #AutoN@resettleLag <- new("Exponential", p1 =0.25) #simobj <- new("Simulation", lines=lines, types=types, #claimobjs= list(AutoN),workingFolder=tempdir()) #simobj@simNo <- 1 #simobj@iRBNER <-FALSE #simobj@iROPEN <-FALSE #simobj@iIBNR <-TRUE #simobj@iUPR <-FALSE #simdata <- claimSimulation(simobj,claimdata, startDate = as.Date("2012-01-01"), #evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31")) #simSummary <- simSummary(simobj,simdata, startDate = as.Date("2012-01-01")) #simTriangle <- simTriangle(simobj,claimdata,simdata, startDate = as.Date("2016-01-01")) #simReport(simobj, simSummary, simTriangle, startDate = as.Date("2012-01-01"))
Claim simulation result summary
simSummary(object, simdata, ...) ## S4 method for signature 'Simulation,data.frame' simSummary(object, simdata, startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31"))
simSummary(object, simdata, ...) ## S4 method for signature 'Simulation,data.frame' simSummary(object, simdata, startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31"))
object |
Simulation object |
simdata |
simulation data generated by claimSimulation |
... |
Additional parameters that may or may not be used. |
startDate |
Date after which claims are analyzed; |
evaluationDate |
Date of evaluation for existing claims and IBNR; |
futureDate |
Date of evaluation for UPR (future claims). |
#run time is about 30s(>10s) and is commented out here to avoid long waiting time #library(cascsim) #data(claimdata) #lines <- c("Auto") #types <- c("N") #AutoN <- new("ClaimType", line = "Auto", claimType = "N") #AutoN@exposureIndex <- setIndex(new("Index",indexID="I1",tabulate= FALSE, #startDate=as.Date("2012-01-01"), annualizedRate = 0)) # level exposure across time #AutoN@frequency <- new("Poisson", p1 =50) #AutoN@severityIndex <- setIndex(new("Index",indexID="I2",tabulate= FALSE, #startDate=as.Date("2012-01-01"), annualizedRate = 0.02)) #assuming a 2% annual inflation #AutoN@severity <- new("Lognormal", p1 =2, p2 =3) #AutoN@deductible <- new("Empirical", empirical=matrix(c(0,1,100,100),2,2)) #AutoN@limit <- new("Empirical", empirical=matrix(c(0,1,1e8,1e8),2,2)) #AutoN@p0<-new("DevFac",meanList=c(0,0),volList=c(0,0)) #AutoN@reportLag <- new("Exponential", p1 =0.1) #AutoN@settlementLag <- new("Exponential", p1 =0.05) #AutoN@iCopula <- TRUE #use copula #AutoN@ssrCopula <- new("CopulaObj", type ="normal", dimension = 3, #param = c(0.1,0.2,0.1))#A Gaussian Copula #AutoN@ssrCopula@marginal <- c(AutoN@severity,AutoN@settlementLag,AutoN@reportLag) #AutoN@laeDevFac <- new("DevFac",FacID="F1",FacModel= TRUE,fun="linear", #paras =c(5,1.5,0.005,1.2,3)) #AutoN@fIBNER <- new("DevFac",FacID="D1",FacModel= FALSE, #meanList =c(1.2,1.15,1.1,1.05,1),volList =c(0,0,0,0,0)) #AutoN@reopen <- new("DevFac",FacID="D2",FacModel= FALSE, #meanList =c(0.02,0.015,0.01,0.005,0),volList =c(0.003, 0.002, 0.001, 0.001, 0)) #AutoN@roDevFac <- new("DevFac",FacID="D3",FacModel= FALSE, #meanList =c(1.05,1.1,1,1,1),volList =c(0.00589,0.0037,0.00632,0.00815,0)) #AutoN@reopenLag <- new("Exponential", p1 =0.01) #AutoN@resettleLag <- new("Exponential", p1 =0.25) #simobj <- new("Simulation", lines=lines, types=types, #claimobjs= list(AutoN),workingFolder=tempdir()) #simobj@simNo <- 1 #simobj@iRBNER <-FALSE #simobj@iROPEN <-FALSE #simobj@iIBNR <-TRUE #simobj@iUPR <-FALSE #simdata <- claimSimulation(simobj,claimdata, startDate = as.Date("2012-01-01"), #evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31")) #simSummary <- simSummary(simobj,simdata, startDate = as.Date("2012-01-01"))
#run time is about 30s(>10s) and is commented out here to avoid long waiting time #library(cascsim) #data(claimdata) #lines <- c("Auto") #types <- c("N") #AutoN <- new("ClaimType", line = "Auto", claimType = "N") #AutoN@exposureIndex <- setIndex(new("Index",indexID="I1",tabulate= FALSE, #startDate=as.Date("2012-01-01"), annualizedRate = 0)) # level exposure across time #AutoN@frequency <- new("Poisson", p1 =50) #AutoN@severityIndex <- setIndex(new("Index",indexID="I2",tabulate= FALSE, #startDate=as.Date("2012-01-01"), annualizedRate = 0.02)) #assuming a 2% annual inflation #AutoN@severity <- new("Lognormal", p1 =2, p2 =3) #AutoN@deductible <- new("Empirical", empirical=matrix(c(0,1,100,100),2,2)) #AutoN@limit <- new("Empirical", empirical=matrix(c(0,1,1e8,1e8),2,2)) #AutoN@p0<-new("DevFac",meanList=c(0,0),volList=c(0,0)) #AutoN@reportLag <- new("Exponential", p1 =0.1) #AutoN@settlementLag <- new("Exponential", p1 =0.05) #AutoN@iCopula <- TRUE #use copula #AutoN@ssrCopula <- new("CopulaObj", type ="normal", dimension = 3, #param = c(0.1,0.2,0.1))#A Gaussian Copula #AutoN@ssrCopula@marginal <- c(AutoN@severity,AutoN@settlementLag,AutoN@reportLag) #AutoN@laeDevFac <- new("DevFac",FacID="F1",FacModel= TRUE,fun="linear", #paras =c(5,1.5,0.005,1.2,3)) #AutoN@fIBNER <- new("DevFac",FacID="D1",FacModel= FALSE, #meanList =c(1.2,1.15,1.1,1.05,1),volList =c(0,0,0,0,0)) #AutoN@reopen <- new("DevFac",FacID="D2",FacModel= FALSE, #meanList =c(0.02,0.015,0.01,0.005,0),volList =c(0.003, 0.002, 0.001, 0.001, 0)) #AutoN@roDevFac <- new("DevFac",FacID="D3",FacModel= FALSE, #meanList =c(1.05,1.1,1,1,1),volList =c(0.00589,0.0037,0.00632,0.00815,0)) #AutoN@reopenLag <- new("Exponential", p1 =0.01) #AutoN@resettleLag <- new("Exponential", p1 =0.25) #simobj <- new("Simulation", lines=lines, types=types, #claimobjs= list(AutoN),workingFolder=tempdir()) #simobj@simNo <- 1 #simobj@iRBNER <-FALSE #simobj@iROPEN <-FALSE #simobj@iIBNR <-TRUE #simobj@iUPR <-FALSE #simdata <- claimSimulation(simobj,claimdata, startDate = as.Date("2012-01-01"), #evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31")) #simSummary <- simSummary(simobj,simdata, startDate = as.Date("2012-01-01"))
Claim simulation result triangles
simTriangle(object, claimdata, simdata, ...) ## S4 method for signature 'Simulation,data.frame,data.frame' simTriangle(object, claimdata, simdata, frequency = "yearly", startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31"))
simTriangle(object, claimdata, simdata, ...) ## S4 method for signature 'Simulation,data.frame,data.frame' simTriangle(object, claimdata, simdata, frequency = "yearly", startDate = as.Date("2012-01-01"), evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31"))
object |
Simulation object |
claimdata |
claim data used as basis for simulation |
simdata |
simulation data generated by claimSimulation |
... |
Additional parameters that may or may not be used. |
frequency |
triangle frequency, either "yearly" or "quarterly"; |
startDate |
Date after which claims are analyzed; |
evaluationDate |
Date of evaluation for existing claims and IBNR; |
futureDate |
Date of evaluation for UPR (future claims). |
#run time is about 30s(>10s) and is commented out here to avoid long waiting time #library(cascsim) #data(claimdata) #lines <- c("Auto") #types <- c("N") #AutoN <- new("ClaimType", line = "Auto", claimType = "N") #AutoN@exposureIndex <- setIndex(new("Index",indexID="I1",tabulate= FALSE, #startDate=as.Date("2012-01-01"), annualizedRate = 0)) # level exposure across time #AutoN@frequency <- new("Poisson", p1 =50) #AutoN@severityIndex <- setIndex(new("Index",indexID="I2",tabulate= FALSE, #startDate=as.Date("2012-01-01"), annualizedRate = 0.02)) #assuming a 2% annual inflation #AutoN@severity <- new("Lognormal", p1 =2, p2 =3) #AutoN@deductible <- new("Empirical", empirical=matrix(c(0,1,100,100),2,2)) #AutoN@limit <- new("Empirical", empirical=matrix(c(0,1,1e8,1e8),2,2)) #AutoN@p0<-new("DevFac",meanList=c(0,0),volList=c(0,0)) #AutoN@reportLag <- new("Exponential", p1 =0.1) #AutoN@settlementLag <- new("Exponential", p1 =0.05) #AutoN@iCopula <- TRUE #use copula #AutoN@ssrCopula <- new("CopulaObj", type ="normal", dimension = 3, #param = c(0.1,0.2,0.1))#A Gaussian Copula #AutoN@ssrCopula@marginal <- c(AutoN@severity,AutoN@settlementLag,AutoN@reportLag) #AutoN@laeDevFac <- new("DevFac",FacID="F1",FacModel= TRUE,fun="linear", #paras =c(5,1.5,0.005,1.2,3)) #AutoN@fIBNER <- new("DevFac",FacID="D1",FacModel= FALSE, #meanList =c(1.2,1.15,1.1,1.05,1),volList =c(0,0,0,0,0)) #AutoN@reopen <- new("DevFac",FacID="D2",FacModel= FALSE, #meanList =c(0.02,0.015,0.01,0.005,0),volList =c(0.003, 0.002, 0.001, 0.001, 0)) #AutoN@roDevFac <- new("DevFac",FacID="D3",FacModel= FALSE, #meanList =c(1.05,1.1,1,1,1),volList =c(0.00589,0.0037,0.00632,0.00815,0)) #AutoN@reopenLag <- new("Exponential", p1 =0.01) #AutoN@resettleLag <- new("Exponential", p1 =0.25) #simobj <- new("Simulation", lines=lines, types=types, #claimobjs= list(AutoN),workingFolder=tempdir()) #simobj@simNo <- 1 #simobj@iRBNER <-FALSE #simobj@iROPEN <-FALSE #simobj@iIBNR <-TRUE #simobj@iUPR <-FALSE #simdata <- claimSimulation(simobj,claimdata, startDate = as.Date("2012-01-01"), #evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31")) #simSummary <- simSummary(simobj,simdata, startDate = as.Date("2012-01-01")) #simTriangle <- simTriangle(simobj,claimdata,simdata, startDate = as.Date("2012-01-01"))
#run time is about 30s(>10s) and is commented out here to avoid long waiting time #library(cascsim) #data(claimdata) #lines <- c("Auto") #types <- c("N") #AutoN <- new("ClaimType", line = "Auto", claimType = "N") #AutoN@exposureIndex <- setIndex(new("Index",indexID="I1",tabulate= FALSE, #startDate=as.Date("2012-01-01"), annualizedRate = 0)) # level exposure across time #AutoN@frequency <- new("Poisson", p1 =50) #AutoN@severityIndex <- setIndex(new("Index",indexID="I2",tabulate= FALSE, #startDate=as.Date("2012-01-01"), annualizedRate = 0.02)) #assuming a 2% annual inflation #AutoN@severity <- new("Lognormal", p1 =2, p2 =3) #AutoN@deductible <- new("Empirical", empirical=matrix(c(0,1,100,100),2,2)) #AutoN@limit <- new("Empirical", empirical=matrix(c(0,1,1e8,1e8),2,2)) #AutoN@p0<-new("DevFac",meanList=c(0,0),volList=c(0,0)) #AutoN@reportLag <- new("Exponential", p1 =0.1) #AutoN@settlementLag <- new("Exponential", p1 =0.05) #AutoN@iCopula <- TRUE #use copula #AutoN@ssrCopula <- new("CopulaObj", type ="normal", dimension = 3, #param = c(0.1,0.2,0.1))#A Gaussian Copula #AutoN@ssrCopula@marginal <- c(AutoN@severity,AutoN@settlementLag,AutoN@reportLag) #AutoN@laeDevFac <- new("DevFac",FacID="F1",FacModel= TRUE,fun="linear", #paras =c(5,1.5,0.005,1.2,3)) #AutoN@fIBNER <- new("DevFac",FacID="D1",FacModel= FALSE, #meanList =c(1.2,1.15,1.1,1.05,1),volList =c(0,0,0,0,0)) #AutoN@reopen <- new("DevFac",FacID="D2",FacModel= FALSE, #meanList =c(0.02,0.015,0.01,0.005,0),volList =c(0.003, 0.002, 0.001, 0.001, 0)) #AutoN@roDevFac <- new("DevFac",FacID="D3",FacModel= FALSE, #meanList =c(1.05,1.1,1,1,1),volList =c(0.00589,0.0037,0.00632,0.00815,0)) #AutoN@reopenLag <- new("Exponential", p1 =0.01) #AutoN@resettleLag <- new("Exponential", p1 =0.25) #simobj <- new("Simulation", lines=lines, types=types, #claimobjs= list(AutoN),workingFolder=tempdir()) #simobj@simNo <- 1 #simobj@iRBNER <-FALSE #simobj@iROPEN <-FALSE #simobj@iIBNR <-TRUE #simobj@iUPR <-FALSE #simdata <- claimSimulation(simobj,claimdata, startDate = as.Date("2012-01-01"), #evaluationDate = as.Date("2016-12-31"), futureDate = as.Date("2017-12-31")) #simSummary <- simSummary(simobj,simdata, startDate = as.Date("2012-01-01")) #simTriangle <- simTriangle(simobj,claimdata,simdata, startDate = as.Date("2012-01-01"))
An S4 class to represent a simulation task.
startNo
The starting simulation index.
simNo
Number of simulation.
lines
A string vector to identify the business line(s) to be simulated.
types
A string vector to identify the claim types to be simulated.
iRBNER
A Boolean indicating whether IBNER claims need to be simulated.
iROPEN
A Boolean indicating whether claim reopening needs to be simulated.
iIBNR
A Boolean indicating whether IBNR claims need to be simulated.
iUPR
A Boolean indicating whether future claims need to be simulated.
claimobjs
A list of claim objects.
workingFolder
A string to specify the working folder where the simulation results will be saved.
iCopula
A Boolean indicating whether to use copula for frequency simulation.
freqCopula
Frequency copula.
iSummary
A Boolean indicating whether to summarzie the simulation results.
iReport
A Boolean indicating whether to generate an HTML report.
iFit
A Boolean indicating whether to fit some simulation parameters based on claim data.
ncores
Number of cores used for simulation.
tag
A unique tag for the simulation object including date and a random ID.
fitfile
A string to set the distribution fitting file name. If omitted, a name based on tag will be used.
copfile
A string to set the copula fitting file name. If omitted, a name based on tag will be used.
facfile
A string to set the factor fitting file name. Factor table is development year dependant. It could be the probability of zero payment, reopen probability, or loss development factors. If omitted, a name based on tag will be used.
fitRpt
A string to set the distribution fitting html report file name. If omitted, a name based on tag will be used.
simfile
A string to set the simulation result file name. If omitted, a name based on tag will be used.
sumfile
A string to set the summary file name. If omitted, a name based on tag will be used.
plog
A string to set the parallel run log file name. If omitted, a name based on tag will be used.
htmlRpt
A string to set the html report name. If omitted, a name based on tag will be used.
libpath
A string to the R liabrary folder where required packages are installed.
Calculate Theoretical Excessive Kurtosis of distribution. min and max are not applied
TEKurt(object, ...) ## S4 method for signature 'Normal' TEKurt(object) ## S4 method for signature 'Beta' TEKurt(object) ## S4 method for signature 'Exponential' TEKurt(object) ## S4 method for signature 'Gamma' TEKurt(object) ## S4 method for signature 'Geometric' TEKurt(object) ## S4 method for signature 'Lognormal' TEKurt(object) ## S4 method for signature 'NegativeBinomial' TEKurt(object) ## S4 method for signature 'Pareto' TEKurt(object) ## S4 method for signature 'Poisson' TEKurt(object) ## S4 method for signature 'Uniform' TEKurt(object) ## S4 method for signature 'Weibull' TEKurt(object)
TEKurt(object, ...) ## S4 method for signature 'Normal' TEKurt(object) ## S4 method for signature 'Beta' TEKurt(object) ## S4 method for signature 'Exponential' TEKurt(object) ## S4 method for signature 'Gamma' TEKurt(object) ## S4 method for signature 'Geometric' TEKurt(object) ## S4 method for signature 'Lognormal' TEKurt(object) ## S4 method for signature 'NegativeBinomial' TEKurt(object) ## S4 method for signature 'Pareto' TEKurt(object) ## S4 method for signature 'Poisson' TEKurt(object) ## S4 method for signature 'Uniform' TEKurt(object) ## S4 method for signature 'Weibull' TEKurt(object)
object |
Distribution Object |
... |
Additional function arguments |
xPareto <- new("Pareto",p1=20,p2=5) TEKurt(xPareto)
xPareto <- new("Pareto",p1=20,p2=5) TEKurt(xPareto)
Calculate Theoretical Mean of distribution. min and max are not applied
TMean(object, ...) ## S4 method for signature 'Normal' TMean(object) ## S4 method for signature 'Beta' TMean(object) ## S4 method for signature 'Exponential' TMean(object) ## S4 method for signature 'Gamma' TMean(object) ## S4 method for signature 'Geometric' TMean(object) ## S4 method for signature 'Lognormal' TMean(object) ## S4 method for signature 'NegativeBinomial' TMean(object) ## S4 method for signature 'Pareto' TMean(object) ## S4 method for signature 'Poisson' TMean(object) ## S4 method for signature 'Uniform' TMean(object) ## S4 method for signature 'Weibull' TMean(object)
TMean(object, ...) ## S4 method for signature 'Normal' TMean(object) ## S4 method for signature 'Beta' TMean(object) ## S4 method for signature 'Exponential' TMean(object) ## S4 method for signature 'Gamma' TMean(object) ## S4 method for signature 'Geometric' TMean(object) ## S4 method for signature 'Lognormal' TMean(object) ## S4 method for signature 'NegativeBinomial' TMean(object) ## S4 method for signature 'Pareto' TMean(object) ## S4 method for signature 'Poisson' TMean(object) ## S4 method for signature 'Uniform' TMean(object) ## S4 method for signature 'Weibull' TMean(object)
object |
Distribution Object |
... |
Additional function arguments |
xPareto <- new("Pareto",p1=20,p2=3) TMean(xPareto)
xPareto <- new("Pareto",p1=20,p2=3) TMean(xPareto)
Convert US date mm/dd/yyyy to yyyy-mm-dd format
toDate(d)
toDate(d)
d |
vector of dates in possible US format |
toDate("3/5/2017")
toDate("3/5/2017")
An S4 class to represent a triangle or rectangle object.
triID
A character string to identify the triangle object.
type
A character string that indicates the triangle type, such as reportedCount, closedCount, paidLoss, and incurredLoss.
startDate
The start date for the accident year or Quarter.
frequency
A character that indicates the frequency of the triangle, "yearly" or "quarterly".
sim
A number that indicates the simulation number used to complete the rectangle. Zero means using the average value.
percentile
A number that indicates the percentile used to complete the rectangle. It is only used when sim is NA.
iRBNER
A Boolean that indicates whether open claims are simulated. If not, current information will be used for constructing rectangles. Otherwise, simulated data will be used.
iROPEN
A Boolean that indicates whether claim reopen are simulated. If not, current information will be used for constructing rectangles. Otherwise, simulated data will be used.
percentile
A number that indicates the percentile used to complete the rectangle. It is only used when sim is NA.
upper
A matrix that contains the upper triangle based on claim data.
upperkeep
A matrix that contains the upper triangle that are not simulated. It will be used to construct the rectangle for the non-simulated part.
rectangle
A matrix that contains the entire rectangle based on simulation data.
Truncate a numeric vector
truncate(x, lower, upper)
truncate(x, lower, upper)
x |
A numeric vector |
lower |
Lower bound |
upper |
Upper bound |
trunc(rnorm(100,3,6),0,7)
trunc(rnorm(100,3,6),0,7)
Calculate Theoretical Standard Deviation of distribution. min and max are not applied
TSD(object, ...) ## S4 method for signature 'Normal' TSD(object) ## S4 method for signature 'Beta' TSD(object) ## S4 method for signature 'Exponential' TSD(object) ## S4 method for signature 'Gamma' TSD(object) ## S4 method for signature 'Geometric' TSD(object) ## S4 method for signature 'Lognormal' TSD(object) ## S4 method for signature 'NegativeBinomial' TSD(object) ## S4 method for signature 'Pareto' TSD(object) ## S4 method for signature 'Poisson' TSD(object) ## S4 method for signature 'Uniform' TSD(object) ## S4 method for signature 'Weibull' TSD(object)
TSD(object, ...) ## S4 method for signature 'Normal' TSD(object) ## S4 method for signature 'Beta' TSD(object) ## S4 method for signature 'Exponential' TSD(object) ## S4 method for signature 'Gamma' TSD(object) ## S4 method for signature 'Geometric' TSD(object) ## S4 method for signature 'Lognormal' TSD(object) ## S4 method for signature 'NegativeBinomial' TSD(object) ## S4 method for signature 'Pareto' TSD(object) ## S4 method for signature 'Poisson' TSD(object) ## S4 method for signature 'Uniform' TSD(object) ## S4 method for signature 'Weibull' TSD(object)
object |
Distribution Object |
... |
Additional function arguments |
xPareto <- new("Pareto",p1=20,p2=3) TSD(xPareto)
xPareto <- new("Pareto",p1=20,p2=3) TSD(xPareto)
Calculate Theoretical Skewness of distribution. min and max are not applied
TSkewness(object, ...) ## S4 method for signature 'Normal' TSkewness(object) ## S4 method for signature 'Beta' TSkewness(object) ## S4 method for signature 'Exponential' TSkewness(object) ## S4 method for signature 'Gamma' TSkewness(object) ## S4 method for signature 'Geometric' TSkewness(object) ## S4 method for signature 'Lognormal' TSkewness(object) ## S4 method for signature 'NegativeBinomial' TSkewness(object) ## S4 method for signature 'Pareto' TSkewness(object) ## S4 method for signature 'Poisson' TSkewness(object) ## S4 method for signature 'Uniform' TSkewness(object) ## S4 method for signature 'Weibull' TSkewness(object)
TSkewness(object, ...) ## S4 method for signature 'Normal' TSkewness(object) ## S4 method for signature 'Beta' TSkewness(object) ## S4 method for signature 'Exponential' TSkewness(object) ## S4 method for signature 'Gamma' TSkewness(object) ## S4 method for signature 'Geometric' TSkewness(object) ## S4 method for signature 'Lognormal' TSkewness(object) ## S4 method for signature 'NegativeBinomial' TSkewness(object) ## S4 method for signature 'Pareto' TSkewness(object) ## S4 method for signature 'Poisson' TSkewness(object) ## S4 method for signature 'Uniform' TSkewness(object) ## S4 method for signature 'Weibull' TSkewness(object)
object |
Distribution Object |
... |
Additional function arguments |
xPareto <- new("Pareto",p1=20,p2=4) TSkewness(xPareto)
xPareto <- new("Pareto",p1=20,p2=4) TSkewness(xPareto)
Calculate ultimate development factor based on current development year, a mean development factor schedule and its volatility. It is used to simulate the ultimate loss for open claims.
ultiDevFac(Years, meanDevFac, sdDevFac = rep(0, length(meanDevFac)), distType = "normal")
ultiDevFac(Years, meanDevFac, sdDevFac = rep(0, length(meanDevFac)), distType = "normal")
Years |
Include two columns: Current development year and Settlement Year |
meanDevFac |
A vector that contains the expected development factor schedule for Normal distribution. It is mu for Lognormal distribution and shape for Gamma distribution. |
sdDevFac |
A vector that contains the standard deviation of expected development factor schedule for Normal distribution. It is sigma for Lognormal distribution and scale for Gamma distribution. |
distType |
distribution type for development factor. It can be "normal", "lognormal" or "gamma". |
meanfac<-c(1.1,1.08,1.05,1.03,1.01,1) volfac<-rep(0.02,6) years<-matrix(c(1:6),3,2) ultiDevFac(years,meanfac,volfac)
meanfac<-c(1.1,1.08,1.05,1.03,1.01,1) volfac<-rep(0.02,6) years<-matrix(c(1:6),3,2) ultiDevFac(years,meanfac,volfac)