Thank you for your interest in our research. See our Sociological Methodology & Research article for methodological details and R Journal article for additional discussions.
This FAQ page for the APC-I model provides responses to frequently asked questions about the APC-I model
Labor force participation data and tables are available for downloading here.
See below about how to use the APCI package in R and Stata. Please contact Jiahui Xu jpx5053@psu.edu if you have additional questions.
#### for R users ####
1. Install and load the APCI package using the following R code:
2.1 install the package from CRAN: install.packages (‘APCI’)
2.2 load the package in R: library(APCI)
3. read your data into R. For example, to read a Stata file,
3.1 download and install an R package “haven”install.packages (‘haven’)
3.2 load the package “haven”: library (haven)
3.3 read data into R: mydata = read_dta(file_path)
3.4 define the following in the apci function:
data a data frame that contains variables for modeling
outcome outcome variable
age age group index in the data
period time period index in the data
cohort cohort membership index in the data
weight optional sample weights
covariate a list of optional user-specified covariates; if none, use covariate=c( )
dev.test logical, if run global deviance tests and return their results
family a link function for a generalized linear model
For example, for a dataset called “mydata”, the function can be used as follows:
apci (data = mydata, outcome = ‘drug’, age = ‘age_group’, period = ‘period_group’, cohort = ‘cohort_group’, covariate = c(‘educc’), family = ‘binomial’, weight = ‘wt’)
4. Common problem
A quick fix to “Error in solve.default(V) : ‘a’ is 0-diml” is setting the “dev.test” option to be false (i.e., dev.test=FALSE”). While we’re working on the issue, the global test about the age-period interactions that this option is designed for can be accomplished manually using the following code:
anova(glm(outcome~age*period, family=gaussian, data=data)
#### for Stata users ####
We now offer two versions of Stata commands, one depending on R (i.e., you will need to install R on your end) and the other independent of R (i.e., you don’t need to have R to implement it).
# R-dependent version #
1. run the following two lines in Stata:
net install github, from("https://haghish.github.io/github/") github install haghish/rcall, stable
2. run command `sysdir` in Stata. Users will see:
. sysdir STATA: /Applications/Stata/ BASE: /Applications/Stata/ado/base/ SITE: /Applications/Stata/ado/site/ PLUS: ~/Library/Application Support/Stata/ado/plus/ PERSONAL: ~/Library/Application Support/Stata/ado/personal/ OLDPLACE: ~/ado/
3.1 create a new folder named `a` under `ado` -> `PERSONAL`.
3.2 copy and paste the ado file in this folder from APCI for Stata.
Note 1 : See the example in `apci_example.do`.
Note 2: If the above method fails, users may try defining the related functions first and then run the apci model. That is, run `apci_alternative.do`. The log file of running this script is `simulation.do`.
# R-independent version #
download and unzip this file: apci_stata_noR. The apci functions are contained in apci_stata_releasev1.do. The example is in “apci_alternative.do”.