Learn R Programming

umx (version 1.9.1)

umxSuperModel: Make a multi-group model

Description

umxSuperModel takes 1 or more models and wraps them in a supermodel with a mxFitFunctionMultigroup fit function that minimises the sum of the fits of the sub-models.

Usage

umxSuperModel(name = "top", ..., autoRun = TRUE)

Arguments

name

The name for the container model (default = 'top')

...

Models forming the multiple groups contained in the supermodel.

autoRun

Whether to run the supermodel before returning it (default = TRUE)

Value

- mxModel

References

- https://github.com/tbates/umx, https://tbates.github.io

See Also

- mxFitFunctionMultigroup, umxRAM

Other Core Modelling Functions: plot.MxModel, umxDiagnose, umxLatent, umxMatrix, umxPath, umxRAM, umxReduceACE, umxReduceGxE, umxRun, umx

Examples

Run this code
# NOT RUN {
library(umx)
# Simulate some data
tmp = umx_make_TwinData(nMZpairs = 100, nDZpairs = 150, 
		AA = 0, CC = .4, EE = .6, varNames = c("x", "y"))
# Group 1
ds1 = tmp[[1]];
# Group 2
ds2 = tmp[[2]];
cov(ds1); cov(ds2)

manifests = names(ds1)
# Model 1
m1 <- mxModel("m1", type = "RAM",manifestVars = manifests,
	mxPath("x", to = "y", labels = "beta"),
	mxPath(manifests, arrows = 2, labels=c("Var_x", "Resid_y_grp1")),
	mxPath("one", to = manifests, labels=c("Mean_x", "Mean_y")),
	mxData(cov(ds1), type = "cov", numObs = nrow(ds1), means=colMeans(ds1))
)
# Model 2
m2 <- mxModel("m2", type = "RAM",manifestVars = manifests,
	mxPath("x", to = "y", labels = "beta"),
	mxPath(manifests, arrows = 2, labels=c("Var_x", "Resid_y_grp2")),
	mxPath("one", to = manifests, labels=c("Mean_x", "Mean_y")),
	mxData(cov(ds1), type = "cov", numObs = nrow(ds2), means=colMeans(ds2))
)
# Place m1 and m2 into a supermodel, and autoRun it
m3 = umxSuperModel('top', m1, m2)
summary(m3)
# }

Run the code above in your browser using DataLab