regions

Codecov test coverage Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.licenseTravis build statusCRAN_Status_Badge” “CRAN_Status_Badge_version_last_release” “metacran downloadsDOI Follow rOpenGov Follow author

Installation

You can install the development version from GitHub with:

devtools::install_github("rOpenGov/regions")

or the released version from CRAN:

install.packages("devtools")

You can review the complete package documentation on regions.danielantal.eu. If you find any problems with the code, please raise an issue on Github. Pull requests are welcome if you agree with the Contributor Code of Conduct

If you use regions in your work, please cite the package.

Motivation

Working with sub-national statistics has many benefits. In policymaking or in social sciences, it is a common practice to compare national statistics, which can be hugely misleading. The United States of America, the Federal Republic of Germany, Slovakia and Luxembourg are all countries, but they differ vastly in size and social homogeneity. Comparing Slovakia and Luxembourg to the federal states or even regions within Germany, or the states of Germany and the United States can provide more adequate insights. Statistically, the similarity of the aggregation level and high number of observations can allow more precise control of model parameters and errors.

The advantages of switching from a national level of the analysis to a sub-national level comes with a huge price in data processing, validation and imputation. The package Regions aims to help this process.

This package is an offspring of the eurostat package on rOpenGov. It started as a tool to validate and re-code regional Eurostat statistics, but it aims to be a general solution for all sub-national statistics. It will be developed parallel with other rOpenGov packages.

Sub-national Statistics Have Many Challenges

Package functionality

Vignettes / Articles

Example

This is a basic example which shows you how to impute data from a larger territorial unit, such as a national statistic, to lower territorial units:

library(regions)

upstream <- data.frame ( country_code =  rep( "AU", 2),
                         year = c(2019:2020),
                         my_var  = c(10,12)
                       )

downstream <- australia_states

imputed <- impute_down ( upstream_data  = upstream,
              downstream_data = downstream,
              country_var = "country_code",
              regional_code = "geo_code",
              values_var = "my_var",
              time_var = "year" )

knitr::kable(imputed)
geo_code year geo_name country_code my_var method
AU-NSW 2019 New South Wales state AU 10 imputed from AU actual
AU-QLD 2019 Queensland state AU 10 imputed from AU actual
AU-SA 2019 South Australia state AU 10 imputed from AU actual
AU-TAS 2019 Tasmania state AU 10 imputed from AU actual
AU-VIC 2019 Victoria state AU 10 imputed from AU actual
AU-WA 2019 Western Australia state AU 10 imputed from AU actual
AU-ACT 2019 Australian Capital Territory territory AU 10 imputed from AU actual
AU-NT 2019 Northern Territory territory AU 10 imputed from AU actual
AU-NSW 2020 New South Wales state AU 12 imputed from AU actual
AU-QLD 2020 Queensland state AU 12 imputed from AU actual
AU-SA 2020 South Australia state AU 12 imputed from AU actual
AU-TAS 2020 Tasmania state AU 12 imputed from AU actual
AU-VIC 2020 Victoria state AU 12 imputed from AU actual
AU-WA 2020 Western Australia state AU 12 imputed from AU actual
AU-ACT 2020 Australian Capital Territory territory AU 12 imputed from AU actual
AU-NT 2020 Northern Territory territory AU 12 imputed from AU actual

Code of Conduct

Please note that the regions project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.