Combining the Buhlmann-Straub credibility model with a GLM (Ohlsson, 2008)
buhlmannStraubGLM.RdFit a single-level random effects model using Ohlsson's methodology combined with Buhlmann-Straub credibility.
This is the single-level analogue of hierCredGLM.
Usage
buhlmannStraubGLM(
formula,
data,
weights,
p = 1.5,
link.power = 0,
muHatGLM = FALSE,
epsilon = 1e-04,
maxiter = 500,
maxiterGLM = 500,
verbose = FALSE,
returnData = TRUE,
balanceProperty = TRUE,
y = TRUE,
...
)Arguments
- formula
object of type
formulathat specifies which model should be fitted. Syntax followslmer: e.g.,Y ~ x1 + x2 + (1 | Cluster). Only one random effect is allowed.- data
an object that is coercible by
as.data.table, containing the variables in the model.- weights
variable name of the exposure weight.
- p
the value for the power parameter of the Tweedie distribution, which is passed to
tweedie. Default is1.5.- link.power
index of power link function, which is passed to
tweedie.link.power = 0produces a log-link. Defaults to the canonical link, which is1 - p.- muHatGLM
indicates which estimate has to be used in the algorithm for the intercept term. Default is
TRUE, which uses the intercept as estimated by the GLM. IfFALSE, the estimate of the Buhlmann-Straub 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.
- maxiterGLM
maximum number of iterations when fitting the GLM part. Passed to
glm.- verbose
logical indicating if output should be produced during the algorithm.
- returnData
logical indicating if input data has to be returned.
- balanceProperty
logical indicating if the balance property should be satisfied.
- y
logical indicating whether the response vector should be returned as a component of the returned value.
- ...
arguments passed to
glm
Value
An object of type buhlmannStraubGLM with the following slots:
- call
the matched call
- CredibilityResults
results of the Buhlmann-Straub 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.
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
Ohlsson, E. (2008). Combining generalized linear models and credibility models in practice. Scandinavian Actuarial Journal 2008(4), 301–314.
Examples
# \donttest{
data("hachemeister", package = "actuar")
# Prepare data
X = as.data.frame(hachemeister)
Df = reshape(X, idvar = "state",
varying = list(paste0("ratio.", 1:12), paste0("weight.", 1:12)),
direction = "long")
# Add a covariate
Df$time_factor = factor(Df$time)
# Fit model
fit = buhlmannStraubGLM(ratio.1 ~ time_factor + (1 | state), Df,
weights = weight.1, p = 1.5)
summary(fit)
#> Call:
#> buhlmannStraubGLM(formula = ratio.1 ~ time_factor + (1 | state),
#> data = Df, weights = weight.1, p = 1.5)
#>
#> Buhlmann-Straub GLM credibility model
#>
#> Convergence: YES
#> Number of iterations: 1
#>
#> GLM Summary:
#>
#> Call:
#> glm(formula = FormulaGLM, family = tweedie(var.power = p, link.power = 0),
#> data = data, weights = data$wijt, model = TRUE, y = TRUE)
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 7.28881 0.03296 221.171 < 2e-16 ***
#> time_factor2 -0.03024 0.04527 -0.668 0.50734
#> time_factor3 0.03562 0.04558 0.782 0.43827
#> time_factor4 0.14086 0.04520 3.117 0.00309 **
#> time_factor5 0.10941 0.04628 2.364 0.02216 *
#> time_factor6 0.20572 0.04524 4.547 3.70e-05 ***
#> time_factor7 0.11839 0.04425 2.675 0.01018 *
#> time_factor8 0.12531 0.04600 2.724 0.00896 **
#> time_factor9 0.14831 0.04678 3.171 0.00265 **
#> time_factor10 0.22036 0.04535 4.859 1.30e-05 ***
#> time_factor11 0.22157 0.04520 4.902 1.13e-05 ***
#> time_factor12 0.27532 0.04380 6.285 9.18e-08 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> (Dispersion parameter for Tweedie family taken to be 609.1103)
#>
#> Null deviance: 90265 on 59 degrees of freedom
#> Residual deviance: 29027 on 48 degrees of freedom
#> AIC: NA
#>
#> Number of Fisher Scoring iterations: 3
#>
#>
#> Variance parameters from Buhlmann-Straub model:
#> Sigma (within-group variance): 29131863
#> Tau (between-group variance): 69999.22
#>
#> Random effects at the state level:
#>
#> Key: <state>
#> state zj Uj
#> <num> <num> <num>
#> 1: 1 0.9961348 1.2293438
#> 2: 2 0.9808662 0.9044844
#> 3: 3 0.9724230 1.0816545
#> 4: 4 0.9142906 0.8278582
#> 5: 5 0.9893672 0.9566591
ranef(fit)
#> $MLFj
#> Key: <state>
#> state Uj
#> <num> <num>
#> 1: 1 1.2293438
#> 2: 2 0.9044844
#> 3: 3 1.0816545
#> 4: 4 0.8278582
#> 5: 5 0.9566591
#>
# }