Skip to content
Snippets Groups Projects
Commit d28e3ae0 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Add table for Austrian "VU Gesamtbestand 2010-16"

parent d09afbd5
Branches
Tags
No related merge requests found
#' @import MortalityTables
NULL
stopifnot(require(methods), require(utils), require(MortalityTables), require(tidyverse), require(reshape2))
############################################################################### #
# Bestandssterbetafel der Versucherungsunternehmen Österreichs, 2012-6 ----
############################################################################### #
VUBestandstafel.Detail.load = function() {
basedata = utils::read.csv(
system.file("extdata", "VU_Gesamtbestand_Austria_Detail_2012-16.csv", package = "MortalityTables"),
# skip = 7,
encoding = "UTF-8",
header = TRUE
)
basedata.array = basedata %>% as_tibble %>%
gather(Variable, Value, smooth, raw, Exposure) %>%
acast(tariff ~ sex ~ premium ~ probability ~ age ~ Variable, value.var = "Value")
VU.Gesamtbestand.Detail = array(
data = c(mortalityTable.NA),
dim = c(dim(basedata.array)[1:4], 2),
dimnames = c(`names<-`(dimnames(basedata.array)[1:4], c("Tarif", "Geschlecht", "Prämie", "Wahrscheinlichkeit")), list(Typ = c("raw", "smooth"))))
dmn = dimnames(basedata.array)[1:4]
q = "qx"
ages = 0:99
ages.ch = as.character(ages)
for (t in dmn[[1]]) {
for (s in dmn[[2]]) {
for (p in dmn[[3]]) {
VU.Gesamtbestand.Detail[[t, s, p, q, "smooth"]] = mortalityTable.period(
name = sprintf("VU Gesamtbestand AT, %s, %s, %s, %s, geglättet", t, s, p, q),
ages = ages,
deathProbs = basedata.array[t, s, p, q, ages.ch, "smooth"],
exposures = basedata.array[t, s, p, q, ages.ch, "Exposure"],
data = list(
raw = basedata.array[t, s, p, q, ages.ch, "raw"],
dim = list(
sex = s,
year = "(all)",
data = "smooth",
tarif = t,
table = "VU Gesamtbestand AT",
zahlart = p,
probability = q
))
)
VU.Gesamtbestand.Detail[[t, s, p, q, "raw"]] = mortalityTable.period(
name = sprintf("VU Gesamtbestand AT, %s, %s, %s, %s, roh", t, s, p, q),
ages = ages,
deathProbs = basedata.array[t, s, p, q, ages.ch, "raw"],
exposures = basedata.array[t, s, p, q, ages.ch, "Exposure"],
data = list(dim = list(
sex = s,
year = "(all)",
data = "raw",
tarif = t,
table = "VU Gesamtbestand AT",
zahlart = p,
probability = q
))
)
}
}
}
q = "sx"
ages = 0:40
ages.ch = as.character(ages)
for (t in dmn[[1]]) {
for (s in dmn[[2]]) {
for (p in dmn[[3]]) {
VU.Gesamtbestand.Detail[[t, s, p, q, "raw"]] = mortalityTable.period(
name = sprintf("VU Gesamtbestand AT, %s, %s, %s, %s, roh", t, s, p, q),
ages = ages,
deathProbs = basedata.array[t, s, p, q, ages.ch, "raw"],
exposures = basedata.array[t, s, p, q, ages.ch, "Exposure"],
data = list(dim = list(
sex = s,
year = "(all)",
data = "raw",
tarif = t,
table = "VU Gesamtbestand AT",
zahlart = p,
probability = q
))
)
}
}
}
VU.Gesamtbestand.Detail
# plotMortalityTables(VU.Gesamtbestand.Detail[,,,"sx","raw"], legend.position = "bottom", log = FALSE)
# makeQxDataFrame(VU.Gesamtbestand.Detail[,,,"sx",])
# unlist(VU.Gesamtbestand.Detail[,,,"sx",])
}
VUBestandstafel.qx.load = function() {
basedata = utils::read.csv(
system.file("extdata", "VU_Gesamtbestand_Austria_qx_2012-16.csv", package = "MortalityTables"),
# skip = 7,
encoding = "UTF-8",
header = TRUE
)
sex = c("m", "f", "u")
VU.Gesamtbestand = array(
data = c(mortalityTable.NA),
dim = c(3),
dimnames = list(sex = sex)
)
for (s in sex) {
data = filter(basedata, sex == s)
data = data[order(data$age),]
VU.Gesamtbestand[[s]] = mortalityTable.period(
name = paste0("VU-Gesamtbestand 2012-2016, ", recode(s, "m" = "Männer", "f" = "Frauen", "u" = "Unisex")),
ages = data$age,
deathProbs = data$smooth,
baseYear = 2014,
exposures = data$exposure,
data = list(
raw = data$raw,
dim = list(
sex = s,
year = "2014",
data = "smooth",
tarif = "(all)",
table = "VU Gesamtbestand AT",
probability = "qx",
population = "Lebensversicherte",
country = "AT",
period = "2012-2016"
)
)
)
}
VU.Gesamtbestand
}
VUBestandstafel.Storno.load = function() {
basedata = utils::read.csv(
system.file("extdata", "VU_Gesamtbestand_Austria_Storno_2012-16.csv", package = "MortalityTables"),
# skip = 7,
encoding = "UTF-8",
header = TRUE
)
tarif = c("KLV", "FLV", "Sonstige")
VU.Gesamtbestand = array(
data = c(mortalityTable.NA),
dim = c(3),
dimnames = list(tarif = tarif)
)
for (t in tarif) {
data = filter(basedata, tarif == t)
data = data[order(data$age),]
VU.Gesamtbestand[[t]] = mortalityTable.period(
name = paste0("VU-Gesamtbestand 2012-2016, Storno ", t),
ages = data$age,
deathProbs = data$sx,
baseYear = 2014,
exposures = data$exposure,
data = list(
dim = list(
sex = "u",
year = "2014",
data = "raw",
tarif = t,
table = "VU Gesamtbestand AT",
probability = "sx",
population = "Lebensversicherte",
country = "AT",
period = "2012-2016"
)
)
)
}
VU.Gesamtbestand
}
VU.Gesamtbestand.Detail = VUBestandstafel.Detail.load()
VU.Gesamtbestand = VUBestandstafel.qx.load()
VU.Gesamtbestand.Storno = VUBestandstafel.Storno.load()
# plotMortalityTables(VU.Gesamtbestand)
# plotMortalityTables(VU.Gesamtbestand.Storno, log = FALSE, aes = aes(color = tarif))
rm(VUBestandstafel.Detail.load, VUBestandstafel.qx.load, VUBestandstafel.Storno.load)
# plotMortalityTables(VU.Gesamtbestand["(all)", c("m", "w"),"(all)","qx",])
# mortalityTables.list()
# mortalityTables.load("Austria_VU*")
This diff is collapsed.
age,tarif,sx,exposure
0,KLV,0.04213794156864926,860567.4782703598
1,KLV,0.03562589427683626,1633022.4653469818
2,KLV,0.0386150991325653,1532939.1258317025
3,KLV,0.040258752379958546,1377240.3755833209
4,KLV,0.039057612095521874,1279686.016950173
5,KLV,0.03983932383046146,1151146.5268628632
6,KLV,0.037750524601344176,1078546.4816649104
7,KLV,0.03469098339593814,1101312.3164233027
8,KLV,0.0317384576083378,1140208.423641427
9,KLV,0.02718678361938331,1290389.9008956796
10,KLV,0.03670261942299522,1203169.3385066988
11,KLV,0.0321355612776966,1066982.141186211
12,KLV,0.029368254957393224,974873.152980581
13,KLV,0.027235711670523275,925947.2484118621
14,KLV,0.025448688302101858,836608.9153846154
15,KLV,0.02642056679521243,770030.5502483818
16,KLV,0.02341990913020455,731936.6929549902
17,KLV,0.022243651545579064,688411.1853906368
18,KLV,0.020986060233737325,629603.0041698028
19,KLV,0.018678354549291967,570687.8742661448
20,KLV,0.02229415847578881,431793.9694415174
21,KLV,0.021558124141272957,304042.12777359626
22,KLV,0.020242895896833146,266456.35375583323
23,KLV,0.01978285806851182,232326.59156254705
24,KLV,0.01741373223728856,219620.28922926387
25,KLV,0.01742421275153274,172665.40532139095
26,KLV,0.016963081281884864,136835.08761101912
27,KLV,0.01677291744834455,123087.6738822821
28,KLV,0.014690881207545869,109530.05596116213
29,KLV,0.013446866784968248,84429.71390937829
30,KLV,0.013707187511194983,67237.70753424658
31,KLV,0.015017424151754616,55184.57872948969
32,KLV,0.01483214865217775,50123.91513623363
33,KLV,0.013433123793019424,47249.48021978022
34,KLV,0.013540284866219061,44305.62871443625
35,KLV,0.011960853531196485,43547.582538009934
36,KLV,0.013232080017445786,39413.801783832605
37,KLV,0.014515230795853864,36179.97735209996
38,KLV,0.015276472949123246,32090.30728586482
39,KLV,0.01355024215496327,29246.46822971549
40,KLV,0.012250965816028,25554.758505193437
0,FLV,0.08017403369475101,187267.6012118019
1,FLV,0.052803364701464725,416039.25362787896
2,FLV,0.03926734472056581,514758.33385518595
3,FLV,0.03301693392816922,609988.1853755834
4,FLV,0.030531546100838976,782651.5130362788
5,FLV,0.02979718301885883,928826.8644061418
6,FLV,0.02724847334437072,1016729.844437754
7,FLV,0.023657496762365962,1148129.2152792413
8,FLV,0.022517255349356502,1150803.3942796928
9,FLV,0.018684619437556733,1140883.4014902906
10,FLV,0.08280492132056363,910416.7371217824
11,FLV,0.1785929914251372,609812.8437076622
12,FLV,0.06682390834785105,409134.14902152645
13,FLV,0.06137488914960158,282289.59523558634
14,FLV,0.06298171713397005,133462.39545386122
15,FLV,0.06408671993189993,94927.73992924883
16,FLV,0.05736005203304013,54018.61761252446
17,FLV,0.05456489541658015,22943.093361433086
18,FLV,0.04673247421282927,11138.845190426013
19,FLV,0.04265613843213067,4542.770382357368
20,FLV,0.03972059964748595,1283.1443850669878
21,FLV,0.0473782814398189,556.3813713683577
22,FLV,0.03978599133428408,295.613698630137
23,FLV,0.014371967415896244,69.079896131266
24,FLV,0.02314374484813899,85.41643835616438
25,FLV,0.037905970454256095,103.52427367153395
26,FLV,0.016852728262124236,117.67514677103718
27,FLV,0.017290828124079848,114.66825982236941
28,FLV,0.03470785195922964,113.24769682372423
29,FLV,0.030201625286621063,97.83240252897787
30,FLV,0.012344635156844508,80.5068493150685
31,FLV,0.044894078561371065,65.32395754930002
32,FLV,0,61.83561643835616
33,FLV,0,54.586301369863016
34,FLV,0,57.503198855938585
35,FLV,0.04411453176372462,44.33653469817853
36,FLV,0.023621420072979984,41.83445732349842
37,FLV,0,40.5846981785338
38,FLV,0.024741707449700924,39.917582417582416
39,FLV,0.03260991487697894,30.165520096342014
40,FLV,0.03076923076923077,32
0,Sonstige,0.05189391075121827,522258.80688694865
1,Sonstige,0.07120389034927593,786307.1638115309
2,Sonstige,0.06188479216442006,657711.7908324553
3,Sonstige,0.05817048541505204,570326.2921044709
4,Sonstige,0.05397086771264782,521709.1499247328
5,Sonstige,0.05022019362782866,473136.20067740476
6,Sonstige,0.04515252783982625,432423.55380852026
7,Sonstige,0.03863468839010493,415527.4895303327
8,Sonstige,0.033731516651192534,395713.4135782026
9,Sonstige,0.032006929110149775,384351.92091675446
10,Sonstige,0.040742936738098263,308414.0756962216
11,Sonstige,0.033830988737493045,242756.36824476894
12,Sonstige,0.026072460189592254,213045.95180641278
13,Sonstige,0.02344106809850147,191828.78319283455
14,Sonstige,0.021275677114086178,165268.2122836068
15,Sonstige,0.022777827829666673,122351.20365798585
16,Sonstige,0.020801073524176646,85681.56981032666
17,Sonstige,0.021185251468625398,66224.35701490291
18,Sonstige,0.02121478726070577,49248.60096342014
19,Sonstige,0.02228496123747775,37850.43442721662
20,Sonstige,0.02813997425432633,26487.696221586633
21,Sonstige,0.03246942732539466,17421.466475989764
22,Sonstige,0.028111827049626222,15221.341991570074
23,Sonstige,0.023401874717937948,13767.507872948969
24,Sonstige,0.01814933623724959,14523.183373475838
25,Sonstige,0.018120185393409646,10992.101738672287
26,Sonstige,0.019398564796325,7708.581017612524
27,Sonstige,0.02663129030686178,7780.460958904109
28,Sonstige,0.01370916145432365,7244.39217221135
29,Sonstige,0.01079136578161579,5530.000579557429
30,Sonstige,0.010003266750905246,3282.4223242510916
31,Sonstige,0.009106857900629347,2841.9912915851273
32,Sonstige,0.0064616355562940285,3085.1915851272015
33,Sonstige,0.005942299015287793,3355.700707511666
34,Sonstige,0.002520967610592369,3565.557767574891
35,Sonstige,0.007029338905098659,3544.0222188770135
36,Sonstige,0.007981147269380017,3244.6770133975615
37,Sonstige,0.004199126048594654,2851.73750564504
38,Sonstige,0.005287364173644545,2263.5618470570525
39,Sonstige,0.002703638602352946,1477.4876787595965
40,Sonstige,0.0022975156136729744,869.50550955893425
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment