# 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:

myModel <- mxModel( blah blah blah ) # define a FIML model but don't put any data in it.
myParameters <- matrix(NA, 100, 5) # suppose 100 files and you want to save 5 parameters from each run


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

for (i in 1:100) {
tempFileName <- paste("myFile",i,".dat", sep=0) # Suppose files name myFile1.dat, myFile2.dat, etc.