Learn R Programming

MortalitySmooth (version 2.3.4)

plot.Mort2Dsmooth: Plot of the Mort2Dsmooth outcomes

Description

It produces two level plots, side-by-side, where the x- and y-axis are the predictors (x and y) of the given Mort2Dsmooth object and the numeric response is either the matrices of actual and fitted log-rates, or the matrices of actual and fitted counts.

Usage

"plot"(x, type = c("logrates", "deaths"), palette = c("rainbow", "heat.colors", "terrain.colors", "topo.colors", "cm.colors"), ...)

Arguments

x
an object of class "Mort2Dsmooth", usually, a result of a call to Mort2Dsmooth.
type
the type of plot which should be returned. The alternatives are: logrates (default) and death.
palette
a string with the color palette for creating a vector of contiguous colors. Default: rainbow.
...
other plotting parameters passed to levelplot. Not in used.

Value

None. Function produces a plot.

Details

The function provides a simple tool for checking the outcomes of a Mort2Dsmooth object. In a Poisson setting, one would commonly look at rates in log-scale, but actual and fitted counts can be plotted too. The function uses levelplot from package lattice to construct the two level plots side-by-side. Plotting parameters are given and cannot be changed. The only expection is the color palette: five different palletes are available and described in the associated documentation: the default rainbow as well as heat.colors, terrain.colors, topo.colors, and cm.colors. A palette with 9 colors is chosen and the breaks for the level plot are chosen according to the deciles of distributions of actual and fitted log-rates (counts).

See Also

Mort2Dsmooth for computing Mort2Dsmooth.object.

Examples

Run this code
## selected data
ages <- 50:100
years <- 1970:2006
death <- selectHMDdata("Denmark", "Deaths", "Females",
                       ages = ages, years = years) 
exposure <- selectHMDdata("Denmark", "Exposures", "Females",
                          ages = ages, years = years)
## fit
fit <- Mort2Dsmooth(x=ages, y=years, Z=death,
                    offset=log(exposure),
                    method=3, lambdas=c(100,500)) 
## plotting log-death rates
plot(fit, palette="terrain.colors")
## plotting death counts
plot(fit, type="death")

Run the code above in your browser using DataLab