plotBAPC: Function to plot age-specific and/or agestandardized rates...

View source: R/plotBAPC.r

plotBAPCR Documentation

Function to plot age-specific and/or agestandardized rates and projections of a Bayesian age-period-cohort model

Description

Function to plot age-specific and/or agestandardized projections of a Bayesian age-period-cohort model generated using BAPC using a fanplot.

Usage

plotBAPC(APCList, scale = 10^5, type="ageSpecProj",
    probs = c(0.025, seq(0.05, 0.95, by=0.05), 0.975), start=NULL,
    showdata = TRUE, mfrow = NULL, col.fan =sequential_hcl,
    obs.pch=21, obs.col="white", obs.bg="black", obs.lwd=2, obs.cex=1, ln=NULL, ...)

Arguments

APCList

APCList object generated by the BAPC function.

scale

Scaling factor for the incidence/mortality rates.

type

String indicating what should be plotted: ageSpecRate — projected age-specific rates, ageSpecProj — projected age-specific counts, ageStdRate — projected age-standardized rates, ageStdProj — projected age-standardized counts or

probs

Probabilities related to percentiles or prediction intervals to be plotted. These values control the number of shades used in the 'fan'. These must be between 0 and 1. Percentiles greater than 0.5, if not given, are automatically calculated as 1-'p', to ensure symmetric fan. Values can be non-integers. See function fan().

start

If NULL results for all periods are plotted. Otherwise 'start' must be a string representing the year to start plotting. It must be an element of periodlabels(APCList).

showdata

Boolean indicating whether observed data points should be added to the plot. Default: TRUE.

mfrow

A vector of the form 'c(nr, nc)'. Subsequent figures will be drawn in an 'nr'-by-'nc' array on the device by _columns_ ('mfcol'), or _rows_ ('mfrow'), respectively.

col.fan

Palette of colours used in the 'fan'. See fucntion fan() of the package fanplot

obs.pch

Plotting character, i.e. symbol, to be used when showing observed values. See options pch in points.

obs.col

Color used when observed data are plotted.

obs.bg

Background (fill) color for the open plot symbols given by 'obs.pch = 21:25'.

obs.lwd

Line width for drawing observed symbols.

obs.cex

Character expansion when drawing observed symbols.

ln

Equivalent to option 'ln' of function fan.

...

Further arguments passed to par()

Value

A plot illustrating age-specific or age-standardized projections/fitted values.

Author(s)

Andrea Riebler

Examples

## Not run: 
if(requireNamespace("INLA", quietly = TRUE)) {
    require(INLA)
    data(FemLCSweden)
    data(FemPYSweden)
    data(whostandard)

    lc_sweden <- APCList(FemLCSweden, FemPYSweden, gf=5)

    result  <- BAPC(lc_sweden, predict=list(npredict=10, retro=TRUE),
        verbose=FALSE, stdweight=whostandard[6:17,2])

    plotBAPC(result, scale=10^5, type="ageSpecProj", showdata=TRUE)

    ## Assume the data for 2000 to 2010 are not observed
    ## (projection results are the same as above)
    FemLCSweden[51:60,] <- NA

    lc_sweden <- APCList(FemLCSweden, FemPYSweden, gf=5)

    result  <- BAPC(lc_sweden, predict=list(npredict=10, retro=FALSE),
        verbose=FALSE, stdweight=whostandard[6:17,2])

    plotBAPC(result, scale=10^5, type="ageSpecProj", showdata=TRUE)
}

## End(Not run)

BAPC documentation built on March 23, 2022, 3 p.m.

Related to plotBAPC in BAPC...