You are here

mxalgebra-help

Primary tabs

Wiki home page

Usage

mxAlgebra(expression, name = NA, dimnames = NA)
mxAlgebra() allows you create algebraic expressions based on one or more MxMatrix objects.
Legal functions within an algebra are described here.

    A <- mxMatrix("Full", nrow = 3, ncol = 3, values=1:9, name = "A")
    B <- mxAlgebra(A, name = "B")
    C <- mxAlgebra(A + B, name = "C")
    D <- mxAlgebra(sin(C), name = "D")

    model <- mxModel("AlgebraExample", A, B, C, D )
    fit   <- mxRun(model)

    mxEval(AlgebraExample.D, fit)
    #           [,1]       [,2]       [,3]
    # [1,]  0.9092974  0.9893582  0.9906074
    # [2,] -0.7568025 -0.5440211 -0.2879033
    # [3,] -0.2794155 -0.5365729 -0.7509872

Gotchas

A common misunderstanding is to call mxAlgebra() expecting it to be evaluated without subsequently being placed in a model and run as above. To evaluate an MxAlgebra, it must be placed in an MxModel (along with all referenced MxMatrix objects) and run.

Please add material here as you learn... If you have questions not answers, then add those here: That's how a wiki works.