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

Switch mT.fitExtrapolationLaw to use the qx rather than the Dx and Ex to fit

parent beeaa415
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
NULL NULL
fitExtrapolationLaw = function(data, ages, data.ages = ages, Dx = data * Ex, Ex, method = "LF2", law = "HP", fit = 75:99, extrapolate = 80:120, fadeIn = 80:90, fadeOut = NULL, verbose = FALSE) { fitExtrapolationLaw = function(data, ages, data.ages = ages, Dx = NULL, Ex = NULL, qx = NULL, method = "LF2", law = "HP", fit = 75:99, extrapolate = 80:120, fadeIn = 80:90, fadeOut = NULL, verbose = FALSE) {
# Add the extrapolate ages to the needed ages # Add the extrapolate ages to the needed ages
neededAges = union(ages, extrapolate) neededAges = union(ages, extrapolate)
# constrain the fit and fade-in range to given ages # constrain the fit and fade-in range to given ages
...@@ -14,7 +14,7 @@ fitExtrapolationLaw = function(data, ages, data.ages = ages, Dx = data * Ex, Ex, ...@@ -14,7 +14,7 @@ fitExtrapolationLaw = function(data, ages, data.ages = ages, Dx = data * Ex, Ex,
# Hohe Alter: Fitte Heligman-Pollard im Bereich 75-99 # Hohe Alter: Fitte Heligman-Pollard im Bereich 75-99
fitLaw = MortalityLaw( fitLaw = MortalityLaw(
x = data.ages, Dx = Dx, Ex = Ex, x = data.ages, Dx = Dx, Ex = Ex, qx = qx,
law = law, opt.method = method, law = law, opt.method = method,
fit.this.x = fit) fit.this.x = fit)
# summary(fitAP.m.75.99) # summary(fitAP.m.75.99)
...@@ -188,19 +188,21 @@ mT.fitExtrapolationLaw = function(table, method = "LF2", law = "HP", ...@@ -188,19 +188,21 @@ mT.fitExtrapolationLaw = function(table, method = "LF2", law = "HP",
ages = ages(table) ages = ages(table)
if (!is.null(table@exposures) && !is.na(table@exposures)) { if (!is.null(table@exposures) && !is.na(table@exposures)) {
Ex = table@exposures Ex = table@exposures
if (!is.null(table@data$deaths)) { qx = table@deathProbs
Dx = table@data$deaths # if (!is.null(table@data$deaths)) {
} else { # Dx = table@data$deaths
Dx = table@deathProbs * Ex # } else {
} # Dx = table@deathProbs * Ex
# }
} else { } else {
Ex = rep(1, length(ages)) Ex = rep(1, length(ages))
Dx = table@deathProbs # Dx = table@deathProbs
qx = table@deathProbs
} }
table = mT.fillAges(table, neededAges = union(ages, extrapolate), fill = 0) table = mT.fillAges(table, neededAges = union(ages, extrapolate), fill = 0)
fitted = fitExtrapolationLaw( fitted = fitExtrapolationLaw(
data = table@deathProbs, ages = ages(table), data = table@deathProbs, ages = ages(table),
Dx = Dx, Ex = Ex, data.ages = ages, qx = qx, Ex = Ex, data.ages = ages,
method = method, law = law, method = method, law = law,
fit = fit, extrapolate = extrapolate, fit = fit, extrapolate = extrapolate,
fadeIn = fadeIn, fadeOut = fadeOut, fadeIn = fadeIn, fadeOut = fadeOut,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment