You are here

Running models multiple times with different data or parameters

Primary tabs

R allows you to create loops so that you can do things such as read in files one at a time and run a model on each of them.

For a given model such as myModel below, these tasks involve running the model repeatedly with different data or settings, and storing some of the output.

One approach is to define a model, and an object to store the results:


Then simply write a for-loop in R to call the model repeatedly

for (i in 1:100) {

After running this, the matrix, myParameters, contains just the parameters you wanted after 100 runs of OpenMx.

Multiple imputation and other resampling ideas

R has several helpful packages supporting this type of processing including 'pan', 'kmi', 'mitools', and 'MICE' . Search for "multiple imputation" on under the "packages" link