This vignette aims to illustrate
how the inclusion of covariates can influence the severity of the claims
generated using the SynthETIC package. The distributional
assumptions shown in this vignette are consistent with the default
assumptions of the SynthETIC package (an Auto Liability
portfolio). The inclusion of covariates aims to be a minor adjustment
step to modelled claim sizes after Step 2: Claim size discussed
in the SynthETIC-demo
vignette.
In particular, with this demo we will construct:
| Description | R Object |
|---|---|
| Covariate Inputs | covariate_obj = various factors, their
levels and relativities for covariate frequency and claim severity |
| Covariate Outputs | covariates_data_obj = dataset of assigned
covariates for each claim |
| S_adj, claim size | claim_size_w_cov[[i]] = claim size for all
claims that occurred in period i after adjustment for
covariates |
SynthETIC Set UpWe set up package-wise global parameters demonstrated in the
SynthETIC-demo vignette (which can be accessed via
vignette("SynthETIC-demo", package = "SynthETIC") or online
documentation) and perform modelling Steps 1 and 2 to generate the
claim frequency and claim sizes under the default assumptions. Note that
changing these assumptions for Steps 1 and 2 do not affect how
covariates are implemented.
library(SynthETIC)
set.seed(20200131)
set_parameters(ref_claim = 200000, time_unit = 1/4)
ref_claim <- return_parameters()[1]
time_unit <- return_parameters()[2]
years <- 10
I <- years / time_unit
E <- c(rep(12000, I)) # effective annual exposure rates
lambda <- c(rep(0.03, I))
# Modelling Steps 1-2
n_vector <- claim_frequency(I = I, E = E, freq = lambda)
occurrence_times <- claim_occurrence(frequency_vector = n_vector)
claim_sizes <- claim_size(frequency_vector = n_vector)To apply simulated covariates to SynthETIC claim sizes,
a covariates is used in conjunction with the
claim_size_adj() function to both simulate covariate
combinations and apply adjusted claim sizes. The example
covariates object below includes relativities for
test_covariates_obj <- SynthETIC::test_covariates_obj
print(test_covariates_obj)
#> $factors
#> $factors$`Legal Representation`
#> [1] "Y" "N"
#>
#> $factors$`Injury Severity`
#> [1] "1" "2" "3" "4" "5" "6"
#>
#> $factors$`Age of Claimant`
#> [1] "0-15" "15-30" "30-50" "50-65" "over 65"
#>
#>
#> $relativity_freq
#> factor_i factor_j level_ik level_jl relativity
#> 1 Legal Representation Legal Representation Y Y 1.000
#> 2 Legal Representation Legal Representation N N 1.000
#> 3 Legal Representation Injury Severity Y 1 0.950
#> 4 Legal Representation Injury Severity Y 2 1.000
#> 5 Legal Representation Injury Severity Y 3 1.000
#> 6 Legal Representation Injury Severity Y 4 1.000
#> 7 Legal Representation Injury Severity Y 5 1.000
#> 8 Legal Representation Injury Severity Y 6 1.000
#> 9 Legal Representation Injury Severity N 1 0.050
#> 10 Legal Representation Injury Severity N 2 0.000
#> 11 Legal Representation Injury Severity N 3 0.000
#> 12 Legal Representation Injury Severity N 4 0.000
#> 13 Legal Representation Injury Severity N 5 0.000
#> 14 Legal Representation Injury Severity N 6 0.000
#> 15 Legal Representation Age of Claimant Y 0-15 1.000
#> 16 Legal Representation Age of Claimant Y 15-30 1.000
#> 17 Legal Representation Age of Claimant Y 30-50 1.000
#> 18 Legal Representation Age of Claimant Y 50-65 1.000
#> 19 Legal Representation Age of Claimant Y over 65 1.000
#> 20 Legal Representation Age of Claimant N 0-15 1.000
#> 21 Legal Representation Age of Claimant N 15-30 1.000
#> 22 Legal Representation Age of Claimant N 30-50 1.000
#> 23 Legal Representation Age of Claimant N 50-65 1.000
#> 24 Legal Representation Age of Claimant N over 65 1.000
#> 25 Injury Severity Injury Severity 1 1 0.530
#> 26 Injury Severity Injury Severity 2 2 0.300
#> 27 Injury Severity Injury Severity 3 3 0.100
#> 28 Injury Severity Injury Severity 4 4 0.050
#> 29 Injury Severity Injury Severity 5 5 0.010
#> 30 Injury Severity Injury Severity 6 6 0.010
#> 31 Injury Severity Age of Claimant 1 0-15 1.000
#> 32 Injury Severity Age of Claimant 1 15-30 1.000
#> 33 Injury Severity Age of Claimant 1 30-50 1.000
#> 34 Injury Severity Age of Claimant 1 50-65 1.000
#> 35 Injury Severity Age of Claimant 1 over 65 1.000
#> 36 Injury Severity Age of Claimant 2 0-15 1.000
#> 37 Injury Severity Age of Claimant 2 15-30 1.000
#> 38 Injury Severity Age of Claimant 2 30-50 1.000
#> 39 Injury Severity Age of Claimant 2 50-65 1.000
#> 40 Injury Severity Age of Claimant 2 over 65 1.000
#> 41 Injury Severity Age of Claimant 3 0-15 1.000
#> 42 Injury Severity Age of Claimant 3 15-30 1.000
#> 43 Injury Severity Age of Claimant 3 30-50 1.000
#> 44 Injury Severity Age of Claimant 3 50-65 1.000
#> 45 Injury Severity Age of Claimant 3 over 65 1.000
#> 46 Injury Severity Age of Claimant 4 0-15 1.000
#> 47 Injury Severity Age of Claimant 4 15-30 1.000
#> 48 Injury Severity Age of Claimant 4 30-50 1.000
#> 49 Injury Severity Age of Claimant 4 50-65 1.000
#> 50 Injury Severity Age of Claimant 4 over 65 1.000
#> 51 Injury Severity Age of Claimant 5 0-15 1.000
#> 52 Injury Severity Age of Claimant 5 15-30 1.000
#> 53 Injury Severity Age of Claimant 5 30-50 1.000
#> 54 Injury Severity Age of Claimant 5 50-65 1.000
#> 55 Injury Severity Age of Claimant 5 over 65 1.000
#> 56 Injury Severity Age of Claimant 6 0-15 1.000
#> 57 Injury Severity Age of Claimant 6 15-30 1.000
#> 58 Injury Severity Age of Claimant 6 30-50 1.000
#> 59 Injury Severity Age of Claimant 6 50-65 1.000
#> 60 Injury Severity Age of Claimant 6 over 65 1.000
#> 61 Age of Claimant Age of Claimant 0-15 0-15 0.183
#> 62 Age of Claimant Age of Claimant 15-30 15-30 0.192
#> 63 Age of Claimant Age of Claimant 30-50 30-50 0.274
#> 64 Age of Claimant Age of Claimant 50-65 50-65 0.180
#> 65 Age of Claimant Age of Claimant over 65 over 65 0.171
#>
#> $relativity_sev
#> factor_i factor_j level_ik level_jl relativity
#> 1 Legal Representation Legal Representation Y Y 2.00
#> 2 Legal Representation Legal Representation N N 1.00
#> 3 Legal Representation Injury Severity Y 1 1.00
#> 4 Legal Representation Injury Severity Y 2 1.00
#> 5 Legal Representation Injury Severity Y 3 1.00
#> 6 Legal Representation Injury Severity Y 4 1.00
#> 7 Legal Representation Injury Severity Y 5 1.00
#> 8 Legal Representation Injury Severity Y 6 1.00
#> 9 Legal Representation Injury Severity N 1 1.00
#> 10 Legal Representation Injury Severity N 2 1.00
#> 11 Legal Representation Injury Severity N 3 1.00
#> 12 Legal Representation Injury Severity N 4 1.00
#> 13 Legal Representation Injury Severity N 5 1.00
#> 14 Legal Representation Injury Severity N 6 1.00
#> 15 Legal Representation Age of Claimant Y 0-15 1.00
#> 16 Legal Representation Age of Claimant Y 15-30 1.00
#> 17 Legal Representation Age of Claimant Y 30-50 1.00
#> 18 Legal Representation Age of Claimant Y 50-65 1.00
#> 19 Legal Representation Age of Claimant Y over 65 1.00
#> 20 Legal Representation Age of Claimant N 0-15 1.00
#> 21 Legal Representation Age of Claimant N 15-30 1.00
#> 22 Legal Representation Age of Claimant N 30-50 1.00
#> 23 Legal Representation Age of Claimant N 50-65 1.00
#> 24 Legal Representation Age of Claimant N over 65 1.00
#> 25 Injury Severity Injury Severity 1 1 0.60
#> 26 Injury Severity Injury Severity 2 2 1.20
#> 27 Injury Severity Injury Severity 3 3 2.50
#> 28 Injury Severity Injury Severity 4 4 5.00
#> 29 Injury Severity Injury Severity 5 5 8.00
#> 30 Injury Severity Injury Severity 6 6 0.40
#> 31 Injury Severity Age of Claimant 1 0-15 1.00
#> 32 Injury Severity Age of Claimant 1 15-30 1.00
#> 33 Injury Severity Age of Claimant 1 30-50 1.00
#> 34 Injury Severity Age of Claimant 1 50-65 1.00
#> 35 Injury Severity Age of Claimant 1 over 65 1.00
#> 36 Injury Severity Age of Claimant 2 0-15 1.00
#> 37 Injury Severity Age of Claimant 2 15-30 1.00
#> 38 Injury Severity Age of Claimant 2 30-50 1.00
#> 39 Injury Severity Age of Claimant 2 50-65 1.00
#> 40 Injury Severity Age of Claimant 2 over 65 1.00
#> 41 Injury Severity Age of Claimant 3 0-15 1.00
#> 42 Injury Severity Age of Claimant 3 15-30 1.00
#> 43 Injury Severity Age of Claimant 3 30-50 1.00
#> 44 Injury Severity Age of Claimant 3 50-65 1.00
#> 45 Injury Severity Age of Claimant 3 over 65 1.00
#> 46 Injury Severity Age of Claimant 4 0-15 1.00
#> 47 Injury Severity Age of Claimant 4 15-30 1.00
#> 48 Injury Severity Age of Claimant 4 30-50 1.00
#> 49 Injury Severity Age of Claimant 4 50-65 0.97
#> 50 Injury Severity Age of Claimant 4 over 65 0.95
#> 51 Injury Severity Age of Claimant 5 0-15 1.00
#> 52 Injury Severity Age of Claimant 5 15-30 1.00
#> 53 Injury Severity Age of Claimant 5 30-50 1.00
#> 54 Injury Severity Age of Claimant 5 50-65 0.95
#> 55 Injury Severity Age of Claimant 5 over 65 0.90
#> 56 Injury Severity Age of Claimant 6 0-15 1.00
#> 57 Injury Severity Age of Claimant 6 15-30 1.00
#> 58 Injury Severity Age of Claimant 6 30-50 1.00
#> 59 Injury Severity Age of Claimant 6 50-65 1.00
#> 60 Injury Severity Age of Claimant 6 over 65 1.00
#> 61 Age of Claimant Age of Claimant 0-15 0-15 1.25
#> 62 Age of Claimant Age of Claimant 15-30 15-30 1.15
#> 63 Age of Claimant Age of Claimant 30-50 30-50 1.00
#> 64 Age of Claimant Age of Claimant 50-65 50-65 0.85
#> 65 Age of Claimant Age of Claimant over 65 over 65 0.70
#>
#> attr(,"class")
#> [1] "covariates"The claim_size_adj() function simulates the covariate
levels for each claim and then adjusts the claim sizes according to the
relativities defined above. The covariate levels for each claim can be
accessed in the covariates_data$data attribute of the
function output.
claim_size_covariates <- claim_size_adj(test_covariates_obj, claim_sizes)
covariates_data_obj <- claim_size_covariates$covariates_data
head(data.frame(covariates_data_obj$data))
#> Legal.Representation Injury.Severity Age.of.Claimant
#> 1 Y 4 15-30
#> 2 Y 5 50-65
#> 3 Y 3 over 65
#> 4 Y 1 30-50
#> 5 Y 2 over 65
#> 6 Y 1 0-15The adjusted claim sizes are stored in the
claim_size_adj attribute.
claim_size_w_cov <- claim_size_covariates$claim_size_adj
claim_size_w_cov[[1]]
#> [1] 3739647.7148 1149728.3702 44874.7873 24.8279 9985.7184
#> [6] 423282.8905 6812.2756 2999.6733 27997.9206 3890.6787
#> [11] 55279.2869 28689.3563 81276.7686 4191.0917 450270.6689
#> [16] 4126657.7735 1509.1414 175964.8381 2718.7119 669654.3800
#> [21] 4562.7708 120613.1427 26453.5692 153603.5457 48656.8827
#> [26] 39724.9007 305787.6385 40710.3323 232535.3602 101718.7909
#> [31] 16159.3904 147139.7820 97638.5131 1073365.3018 97248.4590
#> [36] 157453.5438 317.0998 97173.6502 67580.1853 42745.1336
#> [41] 28208.5407 26084.5159 26828.6094 445.0400 282498.1910
#> [46] 96144.7380 32690.8529 9252.9813 561.4646 37100.3159
#> [51] 48368.7502 258576.8021 198889.6727 292373.8157 2558.2023
#> [56] 153543.6720 724.3892 11909.1351 2202.5643 13606.7134
#> [61] 194030.7055 73555.6589 41012.8696 208797.3319 12288.1475
#> [66] 39007.1143 199240.6102 4565.2795 26775.5009 65412.5925
#> [71] 129120.5313 1517524.0493 73248.0545 6674.9148 175083.1622
#> [76] 84592.8998 108539.5339 305767.8591 131622.6343 22844.8455
#> [81] 131632.1520 171068.1563 157776.6116 5778.8732 296599.5890
#> [86] 1263.5721 15723.1293 70277.8501 33518.2401 268400.2461Just as in Steps 1-2, Steps 3 onwards also do not require any
specific adjustment in relation to implementing covariates. Guidance on
implementing these modelling steps can be found in the
SynthETIC-demo vignette. We can see from the example below
that the inclusion of covariates primarily has an impact on claim sizes
and thus any following modelling steps that are also impacted from the
adjusted claim sizes. Note that the number of claims
(n_vector) and the time at which they occur
(occurrence_times) are unaffected by covariates.
generate_claims_dataset <- function(claim_size_list) {
# SynthETIC Steps 3-5
notidel <- claim_notification(n_vector, claim_size_list)
setldel <- claim_closure(n_vector, claim_size_list)
no_payments <- claim_payment_no(n_vector, claim_size_list)
claim_dataset <- generate_claim_dataset(
frequency_vector = n_vector,
occurrence_list = occurrence_times,
claim_size_list = claim_size_list,
notification_list = notidel,
settlement_list = setldel,
no_payments_list = no_payments
)
claim_dataset
}
claim_dataset <- generate_claims_dataset(claim_size_list = claim_sizes)
claim_dataset_w_cov <- generate_claims_dataset(claim_size_list = claim_size_w_cov)
head(claim_dataset)
#> claim_no occurrence_period occurrence_time claim_size notidel setldel
#> 1 1 1 0.6238351 783769.11073 1.6236481 20.070717
#> 2 2 1 0.1206679 214480.60483 2.6297216 25.556061
#> 3 3 1 0.2220436 30902.21786 1.4058893 8.828525
#> 4 4 1 0.4538309 49.86708 0.7639090 1.050653
#> 5 5 1 0.5910992 14326.01244 1.9583709 3.073137
#> 6 6 1 0.9524492 680134.40835 0.4805288 23.606627
#> no_payment
#> 1 11
#> 2 4
#> 3 5
#> 4 1
#> 5 3
#> 6 5
head(claim_dataset_w_cov)
#> claim_no occurrence_period occurrence_time claim_size notidel setldel
#> 1 1 1 0.6238351 3739647.7148 0.5010955 39.972461
#> 2 2 1 0.1206679 1149728.3702 2.1036364 33.078038
#> 3 3 1 0.2220436 44874.7873 1.2420013 4.725958
#> 4 4 1 0.4538309 24.8279 4.8339620 1.312075
#> 5 5 1 0.5910992 9985.7184 2.7611940 2.109292
#> 6 6 1 0.9524492 423282.8905 0.8693386 28.857195
#> no_payment
#> 1 4
#> 2 4
#> 3 5
#> 4 1
#> 5 2
#> 6 12This section shows the impact of using a set of covariates different
than the default values within the SynthETIC package.
The included framework allows a user to easily construct any set of covariates required for simulation and/or analysis. This gives the user flexibility in choosing both the number of factors in the set of covariates and the number of levels within each factor.
The below example compares
SynthETICfactors_tmp <- list(
"Vehicle Type" = c("Passenger", "Light Commerical", "Medium Goods", "Heavy Goods"),
"Business Use" = c("Y", "N")
)
relativity_freq_tmp <- relativity_template(factors_tmp)
relativity_sev_tmp <- relativity_template(factors_tmp)
# Default Values
relativity_freq_tmp$relativity <- c(
5, 1.5, 0.35, 0.25,
1, 4,
1, 0.6,
0.35, 0.01,
0.25, 0,
2.5, 5
)
relativity_sev_tmp$relativity <- c(
0.25, 0.75, 1, 3,
1, 1,
1, 1,
1, 1,
1, 1,
1.3, 1
)
test_covariates_obj_veh <- covariates(factors_tmp)
test_covariates_obj_veh <- set.covariates_relativity(
covariates = test_covariates_obj_veh,
relativity = relativity_freq_tmp,
freq_sev = "freq"
)
test_covariates_obj_veh <- set.covariates_relativity(
covariates = test_covariates_obj_veh,
relativity = relativity_sev_tmp,
freq_sev = "sev"
)
claim_size_covariates_veh <- claim_size_adj(test_covariates_obj_veh, claim_sizes)
# Comparison of the same claim size except with adjustments due to covariates
data.frame(
Claim_Size = head(round(claim_sizes[[1]]))
,Claim_Size_Original_Covariates = head(round(claim_size_covariates$claim_size_adj[[1]]))
,Claim_Size_New_Covariates = head(round(claim_size_covariates_veh$claim_size_adj[[1]]))
)
#> Claim_Size Claim_Size_Original_Covariates Claim_Size_New_Covariates
#> 1 783769 3739648 641574
#> 2 214481 1149728 175569
#> 3 30902 44875 25296
#> 4 50 25 41
#> 5 14326 9986 11727
#> 6 680134 423283 556741
# Covariate Levels
head(claim_size_covariates$covariates_data$data)
#> Legal Representation Injury Severity Age of Claimant
#> 1 Y 4 15-30
#> 2 Y 5 50-65
#> 3 Y 3 over 65
#> 4 Y 1 30-50
#> 5 Y 2 over 65
#> 6 Y 1 0-15
head(claim_size_covariates_veh$covariates_data$data)
#> Vehicle Type Business Use
#> 1 Passenger N
#> 2 Passenger N
#> 3 Passenger N
#> 4 Passenger N
#> 5 Passenger N
#> 6 Passenger NTo apply specific covariate values for each claim occurrence, we can
use the parameter covariates_id when constructing the
covariates_data object. This would map the each claim to a
corresponding known covariate value from a dataset and apply the
relevant severity relativities. Note that in this case, the frequency
relativities would not be used, as no simulation of covariate values are
performed.
In the example below, we have a known dataset of covariates, which can be mapped to each of the claim sizes. In the covariates dataset, we know:
As a result, we can use the indices for each of these rows to map each set of covariates to its associated claim. In this case, the first 50 claims are related to the last 50 rows in the covariates dataset in reverse order, and claims 51–100 are related to the first 50 rows in the covariates dataset.
claim_sizes_known <- list(c(
rexp(n = 100, rate = 1.5)
))
known_covariates_dataset <- data.frame(
"Vehicle Type" = rep(rep(c("Passenger", "Light Commerical"), each = 25), times = 2),
"Business Use" = c(rep("N", times = 50), rep("Y", times = 50))
)
colnames(known_covariates_dataset) <- c("Vehicle Type", "Business Use")
covariates_data_veh <- covariates_data(
test_covariates_obj_veh,
data = known_covariates_dataset,
covariates_id = list(c(100:51, 1:50))
)
claim_sizes_adj_tmp <- claim_size_adj.fit(
covariates_data = covariates_data_veh,
claim_size = claim_sizes_known
)
head(claim_sizes_adj_tmp[[1]])
#> [1] 0.9040738 0.5424940 0.9514574 3.8774523 2.8469142 2.0752603