Commit df76d32c authored by Reinhold Kainhofer's avatar Reinhold Kainhofer

Style fixes

parent 6b355894
......@@ -20,13 +20,13 @@ setMethod("deathProbabilities", "mortalityTable.period",
#' @describeIn deathProbabilities Return the (cohort) death probabilities of the
#' life table given the birth year (if needed)
setMethod("deathProbabilities","mortalityTable.ageShift",
function (object, ..., YOB = 1975) {
qx=object@deathProbs * (1 + object@loading);
function(object, ..., YOB = 1975) {
qx = object@deathProbs * (1 + object@loading);
shift = ageShift(object, YOB);
if (shift>0) {
qx = c(qx[(shift+1):length(qx)], rep(qx[length(qx)], shift));
} else if (shift<0) {
qx = c(rep(0, -shift), qx[1:(length(qx)-(-shift))])
if (shift > 0) {
qx = c(qx[(shift + 1):length(qx)], rep(qx[length(qx)], shift));
} else if (shift < 0) {
qx = c(rep(0, -shift), qx[1:(length(qx) - (-shift))])
}
object@modification(qx)
})
......@@ -34,23 +34,23 @@ setMethod("deathProbabilities","mortalityTable.ageShift",
#' @describeIn deathProbabilities Return the (cohort) death probabilities of the
#' life table given the birth year (if needed)
setMethod("deathProbabilities","mortalityTable.trendProjection",
function (object, ..., YOB = 1975) {
qx=object@deathProbs * (1 + object@loading);
function(object, ..., YOB = 1975) {
qx = object@deathProbs * (1 + object@loading);
if (is.null(object@trend2) || length(object@trend2) <= 1) {
ages = object@ages;
damping = sapply(
ages,
function (age) { object@dampingFunction(YOB + age - object@baseYear) }
function(age) { object@dampingFunction(YOB + age - object@baseYear) }
);
finalqx = exp(-object@trend * damping) * qx;
} else {
# dampingFunction interpolates between the two trends:
# The damping functions does NOT give yearly weights,
# but rather cumulative weights from the base year until the observation year!
weights = sapply(YOB + 0:(length(qx)-1), object@dampingFunction);
weights = sapply(YOB + 0:(length(qx) - 1), object@dampingFunction);
finalqx = qx * exp(
-(object@trend * (1 - weights) + object@trend2 * weights) *
(YOB + 0:(length(qx)-1) - object@baseYear))
(YOB + 0:(length(qx) - 1) - object@baseYear))
}
object@modification(finalqx)
})
......@@ -58,7 +58,7 @@ setMethod("deathProbabilities","mortalityTable.trendProjection",
#' @describeIn deathProbabilities Return the (cohort) death probabilities of the
#' life table given the birth year (if needed)
setMethod("deathProbabilities","mortalityTable.improvementFactors",
function (object, ..., YOB = 1975) {
function(object, ..., YOB = 1975) {
qx = object@deathProbs * (1 + object@loading);
finalqx = (1 - object@improvement)^(YOB + 0:(length(qx) - 1) - object@baseYear) * qx;
object@modification(finalqx)
......@@ -67,7 +67,7 @@ setMethod("deathProbabilities","mortalityTable.improvementFactors",
#' @describeIn deathProbabilities Return the (cohort) death probabilities of the
#' life table given the birth year (if needed)
setMethod("deathProbabilities","mortalityTable.mixed",
function (object, ..., YOB = 1975) {
function(object, ..., YOB = 1975) {
qx1 = deathProbabilities(object@table1, ..., YOB);
qx2 = deathProbabilities(object@table2, ..., YOB);
mixedqx = (object@weight1 * qx1 + object@weight2 * qx2)/(object@weight1 + object@weight2) * (1 + object@loading);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment