Learn R Programming

umx (version 1.4.0)

umxModify: umxModify

Description

umxModify allows you to modify, re-run and summarize an mxModel, all in one line of script. You can add paths, or other model elements, set paths or drop them. As an example, this one-liner drops a path labelled "Cs", and returns the updated model:

Usage

umxModify(lastFit, update = NULL, regex = FALSE, free = FALSE, value = 0, freeToStart = NA, name = NULL, verbose = FALSE, intervals = FALSE, comparison = FALSE, dropList = "deprecated")

Arguments

lastFit
The mxModel you wish to update and run.
update
What to update before re-running. Can be a list of labels, a regular expression (set regex = TRUE) or an object such as mxCI etc.
regex
Whether or not update is a regular expression (defaults to FALSE). If you provide a string, it over-rides the contents of update, and sets regex to TRUE.
free
The state to set "free" to for the parameters whose labels you specify (defaults to free = FALSE, i.e., fixed)
value
The value to set the parameters whose labels you specify too (defaults to 0)
freeToStart
Whether to update parameters based on their current free-state. free = c(TRUE, FALSE, NA), (defaults to NA - i.e, not checked)
name
The name for the new model
verbose
How much feedback to give
intervals
Whether to run confidence intervals (see mxRun)
comparison
Whether to run umxCompare() after umxRun
dropList
(deprecated: use 'update' instead.

Value

- mxModel

Details

fit2 = umxModify(fit1, update = "Cs", name = "newModelName", comparison = TRUE)

Regular expressions are a powerful feature: they let you drop collections of paths by matching patterns fit2 = umxModify(fit1, regex = "C[sr]", name = "drop_Cs_andCr", comparison = TRUE)

If you are just starting out, you might find it easier to be more explicit. Like this:

fit2 = omxSetParameters(fit1, labels = "Cs", values = 0, free = FALSE, name = "newModelName") fit2 = mxRun(fit2) summary(fit2)

References

- http://github.com/tbates/umx

See Also

Other Model Building Functions: umxDiagnose, umxLabel, umxLatent, umxMatrix, umxPath, umxRAM2Ordinal, umxRAM, umxRun, umxThresholdMatrix, umxValues, umx_fix_first_loadings, umx_fix_latents, umx

Examples

Run this code
require(umx)
data(demoOneFactor)
latents  = c("G")
manifests = names(demoOneFactor)
m1 <- mxModel("One Factor", type = "RAM", 
	manifestVars = manifests, latentVars = latents, 
	mxPath(from = latents, to = manifests),
	mxPath(from = manifests, arrows = 2),
	mxPath(from = latents, arrows = 2, free = FALSE, values = 1.0),
	mxData(cov(demoOneFactor), type = "cov", numObs = 500)
)
m1 = umxRun(m1, setLabels = TRUE, setValues = TRUE)
m2 = umxModify(m1, update = "G_to_x1", name = "drop_X1")
umxSummary(m2); umxCompare(m1, m2)
# 1-line version including comparison
m2 = umxModify(m1, update = "G_to_x1", name = "drop_X1", comparison = TRUE)
m2 = umxModify(m1, update = "^G_to_x[3-5]", regex = TRUE, name = "no_G_to_x3_5", comp = TRUE)
m2 = umxModify(m1, regex = "^G_to_x[3-5]", name = "no_G_to_x3_5") # same, but shorter
m2 = umxModify(m1, update = "G_to_x1", value = .2, name = "fix_G_x1_at_point2", comp = TRUE)
m3 = umxModify(m2, update = "G_to_x1", free = TRUE, name = "free_G_x1_again", comparison = TRUE)

Run the code above in your browser using DataLab