Description Usage Arguments Note Author(s) References See Also Examples
Functions to plot the apc estimates found by apc.fit.model
. The function apc.plot.fit detects the type of
model.design
and model.family
from the fit values and makes appropriate plots.
Depending on the model.design
the plot has up to 9 sub plots.
The type of these can be chosen using type
Model designs of any type.
If type
is "detrend" or "sum.sum"
the canonical age period cohort parametrisation is used. This involves double differences of the
time effects.
The first row of plots are double differences of the time effects.
The next two rows of plots illustrate the representation theorem depending on the choice of type
.
In both cases the sum of the plots add up to the predictor.
The last row of plots are double sums of double differences detrend so that that each series starts in zero and ends in zero. The corresponding level and (up to) two linear trends are shown in the middle row of plots. The linear trends are identified to be 0 for age, period or cohort equal to its smallest value. See note 2 below.
The last row of plots are double sums of double differences anchored as in the derivation of Nielsen (2014b). The corresponding level and (up to) two linear trends are shown in the middle row of plots. The linear trends are identified to be 0 for the anchoring point U of age, period or cohort as described in Nielsen (2014b). See note 1 below.
Model designs with 2 factors.
If type
is "dif" the canonical two factor parametrisation is used.
This involves single differences.
It is only implemented for model.design
of "AC", "AP", "PC".
It does not apply for model.design
of "APC" because single differences are not identified.
It does not apply for the drift models where model.design
is "Ad", "Pd", "Cd", "t" because it is not clear which time scale the second linear trend should be attributed to.
It is not implemented for model.design
of "tA, "tP", "tC", "1".
The first row of plots are single differences of the time effects.
The next two rows of plots illustrate the representation theorem. In the second row the level is given and in
the third row plots of single sums of single differences are given, normalised to start in zero.
Appearance may vary. Note, the plots "detrend" and "dif" can give very different appearance of the time effects. The "dif" plots are dominated by linear trends. They can therefore be more difficult to interpret than the "detrend" plots, where linear trends are set aside.
Standard deviations.
All plots include plots of 1 and 2 standard deviations. The only exception is the intercept in the case
model.family
is "poisson.response" as this uses a multinomial sampling scheme, where the intercept is set to increase
in the asymptotic experiment. The default is to plot standard deviations around zero, so that they represent
a test for zero values of the parameters.
Using the argument sdv.at.zero
the standard deviations can be centered around the estimates. This can give a
very complicated appearance.
Values of coefficients.
These can be found using
apc.identify
.
1 2 3 4 5 6 7 8 9 10 | apc.plot.fit(apc.fit.model,scale=FALSE,
sdv.at.zero=TRUE,type="detrend",
include.linear.plane=TRUE,
include.double.differences=TRUE,
sub.plot=NULL,main.outer=NULL,main.sub=NULL,
cex=NULL,cex.axis=NULL,cex.lab=NULL,cex.main=NULL,
cex.main.outer=1.2,
line.main=0.5,line.main.outer=NULL,
las=NULL,mar=NULL,oma=NULL,mgp=c(2,1,0),
vec.xlab=NULL)
|
apc.fit.model |
List. See |
scale |
Optional. Logical. If (TRUE) FALSE use scale of (inverse) link function. Default is FALSE. |
sdv.at.zero |
Optional. Logical. If FALSE/TRUE standard deviations are plotted around estimates/zero. Default is TRUE. |
type |
Optional. Character. If "detrend" double sums start and end in zero. If "sum.sum" double sums anchored as discussed in Nielsen (??). Default is "detrend". |
include.linear.plane |
Optional. Logical. If true include plots of linear plane. Default TRUE |
include.double.differences |
Optional. Logical. If true include plots of double differences. Default TRUE |
sub.plot |
Optional. Character: "a","b",...,"i". Only the indicated sub plot is plotted. Default is NULL so all plots shown. |
main.outer |
Optional. Character. Main title in outer margin. Default is generated internally. |
main.sub |
Optional. Vector of 9 characters. Main titles for individual plots. Default is generated internally, see note 3 below. |
cex |
Optional. Plot parameter, see |
cex.axis |
Optional. Plot parameter, see |
cex.lab |
Optional. Plot parameter, see |
cex.main |
Optional. Plot parameter, see |
cex.main.outer |
Optional. Controls magnification of outer main title if an array of plots is shown. Default is 1.2 (same as cex.main). |
line.main |
Optional. Specifies the line position of main title in individual plots. Default is 0.5. |
line.main.outer |
Optional. Specifies the line position of outer main title if an array of plots is shown. Default is NULL so that R default is used. |
las |
Optional. Plot parameter, see |
mar |
Optional. Gives the number of lines of margin to be specified on the four sides of the plot. Default: |
oma |
Optional. Gives the size of the outer margins in lines of text. Default: |
mgp |
Optional. Plot parameter, see |
vec.xlab |
Optional. Controls title for xaxis. Should be a 9-vector of characters for an array of plots and a character for a single plot. As R recycles entries if a vector is too short, then |
(1)
The type "sum.sum" (same as "ss.dd") gives double sums anchored
to be zero in the three points where
age=cohort=U
,
age=U+1,cohort=U
age=U,cohort=U+1
with
apc.fit.model$U
and where
U
is the integer value of
(per.zero+3)/2
This corresponds to the representation in
Nielsen (2014b).
The linear plane is parametrised in terms of
a level, which is the value of the predictor at
age=cohort=U
;
an age slope, which is the difference of the values of the predictor at
age=U+1,cohort=U
and
age=cohort=U
;
an cohort slope, which is the difference of the values of the predictor at
age=U,cohort=U+1
and
age=cohort=U
.
(2)
The type "detrend" gives double sums that start in zero and end in zero.
The linear plane is parametrised in terms of
a level, which is the value of the predictor at
age=cohort=1
, which is usually outside the index set for the data;
while age and cohort slopes are adjusted for the ad hoc identification of the time effects.
(3)
The default of the titles main.sub
are generated internally depending on model specification.
In the case of model.design="APC"
and a dose-response model family the default value is
c(expression(paste("(a) ",Delta^2,alpha)),
expression(paste("(b) ",Delta^2,beta)),
expression(paste("(c) ",Delta^2,gamma)),
"(d) first linear trend",
"(e) level",
"(f) second linear trend",
expression(paste("(g) detrended ",Sigma^2,Delta^2,alpha)),
expression(paste("(h) detrended ",Sigma^2,Delta^2,beta)),
expression(paste("(i) detrended ",Sigma^2,Delta^2,gamma)))
(4)
Default values of parameters changed (28 Sep 2020).
The old appearance can be reproduced by setting cex.lab=1.5
. For example:
data.list <- data.Italian.bladder.cancer()
fit.apc <- apc.fit.model(data.list,"poisson.dose.response","APC")
apc.plot.fit(fit.apc,cex.lab=1.5)
The code subsumes var.apc.plot.fit
by Zoe Fannon.
Bent Nielsen <bent.nielsen@nuffield.ox.ac.uk> & Zoe Fannon 28 September 2020 (12 Apr 2015).
Kuang, D., Nielsen, B. and Nielsen, J.P. (2008a) Identification of the age-period-cohort model and the extended chain ladder model. Biometrika 95, 979-986. Download: Article; Earlier version Nuffield DP.
Nielsen, B. (2014b) Deviance analysis of age-period-cohort models. Work in progress.
data.asbestos
and
data.Italian.bladder.cancer
for information on the data used in the example.
Values of coefficients can be found using apc.identify
.
Further information on the identification in the vignette
Identification.pdf
,
Identification.R
on
Vignettes
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #####################
# Example with Italian bladder cancer data
# Note that the model.design "AC" cannot be rejected against "APC"
# so there is little difference between the two plots of those fits.
data.list <- data.Italian.bladder.cancer()
apc.fit.table(data.list,"poisson.dose.response")
fit.apc <- apc.fit.model(data.list,"poisson.dose.response","APC")
apc.plot.fit(fit.apc)
# now try an AC model
# can use dev.new() to see both
fit.ac <- apc.fit.model(data.list,"poisson.dose.response","AC")
apc.plot.fit(fit.ac)
# to check the numerical values for the last two rows of plots use
apc.identify(fit.ac)$coefficients.detrend
# to get only a sub plot and playing with titles
# main.outer not used with individual plot
apc.plot.fit(fit.ac,sub.plot="a",main.outer="My outer title",main.sub="My sub title")
# to play with
# titles (main.outer/main.sub),
# label orientation (las),
# axis titles (vec.xlab)
apc.plot.fit(fit.ac,main.outer="My outer title",
main.sub=c("1","2","3","4","5","6","7","8","9"),
las=1,
vec.xlab=c("a","b","c","d","e","f","g","h","i"))
|
deviance df.residual prob(>chi_sq) LR vs.APC df vs.APC prob(>chi_sq)
APC 33.179 27 0.191 NaN NaN NaN
AP 512.514 40 0.000 479.335 13 0.000
AC 39.390 30 0.117 6.211 3 0.102
PC 1146.649 36 0.000 1113.470 9 0.000
Ad 518.543 43 0.000 485.364 16 0.000
Pd 4041.373 49 0.000 4008.194 22 0.000
Cd 1155.629 39 0.000 1122.450 12 0.000
A 2223.800 44 0.000 2190.621 17 0.000
P 84323.944 50 0.000 84290.765 23 0.000
C 23794.205 40 0.000 23761.026 13 0.000
t 4052.906 52 0.000 4019.727 25 0.000
tA 5825.158 53 0.000 5791.979 26 0.000
tP 84325.758 53 0.000 84292.579 26 0.000
tC 33446.796 53 0.000 33413.617 26 0.000
1 87313.678 54 0.000 87280.499 27 0.000
aic
APC 487.624
AP 940.958
AC 487.835
PC 1583.094
Ad 940.988
Pd 4451.818
Cd 1586.074
A 2644.245
P 84732.389
C 24222.650
t 4457.351
tA 6227.602
tP 84728.203
tC 33849.241
1 87714.123
WARNING apc.plot.fit: sdv large for plot 2 - possibly not plotted
WARNING apc.plot.fit: sdv large for plot 5 - possibly not plotted
WARNING apc.plot.fit: sdv large for plot 5 - possibly not plotted
Estimate Std. Error z value Pr(>|z|)
level -4.70247847 0.31978917 -14.70493345 5.992981e-49
age slope 0.85210695 0.03179021 26.80406823 2.897000e-158
cohort slope 0.18444392 0.03077224 5.99384102 2.049417e-09
SS_DD_age_25 0.00000000 NA NA NA
SS_DD_age_30 0.67158204 0.30082590 2.23246085 2.558452e-02
SS_DD_age_35 0.79084255 0.26027974 3.03843305 2.378119e-03
SS_DD_age_40 1.04935626 0.22402548 4.68409340 2.812018e-06
SS_DD_age_45 1.25654804 0.19160687 6.55794894 5.455288e-11
SS_DD_age_50 1.36044788 0.15981882 8.51243849 1.703131e-17
SS_DD_age_55 1.29243409 0.12807110 10.09153604 6.021972e-24
SS_DD_age_60 1.09065586 0.09649667 11.30252276 1.275017e-29
SS_DD_age_65 0.80285386 0.06531766 12.29152769 1.005869e-34
SS_DD_age_70 0.41585142 0.03543576 11.73536214 8.396616e-32
SS_DD_age_75 0.00000000 NA NA NA
SS_DD_cohort_1880 0.00000000 NA NA NA
SS_DD_cohort_1885 -0.10523303 0.05068901 -2.07605206 3.788914e-02
SS_DD_cohort_1890 -0.04907379 0.07066893 -0.69441817 4.874200e-01
SS_DD_cohort_1895 0.05280602 0.09711641 0.54373947 5.866208e-01
SS_DD_cohort_1900 0.08419619 0.12568257 0.66991149 5.029142e-01
SS_DD_cohort_1905 0.01193088 0.15550939 0.07672128 9.388453e-01
SS_DD_cohort_1910 -0.11403319 0.18550262 -0.61472552 5.387360e-01
SS_DD_cohort_1915 -0.30414206 0.21588525 -1.40881352 1.588903e-01
SS_DD_cohort_1920 -0.42940299 0.24654344 -1.74169304 8.156217e-02
SS_DD_cohort_1925 -0.47864679 0.27698435 -1.72806438 8.397668e-02
SS_DD_cohort_1930 -0.66091441 0.30738612 -2.15011141 3.154640e-02
SS_DD_cohort_1935 -0.71546596 0.33944771 -2.10773539 3.505388e-02
SS_DD_cohort_1940 -1.28295447 0.38819433 -3.30492842 9.500066e-04
SS_DD_cohort_1945 -1.44071392 0.46341495 -3.10890687 1.877809e-03
SS_DD_cohort_1950 0.00000000 NA NA NA
WARNING apc.plot.fit: sdv large for plot 5 - possibly not plotted
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.