GithubHelp home page GithubHelp logo

catchment's Introduction

catchment

The goal of catchment is to estimate health facility catchment populations using Bayesian gravity models. The primary purpose of these population estimates is to calculate catchment-level incidence rates using routine reporting data from health information systems.

Installation

Before installing this package, first you will need to install the R-INLA and Template Model Builder (TMB) packages. These packages are not on CRAN, and the installation process may depend on the type of computer you are using. I recommend following the installation instructions for INLA first, and then install TMB. Be sure to close out of any active R session before installation!

The catchment package is also not on CRAN (yet!). You can install the development version of catchment from GitHub with:

# install.packages("devtools")
devtools::install_github("PATH-Global-Health/catchment")

Example

We are currently developing documentation and tutorial materials.

# Load libraries
library(raster)
library(catchment)

# 1. Pre-processing --------------------------------------
## Load example dataset
data("example_shp")
data("example_pop")
data("example_locs")

## Get friction surface
fric <- PATHtools::get_friction_surface(example_shp) |>
  raster::raster() |>
  raster::resample(example_pop, fun = "mean")

## Create output folder
f <- tempfile()
fs::dir_create(fs::path(f, "tt"))

# 2. Travel time and intial access surfaces --------------
## Create individual travel time rasters
create_travel_surface(friction_surface = fric, extent_file = example_pop,
  points = example_locs, id_col = "label", x_col = "x", y_col = "y",
  output_dir = fs::path(f, "tt"), individual_surfaces = T, parallel = T, cores = 5)

## Organize travel time matrix
tmat <- travel_mat_from_folder(dir = fs::path(f, "tt"), reference = example_pop)

## Create initial accessbility matrix
pmat <- initial_access_surface(tmat, n_fac_limit = 10, force_threshold = 300, sparse = F)

# 3. Fit catchment model ---------------------------------
## Organize input data
catch_dat <- prepare_data(prob_mat_init = pmat, pop_raster = example_pop,
  location_data = example_locs, mesh.args = list(cutoff = 0.1,max.edge = c(0.1, 4)))

## View INLA mesh
plot(catch_dat$mesh)
plot(example_shp, add = T, border = "red", lwd = 2)
points(example_locs$x, example_locs$y)

## Fit catchment model
mod <- catchment_model(catch_dat)

# 4. Post-processing -------------------------------------
## Estimated catchment populations
catchment_populations(mod)
example_locs$est_pop <- catchment_populations(mod)

catchment's People

Contributors

justinmillar avatar

Stargazers

Tomás León avatar  avatar Mel Mashiku avatar Jorge Ruiz-Cabrejos avatar Tim Lucas avatar Peter Macharia avatar

Watchers

Jonathan Drummey avatar  avatar Tim McDonald avatar  avatar  avatar  avatar  avatar Jorge Ruiz-Cabrejos avatar Peter Macharia avatar

catchment's Issues

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.