Residuals of an ODP GLM by group
residual_summary.RdThe standardized deviance residuals of an odp_glm_fit grouped by
origin, development age or calendar period: a row per group with the
count of cells with a defined residual, their mean and their standard
deviation (divisor n - 1, NA below two cells). A trend in the means
over calendar periods points to a calendar effect the model lacks; a
spread that falls with age, to a variance that is not phi * mu
(Taylor and McGuire, CAS Monograph 3, Chapter 6).
Usage
residual_summary(fit, by = c("development", "origin", "calendar"))Arguments
- fit
An odp_glm_fit.
- by
"development","origin"or"calendar".
Examples
long <- data.frame(year = c(2020, 2020, 2020, 2021, 2021, 2022),
age = c(12, 24, 36, 12, 24, 12),
paid = c(100, 150, 165, 110, 170, 120))
fit <- odp_glm(triangle(long, "year", "age", "paid"))
fit@residuals
#> origin development calendar calendar_index actual fitted actual_to_fitted
#> 1 2020 12 2020 0 100 98.4375 1.0158730
#> 2 2020 24 2021 1 50 51.5625 0.9696970
#> 3 2020 36 2022 2 15 15.0000 1.0000000
#> 4 2021 12 2021 1 110 111.5625 0.9859944
#> 5 2021 24 2022 2 60 58.4375 1.0267380
#> 6 2022 12 2022 2 120 120.0000 1.0000000
#> pearson deviance leverage standardized_deviance
#> 1 1.574852e-01 1.570713e-01 0.8173828 0.9973718
#> 2 -2.175971e-01 -2.187102e-01 0.6513672 -1.0051154
#> 3 -1.834613e-15 -2.980232e-08 1.0000000 NA
#> 4 -1.479316e-01 -1.482789e-01 0.8388672 -1.0023480
#> 5 2.043969e-01 2.034960e-01 0.6923828 0.9955926
#> 6 2.594535e-15 0.000000e+00 1.0000000 NA
#> standardized_pearson
#> 1 1
#> 2 -1
#> 3 NA
#> 4 -1
#> 5 1
#> 6 NA
residual_summary(fit, "calendar")
#> label n mean sd
#> 1 2020 1 0.9973718 NA
#> 2 2021 2 -1.0037317 0.001956825
#> 3 2022 1 0.9955926 NA