The repository CompareKin was created to enable the replication of findings reported in:
Changing Kinship Structures in East and West Germany Before and After Reunification,
hereafter our manuscript.
The R code in this repository takes:
- age-specific fertility rates from the Human Fertility Database (HFD)
- age-specific probabilities of survival from the Human Mortality Database (HMD)
for two selected countries to run two-sex time-variant matrix kinship models using the R package DemoKin.
The R code automatically determines the time period for which fertility and mortality information exists for both countries and runs the kinship models for both countries for this overlapping time period only. The R code then processes the output from the matrix kinship models and compares the two selected countries graphically. The following graphical outputs are generated:
- an age x period plot of the average number of all kin combined in country 1 vs. country 2
- a plot of the average number of different kin in country 1 vs. country 2 at each age of the focal individual in the last year
- a plot of the average number of different kin in country 1 vs. country 2 at four different ages of the focal individual in each year
- an age x period plot of the ratio of the average number of different kin in country 1 vs. country 2
All graphical outputs listed above are generated for both female and male focal individuals. Currently, the graphical results are restricted to focal individuals born after the first year of the overlapping time period.
Finally, the R code generates:
- a plot of the total fertility rate (TFR) and life expectancy at birth (e0) in country 1 vs. country 2 in each year
- a plot of the mean generational length in country 1 vs. country 2 in each year
- a file
input.txtthat stores the parameters used for the country comparison - an
R.Datafile containing the outputs from the matrix kinship models
All outputs are stored in an automatically generated and time stamped folder out-country1-country2. Plots are saved as both .pdf and .svg files. In addition, there is an option to change the default inputs for the analysis, such as the comparison countries of interest.
The repository CompareKin contains two folders:
This folder contains all analysis files necessary to replicate our findings:
- The files
00_main.R,01_out-kin.R,02_des-a.R, and02_des-b.Rgenerate the main findings reported in our manuscript. The file00_main.R(a) installs allRpackages necessary to replicate our findings, (b) runs the matrix kinship models, and (c) automatically executes the files01_out-kin.R,02_des-a.R, and02_des-b.R. The latter three files generate the plots reported in our manuscript and save these plots – in .pdf and .svg format – in the time stamped folder out-country1-country2. - The standalone file
99_DE-fert.Rgenerates a plot comparing female and male age-specific fertility rates in East and West Germany based on data from the Human Fertility Collection (HFC). This plot is saved – in .pdf and .svg format – in an automatically generated folder out.
This folder stores all data files necessary to replicate our main findings, generated by the 00_main.R, 01_out-kin.R, 02_des-a.R, and 02_des-b.R files described above.
Our main findings are based on age-, sex-, and country-specific data from the Human Mortality Database (HMD), version 26 February 2024, and the Human Fertility Database (HFD), downloaded on 09 March 2024. The .zip files in the data folder do not need to be unzipped before running the analysis files in the scripts folder.
HMD and HFD data are distributed under a Creative Commons Attribution 4.0 International License. Please note the version or downloaded dates above. Data distributed by HMD and HFD may have been updated or revised in the meantime.
In order to run the R code provided in the repository CompareKin, please proceed in the following order:
- Download the repository from
github. If applicable, unzip the downloaded folder and place it in a location convenient for you. - Double click on the file
CompareKin.Rproj. This should openRStudioon your machine. - Within
RStudio, click onFile/Open File...and select the analysis file00_main.Rlocated in the scripts folder. - You should now be able to run our
Rcode without adjusting any directories.
This work is licensed under a Creative Commons Attribution 4.0 International License.
