You are here

Deprecation of mxPath(all = TRUE) argument

Primary tabs

In OpenMx 1.2 we will be eliminating the all = TRUE argument from the mxPath() function. This argument will be replaced with a new argument to mxPath() that will be more explicit about which paths are constructed and which paths are not constructed. You can follow the discussion of the new argument on the following forum thread.

In the meantime, you will want to be aware of certain behaviors of all = TRUE that most users find unexpected. The all = TRUE argument creates all pairs of pairs between the 'from' and 'to' fields. When bidirectional arrows are specified (arrows = 2), then the path (a,b) is identical to the path (b,a). However, mxPath() generates both the (a,b) path and the (b,a) path, and overwrites the earlier path with the later path. This behavior is especially problematical if you want to assign distinct values, labels, free parameter designations, etc. to your paths.

Here is a concrete example. Suppose I want to create the following model.

I try creating it using the following R code:

lVars <- c('a', 'b')
freeParams <- c('p1', 'p2', 'p3')

model <- mxModel('model', type = 'RAM',
   latentVars = lVars,
   mxPath(from = lVars, to = lVars, arrows = 2, 
      all = TRUE, labels = freeParams))

But this code generates the model:

What happened here? The explanation: When the mxPath() function is called with all = TRUE, it will generate n x m paths, where n is the length of 'from' argument and 'm' is the length of the 'to' argument. Keep in mind that when a path is created, it will clobber any existing path that has the same 'from', 'to', and number of arrows. In the case of symmetric paths, the 'from' and 'to' arguments can be switched with impunity. So the following paths are created:

From To Label
a a p1
a b p2
b a p3
b b p1

In order to get the desired paths, I would need to call:

model <- mxModel('model', type = 'RAM',
   latentVars = lVars,
   mxPath(from = lVars, to = lVars, arrows = 2, 
      all = TRUE, labels = c('p1', 'p2', 'p2', 'p3'))