apcmat {APCG1} | R Documentation |
Generate design matrix for APC models with specfied side conditions, either centralization or reference level.
apcmat(a, p, ref = c(0, 0, 0))
a, p |
Dimension of APC data matrix of a rows and p columns. |
ref |
a vector of 3 integers specifying side conditions for each of age, period, or cohort effects. Positive integer indicates the reference level, while 0 indicates centralization. |
Generate design matrix of age, period, and cohort effects with intercept as the first column. The rows are the observations of APC data going by rows (age groups) in a matrix of a by p dimension with columns as periods. The side condition of each factor is specified by the value of ref, 0 indicating centralization and positive integer indicates the reference level. The centralization assigns the last level to be the minus sum of all others. The design matrix is not of full rank (a singular matrix), reflecting the identifiation problem in APC models. The order of the effects: age, period and cohort effects.
A design matrix of ap rows and 2(a+p)-3 columns
Wenjiang Fu
Fu, W. (2018) A Practical Guide to Age-Period-COhort Analysis: the Identification Problem and Beyond, CRC.
x = apcmat(a=5, p=4, ref=c(1,0,3))