The R package 'gcount4parity' provides the code required to reproduce the article: Barakat, B. (2017). Generalised Count Distributions for Modeling Parity. *Demographic Research*. [FORTHCOMING] This document explains step-by-step how to run this code. The raw input data from the Human Fertility Database (HFD) are freely available, but the User Agreement precludes distributing them as part of the 'gcount4parity' package directly. This makes some additional steps necessary to install the package and re-run the analysis. Downloads --------- 1. Download and unzip the file gcount4parity.zip available on this site. This creates a directory '/gcount4parity/', where '' depends on your system and download location. 2. Register as an HFD user at: http://www.humanfertility.org/. 3. Under Data > Zipped Data Files, download file 'cfr.zip' containing Cumulative fertility rates. 4. Move 'cfr.zip' to the directory '/gcount4parity/inst/extdata/' created in step 1. Installation ------------ If not already available, install R, which is freely available from: https://www.r-project.org/. It is also recommended to install the RStudio application, likewise freely available, from: https://www.rstudio.com/products/rstudio/download/. Double-click the file '/gcount4parity/gcount4parity.Rproj' to open it in RStudio. This should automatically set the working directory to the folder '/gcount4parity/'. If the working directory is correctly set to '/gcount4parity/, you can install the package 'gcount4parity' itself by first installing the required packages: > install.packages(c("devtools", "compoisson", "dplyr", "ggplot2", "ISOcodes", "knitr", "rmarkdown", "R.utils", "tidyr")) (as well as their own dependencies in case these fail to resolve automatically) and then calling: > devtools::install(build_vignettes = TRUE) The source for the article is included as the package 'vignette' in R parlance. The above command ensures the vignette is re-built, in other words, all analyses and figures and re-created from the source code. This may take several minutes, depending on your system. Inspection ---------- The final reproduced article in PDF format, its LaTeX/R source, as well as the contained R code by itself can be inspected in the package browser under the heading 'Vignettes' by calling: > ??gcount4parity The actual source file 'gcount4parity.Rnw' is located in the subdirectory '/gcount4parity/vignettes/'. It is written in Sweave format, intermingling LaTeX and R code. Function this processing code calls on are defined in the various '.R' files in the subdirectory '/gcount4parity/R/'. Additional graphs ----------------- So-called 'rootogram' graphs for each country-cohort dyad that are too numerous to have been included in the article can be produced by issuing a single command. However, this relies on the 'countreg' package as a prerequisite that cannot be installed automatically as a dependency, but must first be installed via: > devtools::install_github('rforge/countreg/pkg') Once 'countreg' is installed, the rootograms can be generated by calling: > gcount4parity::make_rootograms() The graphs are created inside a folder 'plots/' in the working directory. Note that this takes some time and requires approximately 250 MB of space.