Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I recently rolled up the new version of the GillespieSSA package, version 0.3-1. The tar ball of the new version is posted on its web page (here). I also submitted it to CRAN so in (due time) it should appear on the official R package list.

The release consists of a number of bug fixes (among others typos in the package URL and demo models). The biggest change for the end user is, however, a now and cleaner way of passing model parameters to the main interface function ssa(). Rather than having to define model parameters in the global environment or hard coding their values into the propensity functions they can now be passed as a formal argument in the form of a named vector directly to ssa(). I owe a thanks to Ben Bolker for suggesting this deuglification solution. An added benefit of this revised feature is that model definitions are actually shorter now. The whole model + running it can now easily be a one liner.

For example defining and running the stochastic version of the classical logistic growth model $frac{{displaystyle dN}}{{displaystyle dt}}=rN left( 1-frac{{displaystyle N}}{displaystyle K} right)$ is now as simple as

 library(GillespieSSA) out <- ssa(x0=c(N=500),a=c(”b*{N}”, ”(d+(b-d)*{N}/K)*{N}”),nu=matrix(c(+1,-1),ncol=2),parms=c(b=2, d=1, K=1000),tf=25)

Here the per capita birth rate is $b=2$, death rate $d=1$, intrinsic growth rate $r=b-d=1$, carrying capacity $K=1000$. The Monte Carlo simulation is run for ten time units (t=10) using Gillespie’s Direct method (the default method in GillespieSSA) and starting with a population size of $N=500$.

One way of quickly visualizing the resulting time series is by

 ssa.plot(out)

As expected the results look rather stochastically familiar,           