Description Usage Arguments Details Value Author(s) References See Also Examples
Returns an object of class Mort1Dsmooth
which is a Psplines
smooth of the input data of degree and order fixed by the
user. Specifically tailored to mortality data.
1 2 3 4 5 6 
x 
a vector with the values of the predictor variable. These must be at least

y 
a vector with a set of counts response variable values. 
offset 
this can be used to specify an a priori known component
to be included in the linear predictor during fitting. This should be

w 
an optional vector of weights to be used in the fitting
process. This should be 
overdispersion 
logical on the accounting for overdisperion in
the smoothing parameter selection criterion. See 
ndx 
number of internal knots 1. Default: 
deg 
degree of the Bsplines. Default: 3. 
pord 
order of differences. Default: 2. 
lambda 
smoothing parameter (optional). 
df 
a number which specifies the degrees of freedom (optional). 
method 
the method for controlling the amount of
smoothing. 
coefstart 
an optional vector of starting coefficients. 
control 
a list of control parameters. See 
The method fits a Pspline model with equallyspaced Bsplines along
x
. The response variables must be Poisson distributed counts,
though overdisperion can be accounted. Offset can be provided,
otherwise the default is that all weights are one.
The function is specifically tailored to smooth mortality data in
onedimensional setting. In such case the argument x
would be
either the ages or the years under study. Death counts will be the
argument y
. In a Poisson regression setting applied to actual
death counts the offset
will be the logarithm of the exposure
population. See example below.
The function can obviously account for zero counts and definite
offset. In a mortality context, the user can apply the function to
data with zero deaths, but it has to take care that no exposures are equal
to zero, i.e. offset equal to minus infinitive. In this last case, the
argument w
can help. The user would need to set weights equal
to zero when exposures are equal to zero leading to interpolation of
the data. See example below.
Regardless the presence of exposures equal to zero, the argument
w
can also be used for extrapolation and interpolation of the
data. Nevertheless see the function
predict.Mort1Dsmooth
for a more comprehensive way to
forecast mortality rates.
The method produces results similar to function smooth.spline
,
but the smoothing function is a Bspline smooth with discrete
penalization directly on the differences of the Bsplines
coefficients. The user can set the order of difference, the degree of
the Bsplines and number of them. Nevertheless, the smoothing
parameter lambda
is mainly used to tune the smoothness/model
fidelity of the fitted values.
The range in which lambda is searched is given in control

RANGE
. Though it can be modified, the default values are
suitable for most of the application.
There are print.Mort1Dsmooth
,
summary.Mort1Dsmooth
, plot.Mort1Dsmooth
,
predict.Mort1Dsmooth
and
residuals.Mort1Dsmooth
methods available for this
function.
Four methods for optimizing the smoothing parameter are available. The BIC
is set as default. Minimization of the AIC is also possible. BIC will
give always smoother outcomes with respect to AIC, especially for
large sample size. Alternatively the user can directly provide the
smoothing parameter (method=3
) or the degree of freedom to be
used in the model (method=4
). Note that Mort1Dsmooth
uses approximated degree of freedom, therefore method=4
will
produce fitted values with degree of freedom only similar to the one
provided in df
. The tolerance level can be set via
control
 TOL2
.
Note that the 'ultimate' smoothing with very large lambda will
approach to a polynomial of degree pord
.
Starting coeffients for the Bspline basis can be provided by the user. This feature can be useful when a gridsearch is manually performed by the user.
The argument overdispersion
can be set to TRUE
when possible presence of
over(under)dispersion needs to be considered in the selection of the
smoothing parameter. Mortality data often present overdispersion
also known, in demography, as heterogeneity. Duplicates in insurance
data can lead to overdispersed data, too. Smoothing parameter
selection may be affected by this phenomenon. When
overdispersion=TRUE
, the function uses a penalized
quasilikelihood method for including an overdisperion parameter
(psi2
) in the fitting procedure. With this approach expected
values are assumed equal to the variance multiplied by the parameter
psi2
. See reference. Note that the inclusion of the
overdisperion parameter within the estimation might lead to select
higher lambda, leading to smoother outcomes. When
overdispersion=FALSE
(default value) or method=3
or
method=4
, psi2
is estimated after the smoothing
parameter have been employed. Overdispersion parameter considerably larger
(smaller) than 1 may be a sign of overdispersion (underdispersion).
The control
argument is a list that can supply any of the
following components:
MON
: Logical. If TRUE
tracing information on the
progress of the fitting is produced. Default: FALSE
.
TOL1
: The absolute convergence tolerance for each completed
scoring algorithm. Default: 1e06.
TOL2
: Difference between two adjacent smoothing parameters in
the (pseudo) grid search, logscale. Useful only when method
is
equal to 1, 2 or 4. Default: 0.5.
RANGE
: Range of smoothing parameters in which the gridsearch
is applied, commonly taken in logscale. Default: [10^4 ; 10^6].
MAX.IT
: The maximum number of iterations for each completed
scoring algorithm. Default: 50.
The arguments MON
, TOL1
and MAX.IT
are kept
during all the grid search when method
is equal to 1,
2 or 4. Function cleversearch
from package
svcm
is employed to speed the grid search. See
Mort1Dsmooth_optimize
for details.
An object of the class Mort1Dsmooth
with components:
coefficients 
vector of fitted (penalized) Bsplines coefficients. 
residuals 
the deviance residuals. 
fitted.values 
vector of fitted counts. 
linear.predictor 
vector of fitted linear predictor. 
logmortality 
fitted mortality rates in logscale. 
lev 
diagonal of the hatmatrix. 
df 
effective dimension. 
deviance 
Poisson Deviance. 
aic 
Akaike's Information Criterion. 
bic 
Bayesian Information Criterion. 
psi2 
overdispersion parameter. 
lambda 
the selected (given) smoothing parameter lambda. 
call 
the matched call. 
n 
number of observations. 
tolerance 
the used tolerance level. 
B 
the Bsplines basis. 
ndx 
the number of internal knots 1. 
deg 
degree of the Bsplines. 
pord 
order of difference. 
x 
values of the predictor variable. 
y 
set of counts response variable values. 
offset 
vector of the offset. 
w 
vector of weights used in the model. 
Carlo G Camarda
Eilers P. H. C. and B. D. Marx (1996). Flexible Smoothing with Bsplines and Penalties. Statistical Science. 11, 89121.
Camarda, C. G. (2012). MortalitySmooth: An R Package for Smoothing Poisson Counts with PSplines. Journal of Statistical Software. 50, 124. http://www.jstatsoft.org/v50/i01/.
predict.Mort1Dsmooth
,
plot.Mort1Dsmooth
, Mort1Dsmooth_optimize
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  ## selected data
years < 1950:2006
death < selectHMDdata("Japan", "Deaths", "Females",
ages = 80, years = years)
exposure < selectHMDdata("Japan", "Exposures", "Females",
ages = 80, years = years)
## various fits
## default using Bayesian Information Criterion
fitBIC < Mort1Dsmooth(x=years, y=death,
offset=log(exposure))
fitBIC
summary(fitBIC)
## subjective choice of the smoothing parameter lambda
fitLAM < Mort1Dsmooth(x=years, y=death,
offset=log(exposure),
method=3, lambda=10000)
## plot
plot(years, log(death/exposure),
main="Mortality rates, logscale.
Japanese females, age 80, 1950:2006")
lines(years, fitBIC$logmortality, col=2, lwd=2)
lines(years, fitLAM$logmortality, col=3, lwd=2)
legend("topright", c("Actual", "BIC", "lambda=10000"),
col=1:3, lwd=c(1,2,2), lty=c(1,1,1),
pch=c(1,1,1))
## see vignettes for examples on
##  ExtraPoisson variation
##  interpolation
##  extrapolation

Loading required package: svcm
Loading required package: Matrix
Loading required package: splines
Loading required package: lattice
Call:
Mort1Dsmooth(x = years, y = death, offset = log(exposure))
Number of Observations : 57
Effective dimension : 10.36
(Selected) smoothing parameter : 316.23
Bayesian Information Criterion (BIC): 617.25
Call:
Mort1Dsmooth(x = years, y = death, offset = log(exposure))
Number of Observations : 57
Effective dimension : 10.36
(Selected) smoothing parameter : 316.23
Bayesian Information Criterion (BIC) : 617.25
Akaike's Information Criterion (AIC) : 596.09
(Estimated) dispersion parameter (psi^2): 12.3
Residuals:
Min 1Q Median 3Q Max
7.0301 1.6907 0.3916 2.1113 7.4556
Settings and control:
number of Bsplines : 14
degree of the Bsplines: 3
order of differences : 2
convergence tolerance : 5.9079e08
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.