View source: R/features_02a_claim_covariates.R
relativity_template | R Documentation |
Constructs a template for the covariate relativities based on the inputed covariates. Note that only non-zero relativities and one cross-factor relativity is needed for each factor pair.
relativity_template(factors)
factors |
named list of vectors, containing the name of the covariates and associated factors in vector form. |
Suppose that there are m
covariates labelled c_i
, i=1,...,m
,
and that covariate c_i
can assume one and only one of n_i
values,
x_{ik}
, k=1,...,n_i
. The total number of available covariate
values is n = \sum_{i=1}^m n_o
.
Now set up an n \times n
matrix F
, consisting of sub-matrices
F_{ij}
, i,j = 1, ... ,m
of dimension n_i \times n_j
. The
diagonal blocks F_{ii}
will quantify first-order relativities on claims
attributes, and the off-diagonal blocks F_{ij}
, j \neq i
will quantify
second-order effects. Let f_{ij,kl}
denote the (k, l)
element of
F_{ij}
. This element operates as a multiplier of the claim attribute
when covariates c_i
and c_j
take values x_{ik}
and x_jl
respectively. Since c_i
can assume only one of the values x_ik
,
f_{ii, kl} = 0
for k \neq l
, and so F_{ii}
is diagonal for
all i=1, ..., m
. Moreover, f_{ij,kl} = f_{ji,lk}
, so that
F
is symmetric and f_{ij,kl} > 0
.
Returns a dataframe object, with five columns:
factor_i | Factor i. |
factor_j | Factor j. |
level_ik | Level within Factor i. |
level_jl | Level within Factor j. |
relativity | Relativity between level_ik and level_jl , defaults to NA .
|
factors <- list(
"Legal Representation" = c("Y", "N"),
"Injury Severity" = as.character(1:6),
"Age of Claimant" = c("0-15", "15-30", "30-50", "50-65", "over 65")
)
relativity_freq <- relativity_template(factors)
relativity_sev <- relativity_template(factors)
# Default Values
relativity_freq$relativity <- c(
1, 1,
0.95, 1, 1, 1, 1, 1,
0.05, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
0.53, 0.3, 0.1, 0.05, 0.01, 0.01,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
0.183, 0.192, 0.274, 0.18, 0.171
)
relativity_sev$relativity <- c(
2, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
0.6, 1.2, 2.5, 5, 8, 0.4,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 1, 1,
1, 1, 1, 0.97, 0.95,
1, 1, 1, 0.95, 0.9,
1, 1, 1, 1, 1,
1.25, 1.15, 1, 0.85, 0.7
)
head(relativity_freq)
head(relativity_sev)
test_covariates_obj <- covariates(factors)
test_covariates_obj <- set.covariates_relativity(
covariates = test_covariates_obj,
relativity = relativity_freq,
freq_sev = "freq"
)
test_covariates_obj <- set.covariates_relativity(
covariates = test_covariates_obj,
relativity = relativity_sev,
freq_sev = "sev"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.