Create smooth demogdata functions
Smooth demogdata data using one of four methods depending on the value of method
smooth.demogdata(data, method = switch(data$type, mortality = "mspline", fertility = "cspline", migration = "loess"), age.grid, power = switch(data$type, mortality = 0.4, fertility = 1, migration = 1), b = 65, k = 30, span = 0.2, lambda = 1e-10, interpolate = FALSE, weight = data$type != "migration", obs.var = "empirical")
data |
Demogdata object such as created using |
method |
Method of smoothing. Possibilities: |
age.grid |
Ages to use for smoothed curves. Default is single years over a slightly greater range than the unsmoothed data. |
power |
Power transformation for age variable before smoothing. Default is 0.4 for mortality data and 1 (no transformation) for fertility or migration data. |
b |
Lower age for monotonicity if |
k |
Number of knots to use for penalized regression spline estimate. Ignored if |
span |
Span for loess smooth if |
lambda |
Penalty for constrained regression spline if |
interpolate |
If |
weight |
If TRUE, uses weighted smoothing. |
obs.var |
Method for computing observational variance. Possible values: “empirical” or “theoretical”. |
The value of method
determines the type of smoothing used.
Weighted penalized regression splines with a monotonicity constraint. The curves are monotonically
increasing for age greater than b. Smoothness controlled by k
. Methodology based on Wood (1994). Code calls gam
for the basic
computations.
Weighted regression B-splines with a concavity constraint. Smoothness controlled by lambda
.
Methodology based on He and Ng (1999). Code calls cobs
for the basic computations.
Unconstrained weighted penalized regression splines. Equivalent to "mspline" but with b=Inf
.
Weighted locally quadratic regression. Smoothness controlled by span. Code calls
loess
for the basic computations.
Demogdata object identical to data
except all
rate matrices are replaced with smooth versions and pop matrices are replaced with disaggregated population estimates obtained
using monotonic spline interpolation applied to the cumulative population data.
Weight
matrices are also added to the object showing the inverse
variances of the estimated smooth curves.
Rob J Hyndman
france.sm <- smooth.demogdata(extract.years(fr.mort,1980:1997)) plot(france.sm) plot(fr.mort,years=1980,type="p",pch=1) lines(france.sm,years=1980,col=2)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.