apc.indiv.model.table {apc}R Documentation

Generate table to select APC submodel

Description

These functions test, for a given choice of dependent variable and covariates, which of the TS, APC, and APC submodels provides the best fit to the data. Comparison is by likelihood ratio and by Akaike Information Criterion. A table is generated with these statistics for each model considered.

Usage

apc.indiv.model.table(data, dep.var, covariates = NULL,
			unit = 1, n.coh.excl.start = 0, n.coh.excl.end = 0,
			n.age.excl.start = 0, n.age.excl.end = 0,
			n.per.excl.start = 0, n.per.excl.end = 0,
			model.family = NULL, NR.controls = NULL)
	   apc.indiv.ftable(data, dep.var, covariates = NULL,
	    	unit = 1, n.coh.excl.start = 0, n.coh.excl.end = 0,
			n.age.excl.start = 0, n.age.excl.end = 0,
			n.per.excl.start = 0, n.per.excl.end = 0)
	   apc.indiv.LRtable.TS(data, dep.var, covariates = NULL,
	   		unit = 1, n.coh.excl.start = 0, n.coh.excl.end = 0,
			n.age.excl.start = 0, n.age.excl.end = 0,
			n.per.excl.start = 0, n.per.excl.end = 0,
			maxit.loop.TS = 10, maxit.linesearch.TS = 30,
			init.TS = "ols")

Arguments

data

The data.frame in use

dep.var

The name of the dependent variable as it appears in the data

covariates

A vector of the names of covariates as they appear in the data. Default NULL.

unit

The interval at which age, period, and cohort are recorded (must be the same for each). Default 1.

n.coh.excl.start

If any cohorts have been censored (AP data only). Default 0.

n.coh.excl.end

If any cohorts have been censored (AP data only). Default 0.

n.age.excl.start

If any ages have been censored (PC data only). Default 0.

n.age.excl.end

If any ages have been censored (PC data only). Default 0.

n.per.excl.start

If any periods have been censored (AC data only). Default 0.

n.per.excl.end

If any periods have been censored (AC data only). Default 0.

model.family

Either "gaussian" or "binomial"

NR.controls

Optional list to modify aspects of the Newton-Rhapson iteration for binomial TS model.

maxit.loop.TS

Optional. Maximum number Newton-Rhapson iterations. Default 10.

maxit.linesearch.TS

Optional. Maximum number linesearch iterations. Default 20.

init.TS

Optional. Starting values for Newton-Rhapson. One of "zero", "ols", "custom". Default "ols".

Details

Each row of the table corresponds to a single sub-model of the APC model. The first three columns test the sub-model in question against the time-saturated model. The next three columns test the sub-model against the full APC model. The final two columns report the likelihood and AIC of the estimated sub-model. The model with the lowest AIC value which is also not rejected in tests against the APC and TS models should be selected.

Value

table

contains the table of comparison statistics.

NR.report

for logit models only, a report on the Newton-Rhapson algorithm used to estimate the time-saturated model.

Author(s)

Zoe Fannon <zoe.fannon@economics.ox.ac.uk> 13 Jul 2018

References

Fannon, Z. (2018) apc.indiv: R tools to estimate age-period-cohort models with repeated cross section data. Mimeo. University of Oxford.

Fannon, Z., Monden, C. and Nielsen, B. (2018) Age-period-cohort modelling and covariates, with an application to obesity in England 2001-2014. Mimeo. University of Oxford.

See Also

The example below uses data from the NHIS, see data.NHIS.sample

Examples

data("data.NHIS.sample")

## Get appropriate data formats
# Age-cohort
AC_sub <- data.NHIS.sample[data.NHIS.sample$age>=40 & data.NHIS.sample$age<=47 &
					data.NHIS.sample$cohort>=1961 &
                    data.NHIS.sample$cohort<=1967,]

# Period-cohort
PC_sub <- data.NHIS.sample[data.NHIS.sample$cohort>=1961 & data.NHIS.sample$cohort<=1968 &
                    data.NHIS.sample$period>=2008,]

# Age-period
AP_sub <- data.NHIS.sample[data.NHIS.sample$age<=48 & data.NHIS.sample$age>=40 &
                    data.NHIS.sample$period<=2010 & data.NHIS.sample$period>=2003,]

# Age-period with early and late cohorts dropped
AP_cc_sub <- AP_sub[!AP_sub$cohort %in% c(1955, 1956, 1957,
                                          1970, 1969, 1968),]

## Get tables
# Gaussian model, three covariates, period-cohort data
table1 <- apc.indiv.model.table(PC_sub, dep.var = "Lbmi", 
                                covariates = c("daysbed", "nowsmoke",
                                               "eversmoke"),
                                model.family = "gaussian")

# t model selected
# see examples in apc.indiv.est.model for fit of this model

# Binomial model, one covariate, age-cohort data
table2 <- apc.indiv.model.table(AC_sub, dep.var="obese",
                                covariates = c("daysbed"),
                                model.family = "binomial")
# intercept model selected; converged after ten iterations

# The same model (binomial, one covariate, age-cohort data) but with
# user-specified controls of Newton-Rhapson procedure
myspec1 <- list(8)
names(myspec1) <- c("maxit.loop")

table3 <- apc.indiv.model.table(AC_sub, dep.var="obese",
                                model.family = "binomial",
                                covariates = c("daysbed"),
                                NR.controls = myspec1)
# failed to converge

# Gaussian model, age-period cohort-cut data, no covariates
table4 <- apc.indiv.model.table(AP_cc_sub, dep.var = "Lbmi",
                                model.family = "gaussian",
                                n.coh.excl.start = 3,
                                n.coh.excl.end = 3)
# intercept model selected

[Package apc version 1.3.4 Index]