The OpenMx script in the tutorial does not work

Posted on
Picture of user. mkeller Joined: 08/04/2009
Hi all,

I'm trying to run line-by-line through the tutorial under Documentation -> Quick-Start tutorial (1st page). The "More in-depth Example" does not work. (by the way, it would be helpful to have the tutorial be self-contained (i.e., no need for external data) so that anyone can actually run it. So simulation of twin data would be much more useful than calling up some old 'myTwinData.txt' file that can't be downloaded).

Anyway, I simulated my own twin data and tried running through the example. At the twinSatModel step, I run into problems:

> twinSatModel <- mxModel("twinSat",
+ mxModel("MZ", .... ),
+ mxModel("DZ", .... ),
+ mxAlgebra(MZ.objective + DZ.objective, name="twin"),
+ mxAlgebraObjective("twin"))
Error in mxModel("MZ", ....) : object '....' not found

I can take away the "...." and it runs but it chokes on the 2nd line after this:
> twinSatModel <- mxModel("twinSat",
+ mxModel("MZ" ),
+ mxModel("DZ"),
+ mxAlgebra(MZ.objective + DZ.objective, name="twin"),
+ mxAlgebraObjective("twin"))

> twinSatFit <- mxModel(twinSatModel)

> ExpMeanMZ <- mxEval(MZ.expMeanMZ, twinSatFit)
Error in eval(expr, envir, enclos) : object 'MZ.expMeanMZ' not found

Also, should this line be using the mxModel command or the mxRun command?:
> twinSatFit <- mxModel(twinSatModel)

In general, a tutorial is a great idea, but I've encountered several errors in the one posted in addition to those above, which is making progress in learning quite laborious. Of course, this is to be expected in a pre-beta version of software, but would it be possible for someone to run through the code in the tutorial as written and make sure that it works?

Help with the above errors (or just a simple ACE code emailed to me) would be very helpful! Thanks!
Matt

Replied on Sun, 09/20/2009 - 17:01
Picture of user. tbates Joined: 07/31/2009

hi Mat: hope all is well!

There are some tickets in on the issues you mention regarding the documentation.

To get started, there are well-commented and self-contained uni- and multi-variate ACE models and a common path model included with the download: best to go there to learn how OpenMx works.

http://openmx.psyc.virginia.edu/wiki/faq-openmx#Where_are_the_example_scripts_and_demo_data_files

Open the relevant .R file in your favorite editor and paste the examples in chunk by chunk so you can catch any errors (there should be none - all those scripts run for me) and also see how OpenMx builds up a model piece by piece.

Let us know if you have trouble.

t

Replied on Sun, 09/20/2009 - 17:14
Picture of user. mspiegel Joined: 07/31/2009

In reply to by tbates

Could we update http://openmx.psyc.virginia.edu/docs/OpenMx/latest/Introduction.html#more-in-depth-example by adding "mzModel <-" and "dzModel <- " in those places where the submodels are declared, and then replace 'mxModel("MZ", .... ), mxModel("DZ", .... )' with 'mzModel, dzModel'? I know this would break with our convention of explicitly enumerating all of a model's components. But then again, that convention is what is causing this confusion, since we would like to give examples with short code blocks. We end up with users copy/pasting code that doesn't work. I leave the final decision to the documentation team.
Replied on Sun, 09/20/2009 - 17:43
Picture of user. mkeller Joined: 08/04/2009

In reply to by tbates

Thanks for the help Tim. Yes, I agree that it would be nice to just have a working .R file linked to work through. That's how I learn best at least. Also, I see now that the data is actually in the OpenMx package (i.e., by calling data(twinData) ), so disregard my call to simulate data at the start of scripts.