This function creates a new MxAlgebra object.
1 2 3 4
An R expression of OpenMx-supported matrix operators and matrix functions.
An optional character string indicating the name of the object.
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.
Not used. Forces other arguments to be specified by name.
Deprecated. Use the ‘recompute’ argument instead.
The name of the column in current model's raw data that is used as a foreign key to match against the primary key in the joinModel's raw data.
The name of the model that this matrix joins against.
For values greater than zero, enable runtime diagnostics.
a matrix. When
If ‘onDemand’, this algebra will not be recomputed automatically when things it depends on change. mxComputeOnce can be used to force it to recompute.
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
objects and the
mxFitFunctionAlgebra function must reference by name the
MxAlgebra object to be evaluated.
Note that, if the result for an MxAlgebra depends upon one or more "definition variables" (see
mxMatrix()), then the value returned after the call to
mxRun() will be computed using the values of those definition variables in the first (i.e., first before any automated sorting is done) row of the raw dataset.
The following operators and functions are supported in mxAlgebra:
Quadratic product: pre- and post-multiply B by A and its transpose t(A), i.e: A
%&% B == A
Convert covariance matrix to correlation matrix
Matrix column sums as a column vector
Matrix row sums as a column vector
Inverse hyperbolic sine
Inverse hyperbolic cosine
Inverse hyperbolic tangent
Robust natural logarithm
Standard-normal quantile from log probabilities
Compute log(gamma(x+1)) accurately for small x
Eigenvalues of a square matrix. Usage: eigenval(x); eigenvec(x); ieigenval(x); ieigenvec(x)
Vectorize by row
Vectorize by column
Inverse strict half-vectorization
Create matrix from a diagonal vector (similar to diag)
Extract diagonal from matrix (similar to diag)
Multivariate Normal Integration
All cells Multivariate Normal Integration
Perform unary negation on a matrix
Perform binary and on two matrices
Perform binary or on two matrices
Perform binary greater on two matrices
Perform binary less than on two matrices
Perform binary equals to (within a specified epsilon) on two matrices
Filter rows from a matrix
Filter columns from a matrix
Filter rows and columns from a matrix
Evaluate an algebra on an abscissa grid and collect column results
solve is used on an uninvertible square matrix in R, via
mxEval(), it will fail with an error will; if
solve is used on an uninvertible square matrix during
runtime, it will fail silently.
mxRobustLog is the same as
log except that it returns -745
instead of -Inf for an argument of 0. The value -745 is less than
log(4.94066e-324), a good approximation of negative infinity because the
log of any number represented as a double will be of smaller absolute
There are also several multi-argument functions usable in MxAlgebras, which apply themselves elementwise to the matrix provided as their first argument. These functions have slightly different usage from their R counterparts. Their result is always a matrix with the same dimensions as that provided for their first argument. Values must be provided for ALL arguments of these functions, in order. Provide zeroes as logical values of
FALSE, and non-zero numerical values as logical values of
TRUE. For most of these functions, OpenMx cycles over values of arguments other than the first, by column (i.e., in column-major order), to the length of the first argument. Notable exceptions are the
lower.tail arguments to probability-distribution-related functions, for which only the [1,1] element is used. It is recommended that all arguments after the first be either (1) scalars, or (2) matrices with the same dimensions as the first argument.
|| || Note that OpenMx does cycle over the elements of
|| || The algorithm for the non-central beta distribution is used for non-negative values of
|| || Values of
|| || The algorithm for the non-central chi-square distribution is used for non-negative values of
|| || Values of
|| || Exactly one of arguments
|| || Arguments are handled as with
Returns a new MxAlgebra object.
The OpenMx User's guide can be found at http://openmx.ssri.psu.edu/documentation.
MxAlgebra for the S4 class created by mxAlgebra. mxFitFunctionAlgebra for an objective function which takes an MxAlgebra or MxMatrix object as the function to be minimized.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
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(model="AlgebraExample", A, B, C, D ) fit <- mxRun(model) mxEval(D, fit) # Numbers in mxAlgebras are upgraded to 1x1 matrices # Example of Kronecker powering (%^%) and multiplication (%*%) A <- mxMatrix(type="Full", nrow=3, ncol=3, value=c(1:9), name="A") m1 <- mxModel(model="kron", A, mxAlgebra(A %^% 2, name="KroneckerPower")) mxRun(m1)$KroneckerPower # Running kron # mxAlgebra 'KroneckerPower' # $formula: A %^% 2 # $result: # [,1] [,2] [,3] # [1,] 1 16 49 # [2,] 4 25 64 # [3,] 9 36 81
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.