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

Estimate a single APC model

Description

The function apc.indiv.est.model is used to estimate any of: the APC model, any APC submodel, or the time-saturated model. To estimate the APC model or a submodel, it calls apc.indiv.design.collinear, apc.indiv.design.model, and apc.indiv.fit.model in that order. To estimate the time-saturated (TS) model it calls either apc.indiv.estimate.TS or apc.indiv.logit.TS, depending on the selected model.family. These functions can also be called directly by the user.

Usage

  apc.indiv.est.model(data, unit = 1,
                      n.coh.excl.start=0, n.coh.excl.end=0,
                      n.per.excl.start=0, n.per.excl.end=0,
                      n.age.excl.start=0, n.age.excl.end=0,  
                      model.design = "APC", dep.var = NULL, 
                      covariates = NULL, model.family = "gaussian",
                      NR.controls = NULL, 
                      existing.collinear = NULL,
                      existing.design = NULL,
					  plmmodel = "notplm", id.var = NULL,
                      wt.var = NULL)					  
  apc.indiv.design.collinear(data, unit = 1,
                             n.coh.excl.start = 0, n.coh.excl.end = 0,
                             n.per.excl.start = 0, n.per.excl.end = 0,
                             n.age.excl.start = 0, n.age.excl.end = 0)
  apc.indiv.design.model(apc.indiv.design.collinear,
                         model.design = "APC", dep.var = NULL, 
                         covariates = NULL, plmmodel = "notplm",
                         wt.var = NULL, id.var = NULL)
  apc.indiv.fit.model(apc.indiv.design.model, model.family = "gaussian", DV = NULL)
  apc.indiv.estimate.TS(data, dep.var, covariates = NULL)
  apc.indiv.logit.TS(data, dep.var, covariates = NULL, NR.controls = NULL)

Arguments

data

The data.frame in use

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

model.design

The name of the model to be estimated. One of "TS", "APC", "AC", etc.

dep.var

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

DV

apc.indiv.fit.model only. Optional. Vector containing dependent variable.

covariates

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

plmmodel

Used to indicate whether a panel data model is to be estimated and if so what type. Default is "notplm", for not panel data. Other values are "pooling", "within", "random". Further details in plm.

id.var

Only if using panel data. The name of the individual ID variable.

wt.var

Only if using survey weights. The name of the weights variable.

model.family

Either "gaussian" or "binomial". Default "gaussian".

NR.controls

Optional list to modify aspects of the Newton-Rhapson iteration for binomial TS model. Further information in "Details", below.

existing.collinear

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

existing.design

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

apc.indiv.design.collinear

Output from the command apc.indiv.design.collinear.

apc.indiv.design.model

Output from the command apc.indiv.design.model.

Details

The casual user should start with the general function apc.indiv.est.model for analysis. The underlying functions should be employed if the user needs to run many models using the same relatively large dataset, in which case time can be saved by running apc.indiv.design.collinear just once and using apc.indiv.design.model and apc.indiv.fit.model to estimate each of the models.

The time-saturated (TS) binomial model is estimated by a customized Newton-Rhapson iteration. Aspects of this iteration can be controlled by specifying the NR.controls option of apc.indiv.est.model or of apc.indiv.logit.TS. NR.controls is a named list of length 8. In order, the elements are: maxit.loop, maxit.linesearch, tolerance, init, inv.tol, d1.tol, custom.kappa, custom.zeta. maxit.loop sets the maximum number of Newton-Rhapson iterations, and has a default of 10. maxit.linesearch sets the maximum number of linesearch iterations within each Newton-Rhapson iteration, and has a default of 20. tolerance sets the condition for convergence, i.e. the tolerated difference between likelihoods from one Newton-Rhapson iteration to the next; the default is .002. init sets the starting values for the iteration. The default is "ols", meaning that estimates from the linear probability model are the starting values; one can also use "zero" to set the starting values to zero, or use "custom" and specify custom starting values using custom.kappa and custom.zeta. inv.tolsets the tolerance of small values when inverting a matrix (using solve), and the default is the machine precision. d1.tol sets the magnitude of norm of first derivative to be tolerated in Newton-Rhapson iteration, and has a default of .002. custom.kappa is used to specify custom starting values for the TS indicator parameters, while custom.zeta is used to specify custom starting values for parameters on any covariates.

Value

fit

The output of either glm, svyglm, or plm for repeated cross-section, repeated cross-section with survey weights, or panel models respectively. Can be used directly with follow-on functions like waldtest

.

coefficients.canonical

Matrix of estimates, standard error, t-statistic, and p-value of canonical parameter.

coefficients.covariates

Matrix of estimates, standard error, t-statistic, and p-value of covariates.

coefficients.TS

TS model only: matrix of estimates, standard error, t-statistic, and p-value of TS indicators.

aic

TS model only: Akaike Information Criterion.

likelihood

model likelihood.

model.design

which APC submodel has been estimated.

fixef

When plmmodel = "within", estimated individual fixed effects. Otherwise NULL.

full.design.collinear

from apc.indiv.design.collinear only. The collinear design matrix.

full.design

from apc.indiv.design.model only. The design matrix used to estimate the model.

DV

from apc.indiv.design.model only, if dep.var specified. A vector of the outcome variable.

ID

from apc.indiv.design.model only, if panel model. A vector of the individual ID variable.

PER

from apc.indiv.design.model only, if panel model. A vector of the period variable.

WT

from apc.indiv.design.model only, if wt.var specified. A vector of the survey weight variable.

model.formula

from apc.indiv.design.model only, the implied model formula. NULL if dep.var not specified.

model.string

from apc.indiv.design.model only, the implied model formula as a character string. RHS only if dep.var not specified.

Author(s)

Zoe Fannon <zoe.fannon@economics.ox.ac.uk> 26 Jun 2020

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

For model estimation: glm, svyglm, plm For model testing: apc.indiv.model.table, codeapc.indiv.compare.direct, waldtest, linearHypothesis For plotting: apc.plot.fit. The data in these examples are the Wage data from the package ISLR and the PSID7682 data from the package AER.

For examples, see the vignette IntroductionIndividualData.pdf, IntroductionIndividualData.R on Vignettes. Further examples in the vignette IntroductionIndividualDataFurtherExamples.pdf, IntroductionIndividualDataFurtherExamples.R.

Examples

#### see vignettes

[Package apc version 2.0.0 Index]