Chapter 5 – Age-Period-Cohort Analysis: New Models, Methods, and Empirical Applications

Main   Chapter 5   Chapter 6   Chapter 7   Chapter 8   Chapter 9

Table 5.7 IE and CGLIM Estimates, U.S. Female Cancer Mortality, 1969 – 2007

Stata codes for the IE results:

#====step 1: data preparation
insheet using all_mortality_f.txt

#====step 2: run model
apc_ie death if age<=85 & age>=20,
       age(age) period(period) cohort(cohort) family(poisson) link(log)
       exposure(exp);
estimates store IE;

Stata codes for the CGLIM 3 results:

apc_glim death if age<=85 & age>=20,
       age(age) period(period) cohort(cohort)
       agepfx(“_A”) periodpfx(“_P”) cohortpfx(“_C”) family(poisson) link(log)
       exposure(exp) constraint(“C1=C2”);
estimates store CGLIM3;

R codes for the IE results:

#====step 1: data preparation
#Read data from the *.txt file. f.mx is a data frame that represents the overall female cancer mortality, including one column for the size of population exposure and another column for the corresponding number of deaths, all of which are ordered by pear year and then age groups

f.mx<-read.table(“all_mx_f.txt”, header=T)
n.p<-8                    # n.p indicates the number of periods
#The following step transforms data into a matrix form for both deaths and exposure. The matrix rows correspond to age groups, while the columns correspond to period years.
f.death<-matrix(f.mx$death,byrow=F,ncol=n.p)       
f.exposure<-matrix(f.mx$exp,byrow=F,ncol=n.p)

#====step 2: load source codes

Please email Dr. Wenjiang J. Fu for these files.

 

#====step 3: run model

R codes for the CGLIM 3 results:

#=====step 1: prepare contrast matrix con.c
n.p=8          #number of period groups
n.a=14        #number of age groups
n.c=21        #number of cohort groups

#matrix for CGLIM 3 (C1=C2)
con.t<-contr.treatment(n.c,base=1)
con.c<-con.t
con.c[2,1]<-0
con.a<-contr.treatment(n.a,base=1)
con.p<-contr.treatment(n.p,base=1)

#matrix for Centered CGLIM 3 (C1=C2)
con.t<-contr.sum(n.c)
con.c<-con.t
con.c[2,1]<-1
con.c[2,2]<-0
con.c[n.c,1]<--2
con.c[n.c,2]<-0

con.a<-contr.sum(n.a)
con.p<-contr.sum(n.p)

#==========step 2: create factor covariances for age, period and cohort
age.f.fa<-as.factor(f.mx$age)
cohort.f.fa<-as.factor(f.mx$cohort)
period.f.fa<-as.factor(f.mx$period)

#===========step 3: run generalized linear regression
fit.f.apc <- glm(f.mx$cases ~ age.f.fa+ period.f.fa+ cohort.f.fa+ offset(log(f.mx$exp)),family = quasi(link = log,var="mu"), control = glm.control(epsilon = 1e-010, maxit = 10), contrasts= list(age.f.fa=con.a,period.f.fa=con.p,cohort.f.fa=con.c),intercept = intercept)

summary.glm(fit.f.apc)

Computational Software for the Intrinsic Estimator

This section provides programs for estimating APC multiple classification models.

Stata module

An example is given below to replicate results published in Yang, Fu, and Land (2004).

Estimator Software
IE – Intrinsic Estimator for Generalized Linear Models ADO File and Help Document
CGLIM – Conventional Estimator with Equality Constraints ADO File and Help Document
Sample Data Sample Program and Output
apc_example_data.dta (zipped) apc_example.do and apc_example.pdf

Note: The best way to install the programs is by typing “ssc install apc” or “net install apc” in Stata. To download the example, type “net get apc” in Stata.