apcplot {APCG1}R Documentation

APC 2D and 3D Plot

Description

Plot 2D curves or 3D surface of APC data. 2D curves include age by period, period by age, cohort by age, cohort by period.

Usage

apcplot(r, header = F, scale = "log", P3D = F, apc = "age", amin = 1, pmin = 1, cmin = 1, gapage = 1, gapyear = 1, xleg = NA, yleg = NA, nleg = 1, pylim = NA, theta = -30, phi = 30, p3dcol = 3, ppch = F, plty = F, main = "3D plot")

Arguments

r

Data in a matrix of a by p dimension with a rows (age groups) and p columns (period groups)

header

logic value, if True, the matrix dimension labels pass to age and period labels in plots.

scale

Scale of data in plot, either the orginal ("id" or "lin") or the log ("log") scale of data. The default is "log".

P3D

logic value, if True, produce 3D plot of data with age and period as the axes.

apc

specify effect to plot. "age", "per", "coha" or "cohp" for age by period, period by age, cohort by age, or cohort by period plot, respectively.

amin, pmin, cmin

starting age, period, and cohort labels in plot, respectively, not required if header = T.

gapage, gapyear

number of units (years) in each age or period group.

xleg, yleg

x-, y-coordinates of legend.

nleg

number of columns of legend, default is 1.

pylim

range of effect in the plot. Useful when space is needed for legend, either above or below the curves.

theta, phi

angles defining the viewing direction. theta gives the azimuthal direction and phi the colatitude.

p3dcol

color of the 3D plot, 0 — no color, 1 — black, ...

ppch

plot character for 2D plot curves.

plty

plot line type for 2D plot curves.

main

title of plot.

Details

produce 3D surface plot (P3D = T), or 2D curve plot (P3D = F).

Author(s)

Wenjiang Fu

References

Fu, W. (2018) A Practical Guide to Age-Period-COhort Analysis: the Identification Problem and Beyond, CRC.

Examples

USlungCAmale.r = APCG_data(apcdata="lungCAmale",header=TRUE)$rate
apcplot(USlungCAmale.r,header=TRUE, p3d=FALSE, apc="per")
apcplot(USlungCAmale.r,header=TRUE, p3d=FALSE, apc="per", pylim=c(-4, 6))
apcplot(USlungCAmale.r,header=TRUE, p3d=FALSE, apc="per",pylim=c(-4, 6),xleg=1980,yleg=-2.5,nleg=5)
apcplot(USlungCAmale.r,header=TRUE, P3D=TRUE, scale="id", phi=30, theta=30,p3dcol = 3, main ="3D plot of my data")

[Package APCG1 version 1.0 Index]