ssa.plot {GillespieSSA} | R Documentation |
Provides basic functionally for simple and quick time series plot of simulation output from ssa
.
ssa.plot( out = stop("requires simulation output object"), file = "ssaplot", by = 1, plot.from = 2, plot.to = dim(out$data)[2], plot.by = 1, show.title = TRUE, show.legend = TRUE)
out |
data object returned from ssa . |
file |
name of the output file (only applicable if plot.device!="x11" . |
by |
time increment in the plotted time series |
plot.from |
first population to plot the time series for (see note) |
plot.to |
last population to plot the time series for (see note) |
plot.by |
increment in the sequence of populations to plot the time series for (see note) |
show.title |
boolean object indicating if the plot should display a title |
show.legend |
boolean object indicationg if the legend is displayed |
The options by
, plot.from
, plot.to
, and plot.by
can be used to plot a sparser sequense of data points. To plot the population sizes using a larger time interval the by
option can be set, e.g. to plot only every 10th time point by=10
. To plot only specific populations the plot.from
, plot.to
, and plot.by
options can be set to subset the state vector. Note that the indexing of the populations is based on the (t,X) vector, i.e. the first column is the time vector while the first population is index by 2 and the last population by N+1. Display of a plot title above the plot and legend is optional (and are set with the arguments {{{show.title}}} and {{{show.legend}}}. Above the plot panel miscellaneous information for the simulation are displayed, i.e. method, elapsed wall time, number of time steps executed, and the number of time steps per data point.
## Not run: ## Define the Kermack-McKendrick SIR model abd run once unsing the Direct method parms <- c(beta=.001, gamma=.100) x0 <- c(S=500, I=1, R=0) # Initial state vector nu <- matrix(c(-1,0,1,-1,0,1),nrow=3,byrow=T) # State-change matrix a <- c("beta*S*I", "gamma*I") # Propensity vector tf <- 100 # Final time simName <- "Kermack-McKendrick SIR" out <- ssa(x0,a,nu,parms,tf,method="D",simName,verbose=TRUE,consoleInterval=1) ## End(Not run) ## Not run: ## Basic ssa plot ssa.plot(out) ## End(Not run) ## Not run: # Plot only the infectious class ssa.plot(out,plot.from=3,plot.to=3) ## End(Not run) ## Not run: ## Multipanel plot using different SSA methods layout(matrix(seq(4),ncol=4,byrow=TRUE)) ## Using the Direct method ssa.plot(out) ## Run and plot results using the ETL method out <- ssa(x0,a,nu,parms,tf=100,method="ETL,simName="Kermack-McKendrick SIR") ssa.plot(out,show.title=FALSE,show.legend=FALSE) ## Run and plot results using the BTL method out <- ssa(x0,a,nu,parms,tf=100,method="BTL,simName="Kermack-McKendrick SIR") ssa.plot(out,show.title=FALSE,show.legend=FALSE) ## Run and plot results using the OTL method out <- ssa(x0,a,nu,parms,tf=100,method="OTL,simName="Kermack-McKendrick SIR") ssa.plot(out,show.title=FALSE,show.legend=FALSE) ## End(Not run)