You are here

Revision of Writing Demo Scripts from Sat, 09/19/2009 - 07:04

Revisions allow you to track differences between multiple versions of your content, and revert back to older versions.

Wiki home page

Demo scripts are invaluable for helping others learn OpenMx, and, during development, to test that the integrity of the program is maintained as well as to test new features.

Where to put demos

Demo scripts can be added to the "/trunk/demos/" directory. nb: When adding a file to this directory, please manually update the "00INDEX" file in this directory with the name of the file and a 1-line description of its purpose.

Demo scripts differ from other scripts in that they should verfiy that the results obtained are those returned in original Mx where possible.

Using omxCheckCloseEnough()

omxCloseEnough() simply compares the elements of two compatible arrays, returning TRUE if no pair of elements differ by more than epsilon (the maximum allowed difference)
omxCloseEnough() takes three arguments:

   omxCheckCloseEnough(a, b, epsilon = 10^(-15))

'a' and 'b' are numeric vectors or matrices, and 'epsilon' is the maximum allowed (absolute?) difference between the elements of 'a' and the elements of 'b'.

In usage, you would typically fill vector a with results from the results of an OpenMx mxRun() statement, while the elements of b will be hard-coded from a comparable Mx run. nb:

For convenience, you can run mx 1.x from OpenMx using the function omxOriginalMx(), which takes two arguments: 'mx.filename' is a string that is the path and name of the mx script to run (relative be found in the directory returned by getwd() ), and 'output.directory' similarly the relative path to the directory where output files will be written.

notes: 'mx' must appear somewhere in your $PATH.
While you can use omxOriginalMx() to get the correct values for omxCloseEnough(). comment this code out in the demo, and hard code the results: We cannot assume that developers and users have installed Mx 1.X.

Comments

Textmate 2 with dropdown select support attached to make this trivial (just type demo and tab)

remove the .txt extension (added to trick the upload filter)

-----------------------------------------------------------------------------

Program: ${1:ExampleDemo}.R

Author: ${2:$TM_FULLNAME}

Date: date +%Y-%m-%d

#

ModelType: ${3:CFA,EFA,ACE,Multilevel,Mixture,Growth Curve,Growth Mixture,Saturated,Locus Likelihood,Log-odds,Joint,Ordinal,Continuous}

DataType: ${4|Time Series,Likert,Twin,Count,Frequencies,Log-odds,Binary,Survey,Personality,Family,Joint,Ordinal,Continuous,Simulated,Clustered|}

Field: ${5|Path model,Behavior Genetics,Genetic Epidemiology,Functional Magnetic Resonance Imaging (FMRI)|}

#

Purpose:

${6:One Factor model to demonstrate style header for demos.}

#

RevisionHistory:

$2 -- date +%Y-%m-%d initial creation

-----------------------------------------------------------------------------