genWeightMat: Generate weight matrix

Description Usage Arguments Value See Also Examples

View source: R/exportUtils.R

Description

Generates a weight matrix given a group of ages and years and a set of cohorts which are to be given zero weight. This is useful for excluding some data points when fitting a Stochastic Mortality Model (see fit.StMoMo).

Usage

1
genWeightMat(ages, years, clip = 0, zeroCohorts = NULL)

Arguments

ages

vector of ages.

years

vector of years.

clip

number of cohorts in the boundary to assign a zero weight. This can be be used to zero weigh some of the first and last cohorts in the data.

zeroCohorts

other cohort for which a zero weight is to be assigned.

Value

A 0-1 matrix with 0 for the zero-weighed cohorts.

See Also

fit.StMoMo

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#Zero-weight the first three and last three cohorts
wxt1 <- genWeightMat(55:89,  EWMaleData$years, clip = 3)
APCfit1 <- fit(apc(), data = EWMaleData, ages.fit = 55:89, 
               wxt = wxt1)
plot(APCfit1, parametricbx = FALSE, nCol = 3)

#Also Zero-weight the 1886 cohort
wxt2 <- genWeightMat(55:89,  EWMaleData$years, clip = 3, 
                     zeroCohorts = 1886)
APCfit2 <- fit(apc(), data = EWMaleData, ages.fit = 55:89, 
               wxt = wxt2)
plot(APCfit2, parametricbx = FALSE, nCol = 3)

StMoMo documentation built on May 2, 2019, 11:42 a.m.