knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

augury

R-CMD-check

The goal of augury is to streamline the process of fitting models to infill and forecast data, particularly for models used within the WHO's Triple Billion framework.

Installation

You can install augury from GitHub. The package depends on the INLA package which is not available on CRAN. You will need to separately install that prior to installing augury, following the code below.

if (!require("INLA")) install.packages("INLA",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/stable"), dep=TRUE)
remotes::install_github("gpw13/augury")

Overview

Most of the functions available through the package are designed to streamline fitting a model and replacing missing observations within a single data frame in one pass.

Given that models might need to be fit separately to different portions of a data frame, such as fitting time series models for each country individually, these functions now accept the argument group_models that determines whether to fit separate models to each group in the data frame before joining them back together into the original data frame.

Additional model wrappers

Additional functions are provided as requested to streamlining fitting of specific models. For general modeling, there are grouped and individual functions for stats::lm(), stats::glm(), and lme4::lmer() to fit linear models, generalized linear models, and linear mixed-effects models respectively. These wrappers are:

As well, wrappers are provided around INLA for models currently in place for the Triple Billion framework. These are a time series model with no additional covariates (fit individually by country) and a mixed-effects model using covariates.

And for forecasting, generic functions are provided for simple exponential smoothing and Holt's linear trend exponential smoothing.

Covariates

For convenience, the covariates used within the default INLA modeling are exported from the package and can be easily joined up to a data frame for use in modeling. These are available through augury::covariates_df.

Grouped trend development

While we typically want to fit a model to a data set directly, augury has a set of predict_..._avg_trend() functions that allows you to average data by group (e.g. by region), fit the model to the grouped and averaged data, and extract that trend to apply to the original dataset. See the section below on Average trend modeling for more details.

Error metrics

When doing model selection, it is always important to use metrics to evaluate model fit and predictive accuracy. All predict_... functions in augury use the same evaluation framework, implemented through model_error(). If a test column is defined, then the evaluation framework is only applied to this set

Additional functionality

To help streamline other portions of the modeling process, some other functions are included in the package.

Together, they can be used to transform and scale data for better modeling, and then inverse these to get data back into the original feature space.

INLA modeling examples


Forecasting examples


Simple prediction methods


Average trend modeling




caldwellst/augury documentation built on Oct. 10, 2024, 8:20 a.m.