Skip to content
Reproducable analysis of voluntary associations and fertility decline in Sweden 1890 and 1900.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Instructions for replication

The scripts contained within this repository is used for the analysis in the paper "Voluntary associations and net fertility during the Swedish demographic transition".

Software requirements

The analysis is performed using R 3.4.1 and PostGIS 2.1.

Simple instructions

Given that both R and PostGIS are installed, and that the PostgreSQL credentials are updated in R/db_config.R, run the R scripts required_packages.R and then run Makefile.

    make all

Package structure

  • required_packages.R: Documentation of required R packages
  • Makefile: Makefile for the analysis
  • init.R: A initial script sourced by all other scripts
  • R/: Collection of R functions used in the analysis
  • data-raw/: Source datafiles
  • scripts/: R scripts to reproduce analysis from source data files
  • figures/: Figures
  • .cache/: A temporary folder


  • 1890 and 1900 Swedish censuses: The micro-census data is documented within X and can be retrieved from NAPP. After download place to data in the data-raw folder.
  • Voluntary associations: The source data and the data cleaning process is documented in the package movement which is found at The source data can be retrieved from:
  • Swedish administrative boundaries: The source data and the data cleaning process is documented in the package histmaps which is found at The source data can be retrieved from the Swedish National Archive

Replication step by step

First part recreates the analysis data.

  • Download and place NAPP census data in the data-raw folder
  • Run scripts/01-make-napp-sql.R. Imports NAPP micro-census data into PostGIS database.
  • Run scripts/02-napp-to-nad.R. Connects NAPP micro-census parish code to map data parish codes
  • Run scripts/03-make-napp-lookup.R. Creates smallest common boundaries between NAPP micro-census parishes and map data parishes.
  • Run scripts/04-make-nad-map.R. Imports shapefile to PostGIS database
  • Run scripts/05-create-temp-map.R. Create a parish map in PostGIS by unioning at each year on new common id.
  • Run scripts/06-make-sql-roll-movem.R. Creates a rolling averaged voluntary association size
  • Run scripts/07-move-napp-agg.R. Calculate voluntary association size by parish
  • Run scripts/08-teachers-var.R. Calculates number of teachers per children by parish.
  • Run scripts/09-pop-density.R. Creates an urban variable from population density
  • Run scripts/10-unit-id.R. Creates a common parish ID for both censuses, from smallest common boundaries.
  • Run scripts/11-make-analysis-data.R. Combines variables into analysis dataset.
  • Run scripts/12-make-variables.R. Formats and labels variables.
  • Run scripts/13-correlation.R Figure 1
  • Run scripts/14-movement-map.R Figure 2
  • Run scripts/15-regression-1.R Table 4
  • Run scripts/16-regression-2-year.R Table 5
  • Run scripts/17-regression-3-urban.R Table 6
  • Run scripts/18-vis-year.R Figure 3
  • Run scripts/19-vis-urban.R Figure 4
You can’t perform that action at this time.