pclm2D | R Documentation |
Fit two-dimensional penalized composite link model (PCLM-2D), e.g. simultaneous ungrouping of age-at-death distributions grouped in age classes for adjacent years. The PCLM can be extended to a two-dimensional regression problem. This is particularly suitable for mortality analysis when mortality surfaces are to be estimated to capture both age-specific trajectories of coarsely grouped distributions and time trends \insertCiterizzi2019ungroup.
pclm2D(
x,
y,
nlast,
offset = NULL,
out.step = 1,
ci.level = 95,
verbose = TRUE,
control = list()
)
x |
Vector containing the starting values of the input intervals/bins.
For example: if we have 3 bins |
y |
|
nlast |
Length of the last interval. In the example above |
offset |
Optional offset term to calculate smooth mortality rates. A vector of the same length as x and y. See \insertCiterizzi2015;textualungroup for further details. |
out.step |
Length of estimated intervals in output. Values between 0.1 and 1 are accepted. Default: 1. |
ci.level |
Level of significance for computing confidence intervals.
Default: |
verbose |
Logical value. Indicates whether a progress bar should be
shown or not. Default: |
control |
List with additional parameters:
|
The output is a list with the following components:
input |
A list with arguments provided in input. Saved for convenience. |
fitted |
The fitted values of the PCLM model. |
ci |
Confidence intervals around fitted values. |
goodness.of.fit |
A list containing goodness of fit measures: standard errors, AIC and BIC. |
smoothPar |
Estimated smoothing parameters: |
bins.definition |
Additional values to identify the bins limits and location in input and output objects. |
deep |
A list of objects created in the fitting process. Useful in diagnosis of possible issues. |
call |
An unevaluated function call, that is, an unevaluated expression which consists of the named function applied to the given arguments. |
control.pclm2D
plot.pclm2D
# Input data
Dx <- ungroup.data$Dx
Ex <- ungroup.data$Ex
# Aggregate data to be ungrouped in the examples below
# Select a 10y data frame
x <- c(0, 1, seq(5, 85, by = 5))
nlast <- 26
n <- c(diff(x), nlast)
group <- rep(x, n)
y <- aggregate(Dx, by = list(group), FUN = "sum")[, 2:10]
offset <- aggregate(Ex, by = list(group), FUN = "sum")[, 2:10]
# Example 1 ----------------------
# Fit model and ungroup data using PCLM-2D
P1 <- pclm2D(x, y, nlast)
summary(P1)
# Plot fitted values
plot(P1)
# Plot input data
plot(P1, "observed")
# NOTE: pclm2D does not search for optimal smoothing parameters by default
# (like pclm does) because it is more time consuming. If optimization is
# required set lambda = c(NA, NA):
P1 <- pclm2D(x, y, nlast, control = list(lambda = c(NA, NA)))
# Example 2 ----------------------
# Ungroup and build a mortality surface
P2 <- pclm2D(x, y, nlast, offset)
summary(P2)
plot(P2, type = "observed")
plot(P2, type = "fitted")
plot(P2, type = "fitted", colors = c("blue", "red"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.