hom_plot_incidence_by_location: Plot incidence by location as extracted from hierarchical...

View source: R/plotting.R

hom_plot_incidence_by_locationR Documentation

Plot incidence by location as extracted from hierarchical outbreak model.

Description

If extracted_posts is NULL then posts object is used to first extract the incidence draws from posterior (note this will take longer)

Usage

hom_plot_incidence_by_location(
  extracted_posts = NULL,
  posts = NULL,
  outbreak_cases = NULL,
  end_time = 60,
  location_labels = NULL,
  sort = TRUE
)

Arguments

extracted_posts

object returned by hom_extract_posterior_draws

posts

Object after calling extract of stan model object of hierarchical model

outbreak_cases

matrix of outbreak case data

end_time

time in days to plot up until

location_labels

tibble with columns 'site' and 'location'. Will be used to relabel numeric location to values in 'site' column

sort

TRUE/FALSE. If TRUE (default), locations will be ordered by mean R0

Value

list containing: * plot - ggplot object * table - tibble object of results

Note

Naming convention throughout is snake case with prefix "hom_" to denote Hierarcical Outbreak Model

Examples

## Not run: 
 mod # RSTAN fit object
 outbreak_cases <- matrix(c(0,0,1,2,3,0,0,2,4,5),ncol=2) # data of outbreaks in matrix form
 posts <- rstan::extract(mod) # extract posterior from model object
 extracted_posts <- hom_extract_posterior_draws(posts) # get object of incidence and r0
 result <- hom_plot_incidence_by_location(extracted_posts=extracted_posts,
                                          outbreak_cases=outbreak_cases)
 # plot results
 show(result$plot)
 
## End(Not run)

sempwn/cr0eso documentation built on Aug. 21, 2022, 1:35 a.m.