Description Usage Arguments Details Value Author(s) References See Also Examples
Fits the classical five models to tabulated rate data (cases, personyears) classified by two of age, period, cohort: Age, Agedrift, AgePeriod, AgeCohort and AgePeriodCohort. There are no assumptions about the age, period or cohort classes being of the same length, or that tabulation should be only by two of the variables. Only requires that mean age and period for each tabulation unit is given.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 
data 
Data frame with (at least) variables, 
A 
Age; numerical vector with mean age at diagnosis for each unit. 
P 
Period; numerical vector with mean date of diagnosis for each unit. 
D 
Cases, deaths; numerical vector. 
Y 
Personyears; numerical vector. Also used as denominator for binomial
data, see the 
ref.c 
Reference cohort, numerical. Defaults to median date of
birth among cases. If used with 
ref.p 
Reference period, numerical. Defaults to median date of diagnosis among cases. 
dist 
Distribution (or more precisely: Likelihood) used for modeling.
if a binomial model us used, 
model 
Type of model fitted:

dr.extr 
Character or numeric. How the drift parameter should be extracted from the ageperiodcohort model. Specifies the inner product used for definition of orthogonality of the period / cohort effects to the linear effects — in terms of a diagonal matrix.
If given as a numeric vector this is used as the diagonal of the matrix inducing the inner product. The setting of this parameter has no effect on the fit of the model, only on the parametrization. 
parm 
Character. Indicates the parametrization of the effects.
The first four refer to the MLfit of the AgePeriodCohort model,
the last four give Ageeffects from a smaller model and residuals
relative to this. If one of the latter is chosen, the argument

npar 
The number of parameters/knots to use for each of the terms in
the model. If it is vector of length 3, the numbers are taken as the
no. of knots for Age, Period and Cohort, respectively. Unless it has
a names attribute with vales "A", "P" and "C" in which case these
will be used. The knots chosen are the quantiles

alpha 
The significance level. Estimates are given with
(1 
scale 
numeric(1), factor multiplied to the rate estimates before output. 
print.AOV 
Should the analysis of deviance table for the models be printed? 
Each record in the input data frame represents a subset of a Lexis
diagram. The subsets need not be of equal length on the age and
period axes, in fact there are no restrictions on the shape of
these; they could be Lexis triangels for example. The requirement is
that A
and P
are coded with the mean age and calendar
time of observation in the subset. This is essential since A
and P
are used as quantitative variables in the models.
This approach is different from to the vast majority of the uses of
APCmodels in the literature where a factor model is used for age,
period and cohort effects. The latter can be obtained by using
model="factor"
.
An object of class "apc" (recognized by apc.plot
and
apc.lines
) — a list with components:
Type 
Text describing the model and parametrization returned 
Model 
The model object(s) on which the parametrization is based. 
Age 
Matrix with 4 columns: 
Per 
Matrix with 4 columns: 
Coh 
Matrix with 4 columns: 
Drift 
A 3 column matrix with driftestimates and c.i.s: The
first row is the MLestimate of the drift (as defined by

Ref 
Numerical vector of length 2 with reference period and cohort. If ref.p or ref.c was not supplied the corresponding element is NA. 
AOV 
Analysis of deviance table comparing the five classical models. 
Type 
Character string explaining the model and the parametrization. 
Knots 
If 
Bendix Carstensen, http://BendixCarstensen.com
The considerations behind the parametrizations used in this function are given in detail in: B. Carstensen: AgePeriodCohort models for the Lexis diagram. Statistics in Medicine, 10; 26(15):301845, 2007.
Various links to course material etc. is available through http://BendixCarstensen.com/APC
apc.frame
,
apc.lines
,
apc.plot
,
LCa.fit
,
apc.LCa
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  library( Epi )
data(lungDK)
# Taylor a dataframe that meets the requirements
exd < lungDK[,c("Ax","Px","D","Y")]
names(exd)[1:2] < c("A","P")
# Two different ways of parametrizing the APCmodel, ML
ex.H < apc.fit( exd, npar=7, model="ns", dr.extr="Holford", parm="ACP", scale=10^5 )
ex.W < apc.fit( exd, npar=7, model="ns", dr.extr="weighted", parm="ACP", scale=10^5 )
# Sequential fit, first AC, then P given AC.
ex.S < apc.fit( exd, npar=7, model="ns", parm="ACP", scale=10^5 )
# Show the estimated drifts
ex.H[["Drift"]]
ex.W[["Drift"]]
ex.S[["Drift"]]
# Plot the effects
fp < apc.plot( ex.H )
apc.lines( ex.W, frame.par=fp, col="red" )
apc.lines( ex.S, frame.par=fp, col="blue" )

Attaching package: 'Epi'
The following object is masked from 'package:base':
merge.data.frame
NOTE: npar is specified as:A P C
7 7 7
[1] "ML of APCmodel Poisson with log(Y) offset : ( ACP ):\n"
Analysis of deviance for AgePeriodCohort model
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
Age 213 15479.4
Agedrift 212 6867.7 1 8611.7 < 2.2e16 ***
AgeCohort 207 1042.5 5 5825.1 < 2.2e16 ***
AgePeriodCohort 202 435.1 5 607.4 < 2.2e16 ***
AgePeriod 207 3092.4 5 2657.3 < 2.2e16 ***
Agedrift 212 6867.7 5 3775.2 < 2.2e16 ***

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
No reference period given:
Reference period for ageeffects is chosen as
the median date of birth for persons with event: 1911.333 .
NOTE: npar is specified as:A P C
7 7 7
[1] "ML of APCmodel Poisson with log(Y) offset : ( ACP ):\n"
Analysis of deviance for AgePeriodCohort model
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
Age 213 15479.4
Agedrift 212 6867.7 1 8611.7 < 2.2e16 ***
AgeCohort 207 1042.5 5 5825.1 < 2.2e16 ***
AgePeriodCohort 202 435.1 5 607.4 < 2.2e16 ***
AgePeriod 207 3092.4 5 2657.3 < 2.2e16 ***
Agedrift 212 6867.7 5 3775.2 < 2.2e16 ***

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
No reference period given:
Reference period for ageeffects is chosen as
the median date of birth for persons with event: 1911.333 .
NOTE: npar is specified as:A P C
7 7 7
[1] "Sequential modelling Poisson with log(Y) offset : ( ACP ):\n"
Analysis of deviance for AgePeriodCohort model
Resid. Df Resid. Dev Df Deviance Pr(>Chi)
Age 213 15479.4
Agedrift 212 6867.7 1 8611.7 < 2.2e16 ***
AgeCohort 207 1042.5 5 5825.1 < 2.2e16 ***
AgePeriodCohort 202 435.1 5 607.4 < 2.2e16 ***
AgePeriod 207 3092.4 5 2657.3 < 2.2e16 ***
Agedrift 212 6867.7 5 3775.2 < 2.2e16 ***

Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
exp(Est.) 2.5% 97.5%
APC (1weights) 1.032921 1.032080 1.033763
Ad 1.023489 1.022974 1.024005
exp(Est.) 2.5% 97.5%
APC (Dweights) 1.019656 1.019056 1.020256
Ad 1.023489 1.022974 1.024005
exp(Est.) 2.5% 97.5%
Ad 1.023489 1.022974 1.024005
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.