Posts Tagged ‘data’

Using PEST to Calibrate Models

January 14th, 2011 21 comments

There are times when it is helpful to calibrate, or fit, your model to historical data. This capability is not built into the iThink/STELLA program, but it is possible to interface to external programs to accomplish this task. One generally available program to calibrate models is PEST, available freely from In this blog post, I will demonstrate how to calibrate a simple STELLA model using PEST on Windows. Note that this method relies on the Windows command line interface added in version 9.1.2 and will not work on the Macintosh. The export to comma-separated value (CSV) file feature, added in version 9.1.2, is also used.

The model and all files associated with its calibration are available by clicking here.

The Model

The model being used is the simple SIR model first presented in my blog post Limits to Growth. The model is shown again below. There are two parameters: infection rate and recovery rate. Technically, the initial value for the Susceptible stock is also a parameter. However, since this is a conserved system, we can make an excellent guess as to its value and do not need to calibrate it.


The Data Set

We will calibrate this model to two data sets. The first is the number of weekly deaths caused by the Hong Kong flu in New York City over the winter of 1968-1969 (below).


The second is the number of weekly deaths per thousand people in the UK due to the Spanish flu (H1N1) in the winter of 1918-1919 (shown later).

In both cases, I am using the number of deaths as a proxy for the number of people infected, which we do not know. This is reasonable because the number of deaths is directly proportional to the number of infected individuals. If we knew the constant of proportionality, we could multiply the deaths by this constant to get the number of people infected.

Read more…

Imported file not found?

March 6th, 2009 2 comments

We often get calls from customers who have copied a model to another computer and then get the dreaded “…file was not found” message when they open the model.  It may be a missing picture, Excel spreadsheet or some other imported file. When copying a model from one computer to another, you may need to copy more than just the model file.  files2If your model uses other files such as graphics, sounds or spreadsheets you’ll need to package all of them with the model file.

If you have to e-mail your model to isee support, it’s good to know how to package all the necessary files so that we can recreate your setup.

Here’s a list of the files your model may need:

  • Modules (.itt files)
  • Links (Files that a local file hyperlink button points to)
  • Data (Excel and .csv files for import/export)
  • Graphics
  • Sounds
  • Movies

Locate all the associated files in the same place as your model file.

If you have a lot of associated files you can organize them into sub-folders as pictured below:

foldersThe one thing to watch out for is the situation of having one file that is accessed in more than one way.  For instance, an Excel file that is used for importing data but is also accessed via a hyperlink button.  In this case, the Excel file should not be in a sub-folder.  Instead, keep it in the same folder as the model file.

Now you can copy the folder to another computer or flash drive, or burn it to a CD.

If you are going to e-mail the folder, you might want to zip it up so you only have one file to send.

Setting Number of Points in a Graphical Function

February 25th, 2009 No comments

One of the questions I am sometimes asked is, “If I need a specific x-value to appear in my graphical function, how do I determine the number of points required to include that exact point?”  This arises because in a graphical function, the -axis is divided into fixed intervals; the user is only allowed to specify x-min, x-max, and the number of data points.  [If you really need a graphical function with arbitrary (x, y) points, use the LOOKUPXY() built-in function available in version 9.1.2.]

For the following discussion, the range on the x-axis will be needed:

range = x_max – x_min

In all of the examples below, x_min = 3.000 and x_max = 7.000, so the range = 7 – 3 = 4.

For integer values, here is a simple formula that always works:

# of data points = range + 1                                                                                  (1)

For example (using the range above), if the number 6 (an integer) must appear as a point on the x-axis, 4 + 1 = 5 points will be needed.  This divides the ­x-axis into the points 3.0, 4.0, 5.0, 6.0, and 7.0.

Fractional values, however, are more difficult.  In general, if you can isolate the fractional part (and this evenly divides the range), the maximum number of points needed is given by this formula:

Read more…

Save Time Setting up Data Imports

January 27th, 2009 No comments

Setting up an Excel spreadsheet to import data into your model is easy when you’ve got just a few variables but it can get cumbersome when you’ve got lots of variables, especially if some of them are arrayed.

If you want to avoid lots of copying, pasting, and switching back and forth between your model and Excel, we suggest using the export data feature to set up your data import spreadsheet.

Below are a few simple steps that can save you a bunch of time and headache:

Click to expand

Click to expand

  1. In your model, create a Table with all of the variables that you want to import data to.
  2. From the Edit menu, choose Export Data. The Export Data dialog will appear.
  3. Under “Export Type”, select One Time.
  4. Under “Export Data Source”, select Export variables in table and select the table that you created in Step 1.
  5. Under “Interval”, select One set of values.
  6. Under “Export Destination”, Browse to an empty Excel file and Worksheet Name that you have created for your data import.
  7. Select the “Data Orientation” that you prefer.
  8. Click OK.

Voila! Your import sheet should be all set to enter data values for each of the variable names AND it will be in the correct format.

Categories: Modeling Tips Tags: , , ,