knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(blantyreESBL)

Introduction

This document provides instructions on how to locate the Stan code for the models used in the publication:


Dynamics of gut mucosal colonisation with extended spectrum beta-lactamase producing Enterobacterales in Malawi


Joseph M Lewis^1,2,3,4^, , Madalitso Mphasa^1^, Rachel Banda^1^, Matthew Beale^4^, Eva Heinz^2^, Jane Mallewa^5^, Christopher Jewell^6^, Nicholas R Thomson^4^, Nicholas A Feasey^1,2^

  1. Malawi Liverpool Wellcome Clinical Research Programme, Blantyre, Malawi
  2. Liverpool School of Tropical Medicine, Liverpool, UK
  3. Department of Clinical Infection, Microbiology and Immunology, University of Liverpool, Liverpool, UK
  4. Wellcome Sanger Institute, Hinxton, UK
  5. College of Medicine, University of Malawi, Malawi
  6. University of Lancaster, Lanaster, UK
  7. London School of Tropical Medicine and Hygiene, London, UK

Locating Stan code

The stan model has the filename ESBLmod_finalV1.0_rk45.stan are present in the `extdata/ directory of the installed package, which can be located with the following command:

system.file("extdata", 
            "ESBLmod_finalV1.0_rk45.stan", 
            package = "blantyreESBL")

Model specification

The model can include covariates that are:

See the manuscript for details

Passing data to the model

The model expects the following data as input; each item is passed as a named item in a list to the rstan stan command to fit the model. Each

The included data btESBL_stanmodeldata is set up to fit the model used in the manuscript.

Fitting the model

The following code (not run in this vignette) will fit the model as in the manuscript:

library(rstan)
library(blantyreESBL)

stan(
  file = system.file("extdata", 
                     "ESBLmod_finalV1.0_rk45.stan", 
                     package = "blantyreESBL")
  data = btESBL_stanmodeldata,
  warmup = 500,
  iter = 1000,
  chains = 4
) -> stanfit

Simulating from the model

The script simulate_from_posterior.R will generate the simulations used in the analysis. It is included in the package install and again can be located by:

system.file("extdata", 
            "simulate_from_posterior.R", 
            package = "blantyreESBL")

Or it is located (along withe stan model) in the inst/extdata/ folder on the github repo.



joelewis101/blantyreESBL documentation built on Nov. 1, 2023, 1:43 p.m.