apc.fit( data,
A,
P,
D,
Y,
ref.c,
ref.p,
dist = c("poisson","binomial"),
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 )
A
(age),
P
(period), D
(cases, deaths) and Y
(person-years). Cohort (date of birth) is computed as P-A
.
If thsi argument is given the argdist
argument.parm="AdCP"
or parm="AdPC"
,
the resdiual cohort effects will be 1 at ref.c
Y
is assuemd to be the
denominator; "binomial"
gives a binomial model with logit
link.ns
fits a model with natural splines for each of
the terms, withnpar
parameters for the terms.bs
fits a model with B-splines for each of
the terms, withn
"weighted"
(default) lets the
weighted average (by marginal no. cases, D
) of the estimated
period and cohort effects have 0 salpha
) confidence limits.apc.lines
and
apc.plot
) --- a list with components:A.pt
with the ages (equals
unique(A)
) and three columns giving the estimated rates with
c.i.s.P.pt
with the dates of
diagnosis (equals unique(P)
) and three columns giving the
estimated RRs with c.i.s.C.pt
with the dates of birth
(equals unique(P-A)
) and three columns giving the estimated
RRs with c.i.s.drift
), the
second row is the estimate from the Age-drift model. For the
sequential parametrizations, only the latter is given.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.apc.frame
,
apc.lines
,
apc.plot
.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" )
Run the code above in your browser using DataLab