You are here

The OpenMx script in the tutorial does not work

6 posts / 0 new
Last post
mkeller's picture
Offline
Joined: 08/04/2009 - 16:02
The OpenMx script in the tutorial does not work

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

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
hi Mat: hope all is

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

mspiegel's picture
Offline
Joined: 07/31/2009 - 15:24
Could we update

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.

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
yes, good to get rid of those

yes, good to get rid of those misleading elipses

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
a lot of this would go away

a lot of this would go away too if there was a live link to an online copy of the relevant demo/file.R for each demo file: then people would be working on their own full, working copy of the script.

All easy fixes.

mkeller's picture
Offline
Joined: 08/04/2009 - 16:02
Thanks for the help Tim. Yes,

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.