mxData {OpenMx} | R Documentation |

This function creates a new MxData object.

mxData(observed, type, means = NA, numObs = NA)

`observed` |
A matrix or data.frame which provides data to the MxData object. |

`type` |
A character string defining the type of data in the ‘observed’ argument. Must be one of “raw”, “cov”, “cor”, or “sscp”. |

`means` |
An optional vector of means for use when ‘type’ is “cov”, or “cor”. |

`numObs` |
The number of observations in the data supplied in the ‘observed’ argument. Required unless ‘type’ equals “raw”. |

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 objective functions in MxModel objects. Four different data types are supported:

- 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 must use the mxFIMLObjective function as its objective function in MxModel objects, which deals with covariance estimation under full-information maximum likelihood.
- cov
- The 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 mxMLObjective, or mxRAMObjective functions, depending on the specified model.
- cor
- The 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 mxMLObjective, or mxRAMObjective functions, depending on the specified model.
- sscp
- The contents of the ‘observed’ argument are treated as a sums-of-squares and cross-products matrix. The ‘means’ argument is not used. 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 mxMLObjective, or mxRAMObjective functions, depending on the specified model.

MxData objects may not be included in MxAlgebra objects or use the mxAlgebraObjective 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, correlation or sscp 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.

Returns a new MxData object.

The OpenMx User's guide can be found at http://openmx.psyc.virginia.edu/documentation.

MxData for the S4 class created by mxData. matrix and data.frame for objects which may be entered as arguments in the ‘observed’ slot. More information about the OpenMx package may be found here.

#Create a covariance matrix covMatrix <- matrix( c(0.77642931, 0.39590663, 0.39590663, 0.49115615), nrow = 2, ncol = 2, byrow = TRUE) #Create an MxData object including that covariance matrix data <- mxData(covMatrix, 'cov', numObs = 100) model <- mxModel(data)

[Package *OpenMx* version 0.1-1 Index]