knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(blantyreESBL)
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^
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")
The model can include covariates that are:
See the manuscript for details
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
N [integer]
n_covs [integer vector of length 3]
covs_type [integer vector of length(number of covariates)]
t [integer vector of length N]
cov_mat [real matrix with 3*(number of covariate) columns and N rows]
start state [ matrix with N rows and two columns ]
end state: [integer]
The included data btESBL_stanmodeldata is set up to fit the model used in the manuscript.
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
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.