plot.residuals.coda: Plot the residuals of a CoDa Mortality Model

Description Usage Arguments Details Source Examples

Description

Plot the deviance residuals of a CoDa Mortality Model which are of class "residuals.coda". Three types of plots are available: scatter plot of residuals by age, period and cohort, colour map (heatmap) of the residuals, and a black and white signplot of the residuals.

Usage

1
2
3
4
## S3 method for class 'residuals.coda'
plot(x, plotType = c("scatter", "colourmap",
  "signplot"), reslim = NULL, plotAge = TRUE, plotYear = TRUE,
  plotCohort = TRUE, pch = 20, col = NULL, ...)

Arguments

x

An object of class residuals.coda with the residuals of a CoDa Mortality Model.

plotType

The type of the plot. The alternatives are "scatter"(default), "colourmap", and "signplot".

reslim

Optional numeric vector of length 2, giving the range of the residuals.

plotAge

Logical value indicating if the age scatter plot should be produced. This is only used when plotType = "scatter".

plotYear

Logical value indicating if the calendar year scatter plot should be produced. This is only used when plotType = "scatter".

plotCohort

Logical value indicating if the cohort scatter plot should be produced. This is only used when plotType = "scatter".

pch

Optional symbol to use for the points in a scatterplot. This is only used when plotType = "scatter". See plot.

col

Optional colours to use in plotting. If plotType = "scatter" this is a single colour to use in the points in the scatter plots, while if plotType = "colourmap" this should be a list of colours (see help in image.plot for details). This argument is ignored if plotType = "signplot".

...

Other plotting parameters to be passed to the plotting functions. This can be used to control the appearance of the plots.

Details

When plotType = "scatter" scatter plots of the residuals against age, calendar year and cohort (year of birth) are produced.

When plotType = "colourmap" a two dimensional colour map of the residuals is plotted. This is produced using function image.plot. See image.plot for further parameters that can be passed to this type of plots.

When plotType = "signplot" a two dimensional black and white map of the residuals is plotted with dark grey representing negative residuals and light grey representing positive residuals. This is produced using function image.default.

Source

The code for producing the residual plots is inspired from the one published in StMoMo R package. See plot.resStMoMo. All the credit goes to it's authors: Andres Villegas, Pietro Millossovich and Vladimir Kaishev.

Examples

1
2
3
4
5
6
7
8
# Fit model
M <- coda(CoDa.data, x = 0:110, y = 1960:2014)

# Plot residuals
res <- resid(M)
plot(res, plotType = "scatter")
plot(res, plotType = "colourmap")
plot(res, plotType = "signplot")

mpascariu/CoDa documentation built on May 5, 2019, 7 p.m.