apc.indiv.compare.direct {apc}R Documentation

Implements direct tests between APC models

Description

This function allows the user to directly compare any of the APC model, its submodels, or the TS model to any smaller model. For example, the function can be used to compare the TS to the Ad model or the Ad model to the A model.

Usage

	apc.indiv.compare.direct(data, big.model, small.model, unit=1,
                                     dep.var, covariates=NULL, model.family,
                                     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,
                                     NR.controls=NULL)
        apc.indiv.ftest.fullapc(data,  big.model="APC", 
                                    small.model, dep.var, covariates=NULL,
                                    model.family="gaussian", 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,
                                    existing.big.model.fit=NULL, 
                                    existing.small.model.fit=NULL,
                                    existing.collinear=NULL)
        apc.indiv.ftest.TS(data,  small.model="APC",
                               dep.var, covariates=NULL,
                               model.family="gaussian", 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,
                               existing.small.model.fit=NULL, 
                               existing.big.model.fit=NULL, 
                               existing.collinear=NULL)
        apc.indiv.LRtest.fullapc(data,  big.model="APC", 
                                     small.model,
                                     dep.var, covariates=NULL, 
                                     model.family="binomial", 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,
                                     existing.big.model.fit=NULL,
                                     existing.small.model.fit=NULL,
                                     existing.collinear=NULL)
       apc.indiv.LRtest.TS(data, small.model="APC", dep.var, covariates=NULL,
                                model.family="binomial", 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,
                                existing.small.model.fit=NULL, 
                                existing.big.model.fit=NULL, 
                                existing.collinear=NULL,
                                maxit.loop.TS=10, maxit.linesearch.TS=30, 
                                init.TS="ols")                                      

Arguments

data

The data.frame in use.

big.model

The name of the larger of the two models to be tested.

small.model

The name of the smaller of the two models to be tested.

unit

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

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.

model.family

Either "gaussian" or "binomial"

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.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.

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.

NR.controls

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

existing.big.model.fit

Optional specify the output of apc.indiv.fit.model, if already run for the big model.

existing.small.model.fit

Optional specify the output of apc.indiv.fit.model, if already run for the small model.

existing.collinear

Optional specify the output of apc.indiv.design.collinear, if already run.

maxit.loop.TS

Optional, if binomial TS model used. Maximum number Newton-Rhapson iterations. Default 10.

maxit.linesearch.TS

Optional, if binomial TS model used. Maximum number linesearch iterations. Default 20.

init.TS

Optional, if binomial TS model used. Starting values for Newton-Rhapson. One of "zero", "ols", "custom". Default "ols".

Details

These functions are designed to facilitate direct comparison between sub-models. The functions are used to construct the rows of tables in apc.indiv.model.table but can also more helpfully be used to compare nested sub-models that gain similar levels of suport from such a table, e.g. PC to P.

Value

fstat

Gaussian models only. Value of the F-statistic.

LR

Binomial models only. Value of the likelihood-ratio statistic.

df

Degrees of freedom.

df.num

Gaussian models only. Degrees of freedom used in the numerator of the F-statistic.

df.denom

Gaussian models only. Degrees of freedom used in the denominator of the F-statistic.

p.value

P-value from testing against a chi-square or F distribution.

aic.big

AIC of the big model.

aic.small

AIC of the small model.

lik.big

Log-likelihood of the big model.

lik.small

Log-likelihood of the small model.

NR.report

Binomial TS model only. Report on the Newton-Rhapson algorithm.

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 triangular
AC_tri_sub <- data.NHIS.sample[data.NHIS.sample$age>=44 & data.NHIS.sample$age<=53 & 
                        data.NHIS.sample$cohort>=1961 & data.NHIS.sample$cohort<=1974, ]

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

## Run model comparisons
# Compare the APC model to the Ad model, gaussian, no covariates
comp1 <- apc.indiv.compare.direct(PC_sub, big.model = "APC", 
                                  small.model = "Ad",
                                  model.family = "gaussian", dep.var = "Lbmi")
comp1$fstat
comp1$p.value

# Compare the TS model to the PC model, binomial, with covariates
comp2 <- apc.indiv.compare.direct(AC_tri_sub, big.model = "TS", 
                                  small.model = "PC",
                                  model.family = "binomial", dep.var="obese",
                                  covariates = c("daysbed"), NR.controls=NULL)
comp2$LR
comp2$p.value


[Package apc version 1.3.3 Index]