mxAlgebra {OpenMx} | R Documentation |

This function creates a new MxAlgebra object.

mxAlgebra(expression, name = NA, dimnames = NA)

`expression` |
An R expression of matrix operators and matrix functions. |

`name` |
An optional character string indicating the name of the object. |

`dimnames` |
list. The dimnames attribute for the algebra: a list of length 2 giving the row and column names respectively. An empty list is treated as NULL, and a list of length one as row names. The list can be named, and the list names will be used as names for the dimensions. |

The mxAlgebra function is used to create algebraic expressions that operate on one or more MxMatrix objects. To evaluate an MxAlgebra object, it must be placed in an MxModel object, along with all referenced `MxMatrix`

objects and the `mxAlgebraObjective`

function. The `mxAlgebraObjective`

function must reference the `MxAlgebra`

object to be evaluated by name.

The following operations are supported in mxAlgebra:

`solve()`

- Inversion
`t()`

- Transposition
`+`

- Addition
`-`

- Subtraction
`%*%`

- Matrix Multiplication
`*`

- Element or dot product
`/`

- Element division
`%x%`

- Kronecker product
`%&%`

- Quadratic product
`cbind()`

- Horizontal adhesion
`rbind()`

- Vertical adhesion

The following functions are supported in mxAlgebra:

`sum(diag())`

- Trace
`det()`

- Determinant
`sum()`

- Sum
`max()`

- Maximum
`min()`

- Min
`abs()`

- Absolute value
`sin()`

- Sine
`sinh()`

- Hyperbolic sine
`cos()`

- Cosine
`cosh()`

- Hyperbolic cosine
`tan()`

- Tangent
`tanh()`

- Hyperbolic tangent
`exp()`

- Exponent
`log()`

- Natural Logarithm
`sqrt()`

- Square root
`diag()`

- Diagonal to vector or vector to diagonal, depending on input
`c(t()`

- Matrix to vector (by row; returns vector)
`c()`

- Matrix to vector (by column)
`vech()`

- Lower triangular matrix to vector (requires MCMCpack package)
`cov2cor()`

- Standardize matrix
`Re(eigen(A, only.values=TRUE)$values)`

- Real eigenvalues (for matrix A)
`Re(eigen(A, )$values)`

- Real eigenvectors (for matrix A)
`Im(eigen(A, only.values=TRUE)$values)`

- Imanginary eigenvalues (for matrix A)
`Im(eigen(A, )$values)`

- Imanginary eigenvectors (for matrix A)
`colMeans()`

- Mean of columns
`var()`

- Covariance of columns

Returns a new MxAlgebra object.

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

MxAlgebra for the S4 class created by mxAlgebra. MxMatrix and mxMatrix for objects which may be entered in the 'expression' argument and the function that creates them. More information about the OpenMx package may be found here.

A <- mxMatrix("Full", nrow = 3, ncol = 3, values=2, name = "A") # Simple example: algebra B simply evaluates to the matrix A B <- mxAlgebra(A, name = "B") # Compute A + B C <- mxAlgebra(A + B, name = "C") # Compute sin(C) D <- mxAlgebra(sin(C), name = "D") # Make a model and evaluate the mxAlgebra object 'D' A <- mxMatrix("Full", nrow = 3, ncol = 3, values=2, name = "A") model <- mxModel("AlgebraExample", A, B, C, D ) fit <- mxRun(model) mxEval(D, fit)

[Package *OpenMx* version 0.2.3-1006 Index]