Learn R Programming

MortalitySmooth (version 1.0)

plot.Mort1Dsmooth: Plot of the Mort1Dsmooth outcomes

Description

It produces a plot where the x-axis is the predictor of the given Mort1Dsmooth object and the y-axis is either the actual and fitted log-rates, or the actual and fitted counts.

Usage

## S3 method for class 'Mort1Dsmooth'
## S3 method for class 'Mort1Dsmooth':
plot(x, type = c("logrates", "deaths"), ...)

Arguments

x
An object of class "Mort1Dsmooth", usually, a result of a call to Mort1Dsmooth.
type
The type of plot which should be returned. The alternatives are: logrates (default) and death.
...
Other plotting parameters passed to plot.

Value

  • None. Function produces a plot

Details

The function provides a simple tool for checking the outcomes of a Mort1Dsmooth object. In a Poisson setting, one would commonly look at rates in log-scale, but actual and fitted counts can be plotted too. Plotting parameters can be change to enhance the output. Only exceptions are the x values, y values, and the ylim of the main plot, and the arguments for the fitted lines.

See Also

Mort1Dsmooth for computing Mort1Dsmooth.object, plot, par.

Examples

Run this code
# selected data
years <- 1930:2006
death <- selectHMDdata("Denmark", "Deaths", "Females",
                       ages = 60, years = years)
exposure <- selectHMDdata("Denmark", "Exposures", "Females",
                          ages = 60, years = years)
# fit
fit <- Mort1Dsmooth(x=years, y=death, offset=log(exposure),
                    method=3, lambda=100)
# plotting actual and fitted data
par(mfrow=c(1,2))
plot(fit, "deaths")
plot(fit, "logrates")
par(mfrow=c(1,1))

Run the code above in your browser using DataLab