The difference between "names=" and an object name

I am confused about the naming of objects within OpenMx and how they are referenced in subsequent statements. Take the example below:

meanMZ ← mxMatrix( type=“Full”, nrow=1, ncol=ntv, free=TRUE, values=svMe, labels=c(“mMZ1”,“mMZ2”), name=“meanMZ” )

Here meanMz is used twice- first as the name of the object, and second in the “name” of the mxMatrix.

What are the rules here?

The first name is just the name of the object. So when you are calling on that name, you are calling on the entire object - if it’s a matrix like in your example, then you are calling all the information related to the matrix: type of matrix, number of rows/cols, values, labels, etc.

The second name (the name= parameter) is the name of the ‘value’ if you will. This is the name you use when performing equations within open mx (the MxAlgebra function for example). It’s how you refer to the estimated content of your matrix.

The matrix name and the parameter name (name=) do not have to be the same. It also doesn’t change anything if they are the same or not (as far as I know). I think whether you use the same names or not is down to personal preference.

1 Like

When using R and OpenMx, there are multiple names that are assigned to an object, as you mention. The distinction between the names relates to which part of the software uses the name.
Let’s take the example that you pasted above (slightly edited to remove arguments that don’t relate to name).

meanG ← mxMatrix( … labels= c(“mMZ1”,“mMZ2”), name=“meanMZ” )

In this example:

meanG is the name that R uses. So if you want to interact with this object in R, to look inside it, to put in into a list with other objects, or to build an OpenMx model in R, etc, then you will need to use the R name.

meanMZ is the OpenMx name. So if you want to use this object in an OpenMx algebra (e.g., mxAlgebra or mxConstraint, etc) then you will need to use this name.

mMZ1 is the label (for twin 1 in this case). This is what OpenMx will report back in summary(). Remember, if you would like to equate to parameters, then you can give them the same label. While labels are not required, they are strongly suggested.

It has become a convention to make the R name and the OpenMx name different, but this can lead to predictable issues if you confuse the two names. If you make them the same, however, it can make trouble shooting (i.e., finding exactly where you are having an issue more complicated).

The other place where names come are used in OpenMx is in building mxModel statements. All models must have names (required). This facilitates multiple group models, nested models, and a range of more complex options.