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

mT.fitExtrapolationLaw: Add raw argument to allow passing raw data to be used...

mT.fitExtrapolationLaw: Add raw argument to allow passing raw data to be used for fitting, or alternatively use the rawProbs slot of the table's data slot (filled by whittaker.mortalityTable)
parent da3ab938
No related branches found
No related tags found
No related merge requests found
...@@ -249,10 +249,9 @@ mT.extrapolateProbsExp = function(table, age, up = TRUE) { ...@@ -249,10 +249,9 @@ mT.extrapolateProbsExp = function(table, age, up = TRUE) {
#' @export #' @export
mT.fitExtrapolationLaw = function(table, method = "LF2", law = "HP", mT.fitExtrapolationLaw = function(table, method = "LF2", law = "HP",
fit = 75:99, extrapolate = 80:120, fit = 75:99, extrapolate = 80:120,
fadeIn = 80:90, fadeOut = NULL) { fadeIn = 80:90, fadeOut = NULL, raw = NULL) {
if (!is(table, "mortalityTable")) if (!is(table, "mortalityTable"))
stop("First argument must be a mortalityTable.") stop("First argument must be a mortalityTable.")
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
...@@ -267,10 +266,17 @@ mT.fitExtrapolationLaw = function(table, method = "LF2", law = "HP", ...@@ -267,10 +266,17 @@ mT.fitExtrapolationLaw = function(table, method = "LF2", law = "HP",
# Dx = table@deathProbs # Dx = table@deathProbs
# qx = table@deathProbs # qx = table@deathProbs
# } # }
if (!is.null(raw)) {
rawData = raw
} else if (!is.null(table@data$rawProbs)) {
rawData = table@data$rawProbs
} else {
rawData = 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),
qx = table@deathProbs, data.ages = ages, qx = rawData, 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