| apc.fit {Epi} | R Documentation |
Fits the classical five models to tabulated rate data (cases, person-years) classified by age and period: Age, Age-drift, Age-Period, Age-Cohort and Age-period.
apc.fit( data,
A,
P,
D,
Y,
ref.c,
ref.p,
model = c("ns","bs","ls","factor"),
dr.extr = c("weighted","Holford"),
parm = c("ACP","APC","AdCP","AdPC","Ad-P-C","Ad-C-P","AC-P","AP-C"),
npar = c( A=5, P=5, C=5 ),
scale = 1,
alpha = 0.05,
print.AOV = TRUE )
data |
Data frame with (at least) variables, A (age),
P (period), D (cases, deaths) and Y
(person-years). Cohort (date of birth) is computed as P-A. |
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 |
Person-years; numerical vector. |
ref.c |
Reference cohort, numerical. Defaults to median date of
birth among cases. If used with parm="AdCP" or parm="AdPC",
the resdiual cohort effects will be 1 at ref.c |
ref.p |
reference period, numerical. Defaults to median date of diagnosis among cases. |
model |
type of model fitted:
|
dr.extr |
How the drift parameter should be extracted from the
age-period-cohort model. weighted (default) lets the
weighted average (by marginal no. cases, D) of the estimated
period and cohort effects have 0 slopw. Holford uses the
naïve average over all values for the estimated effects,
disregarding the no. cases. |
parm |
The parametrization of the effects. The first four all
refer to the ML-fit of the Age-Period-Cohort model, the last four
give Age-effects from a smaller model and residuals relative to
this. If one of the latter is chosen, drift is ignored.
Possible values are:
|
npar |
The number of parameters to use for each of the terms in the model. It can be a list of three numerical vectors, in which case these taken as the knots for the age, period and cohort effect, the first and last element in each vector are used as the boundary knots. |
alpha |
The significance level. Estimates are given with
(1-alpha) confidence limits. |
scale |
numeric(1), factor multiplied to the rate estimates before output. |
print.AOV |
Should the analysis of deviance table for the models be printed? |
An object of class "apc" (recognized by apc.lines) —
a list with components:
Age |
Matrix with 4 colums: A.pt with the ages (equals
unique(A)) and three columns giving the estimated rates with
c.i.s. |
Per |
Matrix with 4 colums: P.pt with the dates of
diagnosis (equals unique(P)) and three columns giving the
estimated RRs with c.i.s. |
Coh |
Matrix with 4 colums: C.pt with the dates of birth
(equals unique(P-A)) and three columns giving the estimated
RRs with c.i.s. |
Drift |
A 3 column matrix with drift-estimates and c.i.s: The first row is
the ML-estimate of the drift (as defined by drift), the
second row is the estimate from the Age-drift model. For the
sequential parametrizations, only the latter is given. |
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 model is one of "ns" or "bs", a list
with three components: Age, Per, Coh, each one a
vector of knots. The max and the min are the boundary knots. |
Powers |
If model is "fpol", a list
with three components: Age, Per, Coh, each one a
vector of the powers used in the fractional polynomials. |
Bendix Carstensen, http://www.pubhealth.ku.dk/~bxc
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 APC-model, 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="AC-P", 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" )