R: Evaluate Values in a bootstrapped MxModel

mxBootstrapEval {OpenMx} | R Documentation

## Evaluate Values in a bootstrapped MxModel

### Description

This function can be used to evaluate an arbitrary R expression that includes named entities from a MxModel object, or labels from a MxMatrix object.

### Usage

    mxBootstrapEval(expression, model, defvar.row = 1, ...,
     bq=c(.25,.75), method=c('bcbci','quantile'))

    mxBootstrapEvalByName(name, model, defvar.row = 1, ...,
     bq=c(.25,.75), method=c('bcbci','quantile'))

    omxBootstrapEval(expression, model, defvar.row = 1L, ...)

    omxBootstrapEvalCov(expression, model, defvar.row = 1L, ...)

    omxBootstrapEvalByName(name, model, defvar.row=1L, ...)

### Arguments

`expression` | An arbitrary R expression.
`name` | The character name of an object to evaluate.
`model` | The model in which to evaluate the expression.
`defvar.row` | The row number for definition variables when compute=TRUE; defaults to 1. When compute=FALSE, values for definition variables are always taken from the first (i.e., first before any automated sorting is done) row of the raw data.
`...` | Not used. Forces remaining arguments to be specified by name.
`bq` | numeric. A vector of quantiles to be used to summarize bootstrap replication.
`method` | character. One of ‘quantile’ or ‘bcbci’.

### Details

The argument ‘expression’ is an arbitrary R expression. Any named entities that are used within the R expression are translated into their current value from the model. Any labels from the matrices within the model are translated into their current value from the model. Finally the expression is evaluated and the result is returned. To enable debugging, the ‘show’ argument has been provided. The most common mistake when using this function is to include named entities in the model that are identical to R function names. For example, if a model contains a named entity named ‘c’, then the following mxEval call will return an error: `mxEval(c(A, B, C), model)`.

The `mxEvalByName` function is a wrapper around `mxEval` that takes a character instead of an R expression.

The default behavior is to use the ‘bcbci’ `method`, due to its superior theoretical properties.

### Value

`omxBootstrapEval` and `omxBootstrapEvalByName` return the raw matrix of `cvectorize`'d results. `omxBootstrapEvalCov` returns the covariance matrix of the `cvectorize`'d results. `mxBootstrapEval` and `mxBootstrapEvalByName` return the `cvectorize`'d results summarized by `method` at quantiles `bq`.

### References

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

### See Also

mxAlgebra to create algebraic expressions inside your model and mxModel for the model object mxEval looks inside when evaluating. mxBootstrap to create bootstrap data.

### Examples

    library(OpenMx)

    testModel <- mxModel(
      model="testModel",
      mxData(data.frame(weight=1.0, value=1:10), "raw", weight = "weight"),
      mxMatrix("Full", nrow = 1, ncol = 1, values = 1, free=TRUE, name = "A"),
      mxAlgebra(data.weight * filteredDataRow, name = 'rowAlgebra'),
      mxAlgebra((sum(rowResults) - A)^2, name = 'reduceAlgebra'),
      mxFitFunctionRow('rowAlgebra', 'reduceAlgebra', 'value'))

    testModel <- mxRun(testModel)
    testBoot <- mxBootstrap(testModel)
    summary(testBoot)

    mxBootstrapEval(A^2, testBoot)

[Package OpenMx version 2.11.4 Index]