Skip to content

mrc-ide/weave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

115 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

weave weave package logo

R-CMD-check Codecov test coverage

weave turns noisy, gappy spatio-temporal count data — such as malaria cases reported by health facilities — into smooth estimates of the underlying rate. It fills in missing weeks and attaches an honest prediction interval to every estimate.

How it works

weave treats the counts as arising from a smooth latent surface that varies across space and time, modelled as a separable Gaussian process — a spatial kernel combined with a temporal kernel (periodic season × long-term drift). In three steps it:

  1. builds a quick plug-in field from the counts (per-site standardised log(1 + y));
  2. estimates the kernel hyperparameters — how fast counts decorrelate across space, within the season, and over the long term — by maximising the Gaussian-process marginal likelihood, kept fast by the kernel’s Kronecker structure; and
  3. predicts the latent rate at every site and week, conditioning on the observed cells (so gaps are genuinely interpolated rather than guessed) and combining rate uncertainty with Negative-Binomial count noise to form a 95% prediction interval.

Installation

You can install the development version of weave from GitHub with:

# install.packages("pak")
pak::pak("mrc-ide/weave")

Getting started

weave needs two inputs: obs_data, a data frame with columns id (site), t (week) and y_obs (the count, NA where missing); and coordinates, giving each site’s lon/lat. The workflow is two calls — estimate the kernels, then predict:

library(weave)

# 1. estimate the spatial + temporal kernel length-scales
est <- infer_kernel_params(obs_data, coordinates, nt = nt, period = 52)

# 2. predict the rate, fill the gaps, and attach a 95% prediction interval
pred <- gp_predict(obs_data, coordinates, hyperparameters = est,
                   nt = nt, period = 52, n_draws = 100)

pred has one row per site-week, with the posterior rate and a lower/upper prediction interval.

Learn more

About

🧶 GPs for routine data 🧶

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors