[R] Attempting to get a STELLA model into R

Thomas Petzoldt thpe at simecol.de
Mon Dec 1 08:55:16 CET 2008

Gibson, Tyler F wrote:
 > To whomever may be of help,
 > I am a student in a graduate modeling class at the University of
 > North Carolina at Wilmington. I am trying to get a STELLA model
 > converted into R. I am in the process of trying to 're-write' the
 > script into R, but I seem to be missing pieces (i.e. parm values)
 > that are keeping me from being able to replicate this model into R.
 > Does anyone have an idea of a possible solution to my problem? Are
 > there conversion programs or packages available that can convert
 > STELLA models into R format?

Hi Gibson,

I'm working with dynamic systems in R for several years but I don't know 
about any conversion programs.

The good news: AFAIK from old times, STELLA has also an equation view, 
so it should be easy to extract the equations from there. As I remember 
from my scripts, Stella used the following notation:

X(t) = X(t-dt) + mu * dt
INIT X = 1
INFLOWS: mu = X * k
k = 0.1

so you have to rewrite them as differential equations:

mu = X * k
dX/dt = mu

and very similar in R:

mu <- X * k
dX <- mu

Depending on your implementation, parameters may be either constants 
(circle symbol) like the "k" above or hard-coded (and therefore 
"hidden"). How large is your model?

 > Thank you very much for you time, and I hope to hear back from you
 > soon.
 > -Tyler Gibson

Hope it helps

Thomas P.

## Here is an example implementation using the simecol-package.
## It is also possible in the "plain style" according to the
## examples given in package deSolve.


growth <- new("odeModel",
   main = function(t, init, parms) {
     with(as.list(c(init, parms)), {
       mu <- X * k
       dX <- mu
   init = c(X = 1),
   parms = c(k = 0.1),
   times = seq(0, 10, 0.1),
   solver = "lsoda"

growth <- sim(growth)

More information about the R-help mailing list