#' Plot the EIR *vs.* time
#'
#' @param pars a list that defines an `ramp.dts` model (*e.g.*, generated by `ramp.dts::dts_setup()`)
#' @param i the host species index
#' @param clrs a vector of colors
#' @param llty an integer (or integers) to set the `lty` for plotting
#' @param stable a logical: set to FALSE for `orbits` and TRUE for `stable_orbits`
#' @param add_axes a logical: plot axes only if TRUE
#'
#' @export
dts_plot_EIR <- function(pars, i=1, clrs="black", llty=1, stable=FALSE, add_axes=TRUE){
vars=with(pars$outputs,if(stable==TRUE){stable_orbits}else{orbits})
tm = vars$terms$time
EIR = vars$terms$eir[[i]]
if(add_axes==TRUE){
plot(tm, EIR, type = "n",
xlab = "Time", ylab = "dEIR", ylim = range(0, EIR))
}
dts_lines_EIR(tm, EIR, pars$Hpar[[i]]$nStrata, clrs, llty)
}
#' Add lines for the EIR *vs.* time
#'
#' @param tm the time
#' @param EIR the entomological inoculation rate
#' @param nStrata the number of human / host population strata
#' @param clrs a vector of colors
#' @param llty an integer (or integers) to set the `lty` for plotting
#'
#' @export
dts_lines_EIR <- function(tm, EIR, nStrata, clrs="black", llty=1){
if(nStrata==1)
graphics::lines(tm, EIR, col=clrs, lty = llty)
if(nStrata>1){
if(length(clrs)==1) clrs=rep(clrs, nStrata)
if(length(llty)==1) llty=rep(llty, nStrata)
for(i in 1:nStrata)
graphics::lines(tm, EIR[,i], col=clrs[i], lty = llty)
}
}
#' Plot the annualized EIR *vs.* time
#'
#' @param pars a list that defines an `ramp.dts` model (*e.g.*, generated by `ramp.dts::dts_setup()`)
#' @param i the host species index
#' @param clrs a vector of colors
#' @param llty an integer (or integers) to set the `lty` for plotting
#' @param stable a logical: set to FALSE for `orbits` and TRUE for `stable_orbits`
#' @param add_axes a logical: plot axes only if TRUE
#'
#' @export
dts_plot_aEIR <- function(pars, i=1, clrs="black", llty=1, stable=FALSE, add_axes=TRUE){
vars=with(pars$outputs,if(stable==TRUE){stable_orbits}else{orbits})
tm = vars$terms$time
aEIR = 365*vars$terms$eir[[i]]
if(add_axes==TRUE)
plot(tm, aEIR, type = "n", xlab = "Time", ylab = "aEIR", ylim = range(0, aEIR))
dts_lines_aEIR(tm, aEIR, pars$Hpar[[i]]$nStrata, clrs, llty)
}
#' Add lines for the annualized EIR *vs.* t
#'
#' @param tm the time
#' @param EIR the entomological inoculation rate
#' @param nStrata the number of human / host population strata
#' @param clrs a vector of colors
#' @param llty an integer (or integers) to set the `lty` for plotting
#'
#' @export
dts_lines_aEIR <- function(tm, EIR, nStrata, clrs="black", llty=1){
aeir = 365*EIR
if(nStrata==1) graphics::lines(tm, aeir, col=clrs)
if(nStrata>1){
if (length(clrs)==1) clrs=rep(clrs, nStrata)
for(i in 1:nStrata)
graphics::lines(tm, aeir[,i], col=clrs[i])
}
}
#' Plot the prevalence / parasite rate (PR) from a model of human infection and immunity
#'
#' @param pars a list that defines an `ramp.dts` model (*e.g.*, generated by `dts_setup()`)
#' @param i the host species index
#' @param clrs a vector of colors
#' @param llty an integer (or integers) that specifies `lty` for plotting
#' @param stable a logical: set to FALSE for `orbits` and TRUE for `stable_orbits`
#' @param add_axes a logical: plot axes only if TRUE
#'
#' @export
dts_plot_PR = function(pars, i=1, clrs="black", llty=1, stable=FALSE, add_axes=TRUE){
vars=with(pars$outputs,if(stable==TRUE){stable_orbits}else{orbits})
tm = vars$terms$time
if(add_axes==TRUE){
plot(tm, 0*tm + 1, type = "n", ylim = c(0,1),
ylab = "Prevalence", xlab = "Time")
}
dts_lines_PR(tm, vars$terms$pr[[i]], pars$Hpar[[i]]$nStrata, clrs, llty)
}
#' Add lines for the prevalence / parasite rate (PR) from a model of human infection and immunity
#'
#' @param tm the time
#' @param PR the computed parasite rate
#' @param nStrata the number of human / host population strata
#' @param clrs a vector of colors
#' @param llty an integer (or integers) that specifies `lty` for plotting
#'
#' @export
dts_lines_PR = function(tm, PR, nStrata, clrs="black", llty=1){
if(nStrata==1) graphics::lines(tm, PR, col=clrs[1], lty = llty[1])
if(nStrata>1){
if (length(clrs)==1) clrs=rep(clrs, nStrata)
if (length(llty)==1) llty=rep(llty, nStrata)
for(i in 1:nStrata)
graphics::lines(tm, PR[,i], col=clrs[i], lty = llty[i])
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.