WH {WH} | R Documentation |
Whittaker-Henderson Smoothing
Description
Main package function to apply Whittaker-Henderson Smoothing in a survival
analysis framework. It takes as input two vectors / matrices of observed
events and associated central exposure and estimate a smooth version of the
log-hazard rate. Smoothing parameters may be supplied or automatically chosen
according to a specific criterion such as "REML"
(recommended), "AIC"
,
"BIC"
or "GCV"
. Whittaker-Henderson Smoothing may be applied in a full
maximum likelihood framework (strongly recommended) or an asymptotic
(approximate) Gaussian framework.
Usage
WH(d, ec, lambda = NULL, q = 2, criterion, reg, y, wt, verbose = 1, ...)
Arguments
d |
Vector / matrix of observed events whose elements should be named. |
ec |
Vector / matrix of central exposure. The central exposure corresponds to the sum of the exposure period over the insured population. An individual experiencing an event of interest during the year will no longer be exposed afterwards and the exposure should be reduced accordingly. |
lambda |
Smoothing parameter. If missing, an optimization procedure will be used to find the optimal smoothing parameter. |
q |
Order of penalization. Polynoms of degrees |
criterion |
Criterion to be used for the selection of the optimal
smoothing parameter. Default is |
reg |
Should an approximate regression framework be used ? framework. |
y |
Optional vector of observations whose elements should be named. Used
only in the regression framework and even in this case will be
automatically computed from the |
wt |
Optional vector / matrix of weights. As for the observation vector
/ matrix |
verbose |
Integer between 0 and 3. Control the level of informations that will be printed on screen during fitting. |
... |
Additional parameters passed to the smoothing function called. |
Value
An object of class WH_1d
i.e. a list containing, among other
things :
-
y
The observation vector/matrix, either supplied or computed as y = log(d) - log(ec) -
y_hat
The vector/matrix of fitted value -
std_y_hat
The vector/matrix of standard deviation associated with the fitted value -
res
The vector/matrix of model deviance residuals -
edf
The vector/matrix of effective degrees of freedom associated with each observation -
diagnosis
A data.frame with one row containing the effective degrees of freedom of the model, the deviance of the fit as well as the AIC, BIC, GCV and REML criteria
Examples
d <- portfolio_mort$d
ec <- portfolio_mort$ec
y <- log(d / ec)
y[d == 0 | ec == 0] <- NA
wt <- d
# Maximum likelihood
WH(d, ec) # automatic smoothing parameter selection via REML
WH(d, ec, lambda = 1e2) # fixed smoothing parameter
WH(d, ec, criterion = "GCV") # alternative criterion for smoothing parameter selection
# Regression
WH(y = y, wt = wt) # regression framework is default when y is supplied
WH(d, ec, reg = TRUE, lambda = 1e2) # forces computation of y from d and ec