mxBootstrapEval | R Documentation |
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.
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, ...)
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 to use 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 bootstrap quantiles at which to summarize the bootstrap replication. |
method |
character. One of ‘quantile’ or ‘bcbci’. |
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.
nb: ‘bcbci’ stands for ‘bias-corrected bootstrap confidence interval’
The default behavior is to use the ‘bcbci’ method
, due to its superior theoretical properties.
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
.
The OpenMx User's guide can be found at https://openmx.ssri.psu.edu/documentation/.
mxAlgebra to create algebraic expressions inside your model and mxModel for the model object mxEval looks inside when evaluating. mxBootstrap to create bootstrap data.
library(OpenMx)
# make a unit-weighted 10-row data set of values 1 thru 10
myData = mxData(data.frame(weight=1.0, value=1:10), "raw", weight = "weight")
sum(1:10)
# Model sums data$value (sum(1:10)= 55), subtracts "A", squares the result,
# and tries to minimize this (achieved by setting A=55)
testModel = mxModel(model = "testModel1", myData,
mxMatrix(name = "A", "Full", nrow = 1, ncol = 1, values = 1, free=TRUE),
# nb: filteredDataRow is an auto-generated matrix of
# non-missing data from the present row.
# This is placed into the "rowResults" matrix (also auto-generated)
mxAlgebra(name = "rowAlg", data.weight * filteredDataRow),
# Algebra to turn the rowResults into a single number
mxAlgebra(name = "reduceAlg", (sum(rowResults) - A)^2),
mxFitFunctionRow(
rowAlgebra = "rowAlg",
reduceAlgebra = "reduceAlg",
dimnames = "value"
)
# no need for an MxExpectation object when using mxFitFunctionRow
)
testModel = mxRun(testModel) # A is estimated at 55, with SE= 1
testBoot = mxBootstrap(testModel)
summary(testBoot) # A is estimated at 55, with SE= 0
# Let's compute A^2 (55^2 = 3025)
mxBootstrapEval(A^2, testBoot)
# SE 25.0% 75.0%
# [1,] 0 3025 3025
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.