The mxData function creates MxData objects, which can be used as arguments in MxModel objects. The observed argument may take either a data frame or a matrix, which is then described with the type argument. Data types describe compatibility and usage with expectation functions in MxModel objects. Four different data types are supported (a fifth, sscp, is not yet implemented):
- raw
- The contents of the observed argument are treated as raw data. Missing values are permitted and must be designated as the system missing value. The means and numObs arguments cannot be specified, as the means argument is not relevant and the numObs argument is automatically populated with the number of rows in the data. Data of this type may use fit functions such as mxFitFunctionML function in MxModel objects, which will automatically use covariance estimation under full-information maximum likelihood for this data type.
covThe contents of the observed argument are treated as a covariance matrix. The means argument is not required, but may be included for estimations involving means. The numObs argument is required, which should reflect the number of observations or rows in the data described by the covariance matrix. Data of this type may use the fit functions such as mxFitFunctionML, depending on the specified model.
corThe contents of the observed argument are treated as a correlation matrix. The means argument is not required, but may be included for estimations involving means. The numObs argument is required, which should reflect the number of observations or rows in the data described by the covariance matrix. Data of this type may use the fit functions such as mxFitFunctionML functions, depending on the specified model.
acovThe best way to have data of the type is to use the mxDataWLS function. The contents of the observed argument are treated as the polychoric correlation matrix of the ordinal variables. The means argument is not required, but may be included for estimations involving means. The thresholds argument is not required, but may be included for estimation involving thresholds and ordinal variables. The numObs argument is required, which should reflect the number of observations or rows in the data described by the polychoric correlation matrix. Data of this type almost certainly use the mxFitFunctionWLS function, but may depend on the specified model.
MxData objects may not be included in MxAlgebra objects or use the mxFitFunctionAlgebra function. If these capabilities are desired, data should be appropriately input or transformed using the mxMatrix and mxAlgebra functions.
While column names are stored in the observed slot of MxData objects, these names are not recognized as variable names in MxPath objects. Variable names must be specified using the manifestVars argument of the mxModel function prior to use in MxPath objects.
The mxData function does not currently place restrictions on the size, shape, or symmetry of matrices input into the observed argument. While it is possible to specify MxData objects as covariance or correlation matrices that do not have the properties commonly associated with these matrices, failure to correctly specify these matrices will likely lead to problems in model estimation.
OpenMx uses the names of variables to map them onto the expectation functions and other elements associated with your model. For data.frames, ensure you have set the names(). For matrices set names using, for instance, row.names=c(your, columns). Covariance and correlation matrices need to have both the row and column names set and these must be identical, for instance by using dimnames=list(varNames, varNames).
When a primary key is provided, sorting is disabled. Otherwise, sort defaults to TRUE.