Learn R Programming

apc (version 3.0.0)

apc.fit.model.2s: Fits an age period cohort model for 2 samples

Description

Generalizes apc.fit.model to a 2 sample model. For an application, see the vignette ReproducingN2025.pdf, ReproducingN2025.R on vignette.

Usage

apc.fit.model.2s(apc.data.list.1,apc.data.list.2,model.family,
            model.design.common="APC",model.design.difference="APC",
            gls.weight=c(1,1),apc.index=NULL,time.series=NULL)
apc.fit.table.2s(apc.data.list.1,apc.data.list.2,model.family,
            restrict="difference",model.design.reference.common="APC",
            model.design.reference.difference="APC",
            gls.weight=c(1,1),time.series=NULL,digits=3)

Arguments

apc.data.list.1

List. For 1st sample. See apc.data.list for a description of the format.

apc.data.list.2

List. For 2nd sample. See apc.data.list for a description of the format.

model.family

Character. The following options are implemented. These are used internally when calling glm.fit.

"log.normal.rates"

Gaussian regression for log(rates) and with identity link (Least Squares).

"gls.log.normal.rates"

Gaussian regression for log(rates) and with identity link (Generalized Least Squares). The option gls.weight must be used to give the relative weight of the two samples.

"log.normal.response"

Gaussian regression for log(response) and with identity link (Least Squares).

model.design.common

Optional. Indicates which sub-model should be fitted for the common part of the parameters, that is for the sum of the canonical parameters (xi.1+xi.2)/2. Possible choices: "APC","AP","AC","PC","Ad","Pd","Cd","A","P","C","t","tA","tP","tC" and "ATC". Default is "APC"

model.design.difference

Optional. Indicates which sub-model should be fitted for the difference part of the parameters, that is for the difference of the canonical parameters (xi.1-xi.2)/2. Possible choices: "APC","AP","AC","PC","Ad","Pd","Cd","A","P","C","t","tA","tP","tC" and "ATC". Default is "APC"

model.design.reference.common

Optional for apc.fit.table.2s. Default is "APC"

model.design.reference.difference

Optional for apc.fit.table.2s. Default is "APC"

restrict

Optional for apc.fit.table.2s. Character. Either "difference" or "common". Which type of parameter is restricted? Default is "difference

gls.weight

Optional. Vector. Use to set relative weights when estimating by GLS using model.family set to "gls.log.normal.rates". GLS regression divides log(rates) and design for each sample by respective weights Weights could be their residual standard deviation in 1-sample analysis. Or, Weights could be normalized so that 2nd element is 1 and 1st element is 1-sample residual standard deviation for 1st sample divided by that of 2nd sample deviation for the first sample and 1 for second sample. Default is c(1,1).

apc.index

Optional. List. See apc.get.index for a description of the format. If not provided this is computed internally. If apc.fit.model is used in a simulation study computational effort can be saved when using this option.

time.series

Optional. Vector. Should have same length as the number of periods. Double differences of period parameters will be restricted to follow double differences of the time series. Should be used with model.design.common and/or model.design.difference set to "ATC". Default is NULL.

digits

Optional. Numerical. Number of digits in output. Default=3.

Author

Bent Nielsen <bent.nielsen@nuffield.ox.ac.uk> 7 Jul 2025

References

Nielsen, B. (2022) Two-sample age-period-cohort models with an application to Swiss suicide rates. Download: Nuffield Discussion Paper 2022-W03.