plot.Mort2Dsmooth: Plot of the Mort2Dsmooth outcomes

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/plot.Mort2Dsmooth.R

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

1
2
3
4
5
6
7
8
## S3 method for class 'Mort2Dsmooth'
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.

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).

Value

None. Function produces a plot.

Author(s)

Carlo G Camarda

See Also

Mort2Dsmooth for computing Mort2Dsmooth.object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## 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")

MortalitySmooth documentation built on May 29, 2017, 7:11 p.m.