Adjust the intercept to regain the balance property
adjustIntercept.Rd
This function updates the intercept term of the model fit such that the balance property is satisfied.
Arguments
- obj
an object of type
glm
,speedglm
,cpglm
orcpglmm
containing the model fit.- data
a
data.frame
ordata.table
object that was used to fit the model.
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
Wüthrich, M. V. (2020). Bias regularization in neural network models for general insurance pricing. European actuarial journal 10(1), 179–202.
Examples
library(statmod)
datas = dataCar[1:1e3, ]
Fit = glm(Y ~ area + gender, data = datas, weights = datas$w, family = tweedie(1.75, 0),
model = TRUE, control = glm.control(epsilon = 1e-4, maxit = 5e2))
w = weights(Fit, "prior")
y = Fit$y
sum(w * y) == sum(w * fitted(Fit))
#> [1] FALSE
adjFit = adjustIntercept(Fit, datas)
coef(adjFit)
#> (Intercept) areaB areaC areaD areaE areaF
#> 5.5386226 -0.1882927 -0.1542479 -2.4340072 -1.6156363 0.8378340
#> genderM
#> 0.2379400
sum(w * y) == sum(w * fitted(adjFit))
#> [1] TRUE