Code Monkey home page Code Monkey logo

beyond-borders's Introduction

beyond-borders

Code for the manuscript Howes, Eaton, Flaxman "Beyond borders: evaluating the suitability of spatial adjacency for small-area estimation" (in preparation).

Small-area estimation models typically use the Besag model, a type of Gaussian Markov random field, to model spatial structure.

However, for irregular geometries, the assumptions made by the Besag model do not seem plausible. The Besag model was designed to work well for grids, as are used in image analysis, but in small-area estimation the geometries we encounter, like the districts of a country, are more irregular.

The goal of this work is to determine whether or not, in practice, this matters. To do so, we consider the performance of eight inferential small-area models:

Model Function
Constant constant_aghq
Independent and identically distributed iid_aghq
Besag besag_aghq
Besag-York-Mollié 2 bym2_aghq
Centroid kernel (fixed lengthscale) fck_aghq
Integrated kernel (fixed lengthscale) fik_aghq
Centroid kernel ck_aghq
Integrated kernel ik_aghq

We use the aghq package for adaptive Gauss-Hermite quadrature over a marginal Laplace approximation to conduct approximate Bayesian inference for each of the models. Where possible, alternative implementions using TMB, tmbstan, R-INLA and rstan are provided by the arealutils package.

R package dependencies

This analysis is supported by the arealutils package (I'd usually use the name areal.utils but C++ doesn't like having . in package names) which can be installed from Github via:

devtools::install_github("athowes/arealutils")

The aghq package is available from CRAN, though the latest development version can be installed from Github via:

devtools::install_github("awstringer1/aghq")

Additionally, if required, the R-INLA package is not currently available on CRAN, and instead may be installed by following instructions from the project website.

File structure

The directories of this repository are:

Directory Contains
make Scripts used to run the reports. _make.R runs everything in order.
misc Miscellaneous code, not used as part of orderly.
src All orderly reports.
utils Helper scripts for common development tasks.

Within the src directory, reports are prefixed by a number (0-2) designating:

Prefix Description
0 Applicable to both studies.
1 Corresponds to the study on synthetic data.
2 Corresponds to the study on HIV data from household surveys in sub-Saharan Africa.

orderly

We use the orderly package (RESIDE, 2020) to simplify the process of doing reproducible research. After installing orderly (from either CRAN or Github) a report, let's say called example, may be run by:

orderly::orderly_run(name = "src/example")

The results of this run will appear in the draft/ folder (ignored on Github). To commit the draft (with associated id) to the archive/ folder (also ignored on Github, and which should be treated as "read only") use:

orderly::orderly_commit(id)

Any outputs of this report will then be available to use as dependencies within other reports.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.