Skip to contents

The Chap R SDK provides tools for building disease forecasting models compatible with the Chap platform.

Documentation

Read the full documentation

What is this?

Chap (Climate Health Analytics Platform) enables health ministries to run disease forecasting models. This R SDK helps model developers create models that integrate seamlessly with Chap.

Who is this for?

  • Epidemiologists and researchers who want to deploy their R models on Chap
  • Model developers who need a standardized interface for train/predict workflows
  • Teams who want to share models with collaborators via Chap

Key Features

  • Zero boilerplate CLI: One function creates a complete command-line interface
  • Automatic data handling: CSV loading, tsibble conversion, output formatting
  • Configuration schemas: YAML/JSON config with validation and defaults
  • Model validation: Test suite to verify Chap compatibility before deployment

Quick Example

A complete Chap-compatible model in one file:

library(chapr)
library(dplyr)

train_fn <- function(training_data, model_configuration = list(), run_info = list()) {
  means <- training_data |>
    as_tibble() |>
    summarise(mean_cases = mean(disease_cases, na.rm = TRUE), .by = location)
  list(means = means)
}

predict_fn <- function(historic_data, future_data, saved_model,
                       model_configuration = list(), run_info = list()) {
  future_data |>
    left_join(saved_model$means, by = "location") |>
    mutate(samples = purrr::map(mean_cases, ~c(.x))) |>
    select(-mean_cases)
}

if (!interactive()) {
  create_chap_cli(train_fn, predict_fn)
}

Then run from the command line:

Rscript model.R train --data training_data.csv
Rscript model.R predict --historic historic.csv --future future.csv --output predictions.csv
Rscript model.R info

Installation

Install from GitHub by running the following R-code:

# install.packages("remotes")
remotes::install_github("dhis2-chap/chap_r_sdk")

For Model Examples

Each example in examples/ has its own renv environment which keeps track of the packages and the versions used:

cd examples/fable_model
Rscript -e 'renv::restore()'

Contributing

See CONTRIBUTING.md for development setup and guidelines.

Getting Help