Title: | Interactive Plotting for Mathematical Models of Infectious Disease Spread |
---|---|
Description: | Provides interactive plotting for mathematical models of infectious disease spread. Users can choose from a variety of common built-in ordinary differential equation (ODE) models (such as the SIR, SIRS, and SIS models), or create their own. This latter flexibility allows 'shinySIR' to be applied to simple ODEs from any discipline. The package is a useful teaching tool as students can visualize how changing different parameters can impact model dynamics, with minimal knowledge of coding in R. The built-in models are inspired by those featured in Keeling and Rohani (2008) <doi:10.2307/j.ctvcm4gk0> and Bjornstad (2018) <doi:10.1007/978-3-319-97487-3>. |
Authors: | Sinead E. Morris [aut, cre] , Ottar N. Bjornstad [ctb] |
Maintainer: | Sinead E. Morris <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.3 |
Built: | 2024-11-08 06:15:36 UTC |
Source: | https://github.com/SineadMorris/shinySIR |
This function prints a list of all built in models, along with their parameter arguments and a short description.
default_models()
default_models()
data frame of model descriptions.
default_models()
default_models()
This function returns the default parameter vectors for a particular built-in model.
get_ics(model)
get_ics(model)
model |
name of the model to be solved. Examples include: SIR and SIR vaccination. |
named vector of default initial conditions.
This function gets the display name for any built-in model.
get_name(model)
get_name(model)
model |
character specifying the name of the built-in model. |
character of the corresponding display name.
get_name(model = "SIR")
get_name(model = "SIR")
This function returns the default parameter vectors for a particular built-in model.
get_params(model)
get_params(model)
model |
name of the model to be solved. Examples include: SIR and SIR vaccination. |
list of default parameter vectors.
get_params(model = "SIR")
get_params(model = "SIR")
Plot model output. This function plots the output of a fitted model data frame.
plot_model( output, linesize, textsize, xlabel, ylabel, legend_title, levels, values, ... )
plot_model( output, linesize, textsize, xlabel, ylabel, legend_title, levels, values, ... )
output |
data frame output from solve_eqns(). |
linesize |
numeric value for line width in ggplot. |
textsize |
numeric value for textsize in ggplot. |
xlabel |
character string for x axis label. |
ylabel |
character string for y axis label. |
legend_title |
character string for legend title. |
levels |
character vector of the variable names in the order they should be plotted. Default is to obtain the order from the initial conditions vector 'ics'. |
values |
vector specifying manual color scale. Length must equal the number of model variables. |
... |
extra argument to be passed through to ggplot scale_colour_manual: use 'labels' to change the legend names |
ggplot object
This function solves an ODE model using 'deSolve' and returns the output as a data frame.
run_shiny( model = "SIR", neweqns = NULL, ics = NULL, tstart = 0, timestep = 1, tmax = 365, parm0 = NULL, parm_names = NULL, parm_min = NULL, parm_max = NULL, sigfigs = 4, showtable = TRUE, linesize = 1.2, textsize = 14, xlabel = "Time", ylabel = "Number of individuals", legend_title = "Compartment", slider_steps = NULL, values = NULL, ... )
run_shiny( model = "SIR", neweqns = NULL, ics = NULL, tstart = 0, timestep = 1, tmax = 365, parm0 = NULL, parm_names = NULL, parm_min = NULL, parm_max = NULL, sigfigs = 4, showtable = TRUE, linesize = 1.2, textsize = 14, xlabel = "Time", ylabel = "Number of individuals", legend_title = "Compartment", slider_steps = NULL, values = NULL, ... )
model |
name of the model to be solved. Examples of built-in models are: "SIR", "SIRS", "SIS", "SIRvaccination". Call 'default_models()' to view the names of all built-in models along with a short description. Default model is "SIR". |
neweqns |
function specifying the equations of the user-defined model. Only to be used if a model is required that is not built-in. Default is NULL. |
ics |
named numeric vector specifying the initial conditions i.e. the initial values of all model variables. Default is c(S = 9999, I = 1, R = 0) for the SIR model. |
tstart |
numerical value of form c(tmin, tmax) indicating the time to start simulations. Default value is 0. |
timestep |
numerical value indicating time step be used when solving equations. Default value is 1/365. |
tmax |
numerical value indicating maximum time point to be considered. |
parm0 |
named numeric vector of starting parameter values. Names must correspond to those used in the model equations. |
parm_names |
character vector of parameter names to be displayed in shiny menu. Must be in the same order as 'parm0'. |
parm_min |
named numeric vector of minimum parameter values. |
parm_max |
named numeric vector of maximum parameter values. |
sigfigs |
number of significant figures to round parameter input vectors. Default is 4. |
showtable |
logical TRUE/FALSE. Should the table of transformed parameters be shown? Only applies to built-in models. Default is TRUE. |
linesize |
numeric value for line width in ggplot output. Default is 1.2. |
textsize |
numeric value for textsize in ggplot output. Default is 14. |
xlabel |
character string for x axis plotting label. Default is "Time". |
ylabel |
character string for y axis plotting label. Default is "Number of individuals". |
legend_title |
character string for legend title. Default is "Compartment". |
slider_steps |
numeric vector of step size to include between slider input values. Should be NULL or a vector with an entry for each parameter input. Default is NULL. |
values |
vector specifying manual color scale (if desired). Length must equal the number of model variables. |
... |
extra argument to be passed through to ggplot scale_colour_manual: use 'labels' to change the legend names. |
data frame of model solutions in long format.
run_shiny(model = "SIR")
run_shiny(model = "SIR")
#' This launches an app running the SEIR model i.e. a model incorporating latency and seasonal forcing in transmission.
seir.app
seir.app
An object of class shiny.appobj
of length 5.
Launch app for details
## Not run: seir.app
## Not run: seir.app
This launches an app running the SEIRS model i.e. a model incorporating latency and loss of immunity.
seirs.app
seirs.app
An object of class shiny.appobj
of length 5.
Launch app for details
## Not run: seirs.app
## Not run: seirs.app
These equations describe the classic SIR model with no births or deaths.
SIR(t, y, parms)
SIR(t, y, parms)
t |
numeric vector of time points. |
y |
numeric vector of variables. |
parms |
named vector of model parameters. |
equation list
These equations describe the classic SIR model with equal births and deaths.
SIRbirths(t, y, parms)
SIRbirths(t, y, parms)
t |
numeric vector of time points. |
y |
numeric vector of variables. |
parms |
named vector of model parameters. |
equation list
These equations describe the classic SIRS model without births or deaths.
SIRS(t, y, parms)
SIRS(t, y, parms)
t |
numeric vector of time points. |
y |
numeric vector of variables. |
parms |
named vector of model parameters. |
equation list
These equations describe the classic SIRS model with equal birth and death rates.
SIRSbirths(t, y, parms)
SIRSbirths(t, y, parms)
t |
numeric vector of time points. |
y |
numeric vector of variables. |
parms |
named vector of model parameters. |
equation list
These equations describe the classic SIRS model with equal birth and death rates and vaccination at birth.
SIRSvaccination(t, y, parms)
SIRSvaccination(t, y, parms)
t |
numeric vector of time points. |
y |
numeric vector of variables. |
parms |
named vector of model parameters. |
equation list
These equations describe the classic SIR model with births and deaths, constant population size, and (optional) vaccination at birth.
SIRvaccination(t, y, parms)
SIRvaccination(t, y, parms)
t |
numeric vector of time points |
y |
numeric vector of variables |
parms |
named vector of model parameters. |
equation list
These equations describe the classic SIS model with no births or deaths.
SIS(t, y, parms)
SIS(t, y, parms)
t |
numeric vector of time points |
y |
numeric vector of variables |
parms |
named vector of model parameters. |
equation list
These equations describe the classic SIR model with equal births and deaths.
SISbirths(t, y, parms)
SISbirths(t, y, parms)
t |
numeric vector of time points. |
y |
numeric vector of variables. |
parms |
named vector of model parameters. |
equation list
This function solves an ODE model using 'deSolve' and returns the output as a data frame.
solve_eqns(eqns, ics, times, parms)
solve_eqns(eqns, ics, times, parms)
eqns |
name of the model to be solved. Examples include: SIR and SIRvaccination. |
ics |
named numeric vector specifying the initial conditions i.e. the initial values of all model variables. |
times |
numerical vector indicating the time points at which the equation should be solved. |
parms |
named numeric vector of parameter values. |
data frame of model solutions in long format.