Skip to contents

Fit a random effects model using Ohlsson's methodology. In this function you estimate the power parameter p. See hierCredGLM when you want fix p.

Usage

hierCredTweedie(
  formula,
  data,
  weights,
  muHatGLM = TRUE,
  epsilon = 1e-04,
  maxiter = 500,
  verbose = FALSE,
  returnData = TRUE,
  cpglmControl = list(bound.p = c(1.01, 1.99)),
  balanceProperty = TRUE,
  optimizer = "bobyqa",
  y = TRUE,
  ...
)

Arguments

formula

object of type formula that specifies which model should be fitted. Syntax is the same as for lmer and glmer. For example, Yijkt ~ x1 + x2 + (1 | Industry / Branch).

data

an object that is coercible by as.data.table, containing the variables in the model.

weights

variable name of the exposure weight.

muHatGLM

indicates which estimate has to be used in the algorithm for the intercept term. Default is TRUE, which used the intercept as estimated by the GLM. If FALSE, the estimate of the hierarchical credibility model is used.

epsilon

positive convergence tolerance \(\epsilon\); the iterations converge when \(||\theta[k] - \theta[k - 1]||^2[[2]]/||\theta[k - 1]||^2[[2]] < \epsilon\). Here, \(\theta[k]\) is the parameter vector at the \(k^{th}\) iteration.

maxiter

maximum number of iterations.

verbose

logical indicating if output should be produced during the algorithm.

returnData

logical indicating if input data has to be returned.

cpglmControl

a list of parameters to control the fitting process in the GLM part. By default, cpglmControl = list(bound.p = c(1.01, 1.99)) which restricts the range of the power parameter p to [1.01, 1.99] in the fitting process. This list is passed to cpglm.

balanceProperty

logical indicating if the balance property should be satisfied.

optimizer

a character string that determines which optimization routine is to be used in estimating the index and the dispersion parameters. Possible choices are "nlminb" (the default, see nlminb), "bobyqa" (bobyqa) and "L-BFGS-B" (optim).

y

logical indicating whether the response vector should be returned as a component of the returned value.

...

arguments passed to cpglm.

Value

An object of type hierCredTweedie with the following slots:

call

the matched call

HierarchicalResults

results of the hierarchical credibility model.

fitGLM

the results from fitting the GLM part.

iter

total number of iterations.

Converged

logical indicating whether the algorithm converged.

LevelsCov

object that summarizes the unique levels of each of the contract-specific covariates.

fitted.values

the fitted mean values, resulting from the model fit.

prior.weights

the weights (exposure) initially supplied.

y

if requested, the response vector. Default is TRUE.

Details

When estimating the GLM part, this function uses the cpglm function from the cplm package.

References

Ohlsson, E. (2008). Combining generalized linear models and credibility models in practice. Scandinavian Actuarial Journal 2008(4), 301–314.

See also

hierCredTweedie-class, fitted.hierCredTweedie, predict.hierCredTweedie, ranef-actuaRE, weights-actuaRE, hierCredibility, hierCredGLM, cpglm, plotRE, adjustIntercept, BalanceProperty @references Campo, B.D.C. and Antonio, Katrien (2023). Insurance pricing with hierarchically structured data an illustration with a workers' compensation insurance portfolio. Scandinavian Actuarial Journal, doi: 10.1080/03461238.2022.2161413

Examples

# \donttest{
data("dataCar")
fit = hierCredTweedie(Y ~ area + (1 | VehicleType / VehicleBody), dataCar,
weights = w, epsilon = 1e-6)
fit
#> Call:
#> hierCredTweedie(formula = Y ~ area + (1 | VehicleType/VehicleBody), 
#>     data = dataCar, weights = w, epsilon = 1e-06)
#> 
#> 
#> Combination of the hierarchical credibility model with a GLM
#> 
#> Estimated variance parameters:
#>   Var(V[jk]): 349.3256 
#>   Var(V[j]): 628.8985 
#> Unique number of categories of VehicleType: 2
#> Unique number of categories of VehicleBody: 9
#> 
#> Results contract-specific risk factors:
#> 
#> 
#> Call:
#> cpglm(formula = FormulaGLM, link = "log", data = data, weights = wijkt, 
#>     control = cpglmControl, optimizer = optimizer)
#> 
#> Deviance Residuals: 
#>    Min      1Q  Median      3Q     Max  
#> -8.095  -5.970  -4.573  -2.928  86.137  
#>             Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)  5.63662    0.08834  63.803   <2e-16 ***
#> areaB        0.04772    0.13048   0.366   0.7146    
#> areaC        0.07692    0.11742   0.655   0.5124    
#> areaD       -0.18574    0.15671  -1.185   0.2359    
#> areaE        0.13053    0.16712   0.781   0.4348    
#> areaF        0.46389    0.18823   2.464   0.0137 *  
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Estimated dispersion parameter: 175.29
#> Estimated index parameter: 1.5705 
#> 
#> Residual deviance: 2360054  on 67560  degrees of freedom
#> AIC:  116884 
#> 
#> Number of Fisher Scoring iterations:  6 
#> 
summary(fit)
#> Call:
#> hierCredTweedie(formula = Y ~ area + (1 | VehicleType/VehicleBody), 
#>     data = dataCar, weights = w, epsilon = 1e-06)
#> 
#> 
#> Combination of the hierarchical credibility model with a GLM
#> 
#> Estimated variance parameters:
#>   Individual contracts: 4289401 
#>   Var(V[jk]): 349.3256 
#>   Var(V[j]): 628.8985 
#> Unique number of categories of VehicleType: 2
#> Unique number of categories of VehicleBody: 9
#> 
#> Results contract-specific risk factors:
#> 
#> 
#> Call:
#> cpglm(formula = FormulaGLM, link = "log", data = data, weights = wijkt, 
#>     control = cpglmControl, optimizer = optimizer)
#> 
#> Deviance Residuals: 
#>    Min      1Q  Median      3Q     Max  
#> -8.095  -5.970  -4.573  -2.928  86.137  
#>             Estimate Std. Error t value Pr(>|t|)    
#> (Intercept)  5.63662    0.08834  63.803   <2e-16 ***
#> areaB        0.04772    0.13048   0.366   0.7146    
#> areaC        0.07692    0.11742   0.655   0.5124    
#> areaD       -0.18574    0.15671  -1.185   0.2359    
#> areaE        0.13053    0.16712   0.781   0.4348    
#> areaF        0.46389    0.18823   2.464   0.0137 *  
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> Estimated dispersion parameter: 175.29
#> Estimated index parameter: 1.5705 
#> 
#> Residual deviance: 2360054  on 67560  degrees of freedom
#> AIC:  116884 
#> 
#> Number of Fisher Scoring iterations:  6 
#> 
#> $call
#> cpglm(formula = FormulaGLM, link = "log", data = data, weights = wijkt, 
#>     control = cpglmControl, optimizer = optimizer)
#> 
#> $deviance
#> [1] 2360054
#> 
#> $aic
#> [1] 116884
#> 
#> $contrasts
#> NULL
#> 
#> $df.residual
#> [1] 67560
#> 
#> $iter
#> [1] 6
#> 
#> $na.action
#> NULL
#> 
#> $deviance.resid
#>       Min        1Q    Median        3Q       Max 
#> -8.095052 -5.969509 -4.572944 -2.927895 86.137065 
#> 
#> $coefficients
#>                Estimate Std. Error    t value   Pr(>|t|)
#> (Intercept)  5.63661846 0.08834343 63.8034805 0.00000000
#> areaB        0.04771903 0.13047847  0.3657234 0.71457260
#> areaC        0.07691849 0.11741546  0.6550968 0.51240767
#> areaD       -0.18573986 0.15670655 -1.1852719 0.23591415
#> areaE        0.13052750 0.16711877  0.7810464 0.43477797
#> areaF        0.46389185 0.18823319  2.4644530 0.01372473
#> 
#> $dispersion
#> [1] 175.2852
#> 
#> $vcov
#>              (Intercept)        areaB        areaC        areaD        areaE
#> (Intercept)  0.007804562 -0.007804562 -0.007804562 -0.007804562 -0.007804562
#> areaB       -0.007804562  0.017024631  0.007804562  0.007804562  0.007804562
#> areaC       -0.007804562  0.007804562  0.013786391  0.007804562  0.007804562
#> areaD       -0.007804562  0.007804562  0.007804562  0.024556942  0.007804562
#> areaE       -0.007804562  0.007804562  0.007804562  0.007804562  0.027928682
#> areaF       -0.007804562  0.007804562  0.007804562  0.007804562  0.007804562
#>                    areaF
#> (Intercept) -0.007804562
#> areaB        0.007804562
#> areaC        0.007804562
#> areaD        0.007804562
#> areaE        0.007804562
#> areaF        0.035431734
#> 
#> $p
#> [1] 1.570459
#> 
ranef(fit)
#> $sector
#>         VehicleType        Uj
#> 1:   Common vehicle 0.9557004
#> 2: Uncommon vehicle 1.0509018
#> 
#> $group
#>         VehicleType VehicleBody       Ujk
#> 1:   Common vehicle       HBACK 1.0248171
#> 2:   Common vehicle       SEDAN 0.9524791
#> 3:   Common vehicle         UTE 0.9969568
#> 4: Uncommon vehicle       COUPE 1.0232340
#> 5: Uncommon vehicle       HDTOP 1.0064096
#> 6: Uncommon vehicle       MIBUS 1.0041678
#> 7: Uncommon vehicle       PANVN 1.0022996
#> 8: Uncommon vehicle       STNWG 0.9831763
#> 9: Uncommon vehicle       TRUCK 1.0076169
#> 
fixef(fit)
#> (Intercept)       areaB       areaC       areaD       areaE       areaF 
#>  5.63661846  0.04771903  0.07691849 -0.18573986  0.13052750  0.46389185 
# }