Saving and Loading a model

No replies
mspiegel's picture
Joined: 07/31/2009

We have been receiving feedback from OpenMx users using save() and save.image() to save the state of a MxModel into a file on disk. There have been problems associated with saving a model from an older version of OpenMx and attempting to load the model into a newer version of OpenMx. save() and save.image() store the internal representation of OpenMx objects, which may change across different versions of OpenMx. Given the resources available to the development team, we have decided to focus our efforts on maintaining backwards compatibility of OpenMx scripts. If you want to inspect a model at some point in the future, then keep a copy of the script used to generate the model.

It has come to our attention that the checkpoint mechanism is currently insufficient to restore the model state subsequent to optimization. To address these shortcomings we will be implementing the following features:

  • Using mxRun(model, checkpoint = TRUE) will append a line to the checkpoint file with the free parameter values at the conclusion of the optimization.
  • Using mxRun(model, checkpoint = TRUE) will save any expensive computations that are performed at the conclusion of optimization (such as the values of the calculated hessians, the confidence intervals, etc.) to a file.
  • A new function mxSave(model, filename) will be implemented as the complement of mxRestore(model, filename). The mxSave() function will have the same functionality as mxRun(model, checkpoint = TRUE), except that mxSave() will not run the model.
  • The mxOption("Always Checkpoint") will be available to turn on checkpointing for all models by default.
  • The header for the checkpoint file will identify anonymous free parameters with the string matrixName[row,col].

Even with these features you will be unable to recreate your model if you have not saved the original R script. These features will allow you to use mxRun(model, checkpoint = TRUE) or mxSave() such that you can subsequently use mxRestore() without needing to re-optimize the model. These features will be available in the OpenMx 1.3 series.