relativity_template function

Template to input Covariate Relativities

Template to input Covariate Relativities

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)

Arguments

  • factors: named list of vectors, containing the name of the covariates and associated factors in vector form.

Returns

Returns a dataframe object, with five columns:

factor_iFactor i.
factor_jFactor j.
level_ikLevel within Factor i.
level_jlLevel within Factor j.
relativityRelativity between level_ik and level_jl , defaults to NA .

Details

Suppose that there are mm covariates labelled cic_i, i=1,...,mi=1,...,m, and that covariate cic_i can assume one and only one of nin_i values, xikx_{ik}, k=1,...,nik=1,...,n_i. The total number of available covariate values is n=i=1mnon = \sum_{i=1}^m n_o.

Now set up an n×nn \times n matrix FF, consisting of sub-matrices FijF_{ij}, i,j=1,...,mi,j = 1, ... ,m of dimension ni×njn_i \times n_j. The diagonal blocks FiiF_{ii} will quantify first-order relativities on claims attributes, and the off-diagonal blocks FijF_{ij}, jij \neq i will quantify second-order effects. Let fij,klf_{ij,kl} denote the (k,l)(k, l) element of FijF_{ij}. This element operates as a multiplier of the claim attribute when covariates cic_i and cjc_j take values xikx_{ik} and xjlx_jl

respectively. Since cic_i can assume only one of the values xikx_ik, fii,kl=0f_{ii, kl} = 0 for klk \neq l, and so FiiF_{ii} is diagonal for all i=1,...,mi=1, ..., m. Moreover, fij,kl=fji,lkf_{ij,kl} = f_{ji,lk}, so that FF is symmetric and fij,kl>0f_{ij,kl} > 0.

Examples

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" )
  • Maintainer: Melantha Wang
  • License: GPL-3
  • Last published: 2024-01-27