Quickly create, run, and report structural equation and twin models. See '?umx' for help, and umx_open_CRAN_page("umx") for NEWS.
umx is a structural equation modeling package designed to make SEM easier, from building, to modifying and reporting.
It includes high-level functions for complex models such as multi-group twin models, as well as for graphical model output.
Grab it from CRAN with
install.packages("umx")library(umx)?umx
Most functions have extensive and practical examples (even figures for the twin models): so USE THE HELP :-).
See what is on offer with '?umx'. There are online tutorials at tbates.github.io.
umx
stands for "user" OpenMx functions. It provides over 100 functions from high-level umxRAM and umxPath functions that make Structural Equation Modeling in R straightforward, to low-level functions to automate activities such as labelling, setting start values etc.,
Some highlights include:
umxRAM()
# mxModel with smart data =
parameter, no need to specify type = "RAM", + auto-discovery of manifests and latents from the paths you writeumxPath()
# mxPath on steroids: one-word settings to set var
, mean
cov
, fixedAt
'v.m.' = and more. Great time-saver!umxSummary(model)
# A model fit designed for journal reporting (Χ², p, CFI, TLI, & RMSEA). Optionally show the path loadingsplot(model, std=T, digits = 3, file = "name")
# Graphical, editable output of model in your browser!umxModify()
*# Modify and run a model. You can add objects, drop or add paths, including by regular-expression label matching), re-name the model, re-run, and even return the comparison. All in 1 line *parameters(m1, "below", .1, pattern="_to_"))
# A powerful assistant to get labels from a model (e.g. all 'to' params, below .1 in value)umxACE()
# Twin ACE modeling with aplomb paths are labeled! Works with plot()
and umxSummary
!umxCP()
, umxIP()
, umxGxE()
, umxCP()
…umx_set_cores()
umx_set_optimizer()
umx_time(model)
# Report the time taken by a model in a compact programable formatumxHcor(data, use = "pairwise.complete.obs")
# Compute appropriate pair-wise correlations for mixed data types.Feel free to use, and submit code and requests via Github. Tell your friends! Publish more good science :-)
For thrill-seekers and collaborators only: the bleeding-edge development version is here:
install.packages("devtools")library("devtools")install_github("tbates/umx")library("umx")?umx
umxSimplex
umxACEv
supports WLS, UWLS, DWLS modelsumxCP
supports WLS, UWLS, DWLS modelsumxLav2RAM
xmu_lavaan_process_group
xmu_clean_label
plot
will get ability to opt paths out of constraints.citation("umx")
Our paper on umx is out!
?umxExamples
All the code from Bates, Neale and Maes (2019).umxSexLim
multivariate sex-limitation working.umxSexLim
Gained nonlinear, linear, and homogeneity modesumxSexLim
Gained examples.umxRAM
supports WLS, UWLS, DWLS models!umxACE
supports WLS, UWLS, DWLS models!umxPlotCP
Supports CIs on the diagram!umx_make_top_twin_models
increases the robustness and improve-ability of all twin scripts.umx_dot_define_shapes
builds the latents and manifest shape definitions (should be xmu_)xmu_check_variance
checks data for minVar (default > 0.1) and comparable scale for variables (maxVarRatio default = 500)
umx_set_data_variance_check
get/set variance tolerance.umx
is checked on travis.plot
allows user control over splines, as well as max, min, same positioning.xmu_dot_move_ranks
.xmu_dot_rank_string
.namez
options for collapse get easier to short-cut names.data(Fischbein_wt)
weight of 66 females record over six 6-month intervals (from Fischbein (1977) weight data).umxRAM2
Beginning support for lavaan syntax strings.type
(WLS) added to twin models...umxValues
to work more reliably with data with no means.umx_rename
Didn't give correct values when test = TRUE
for non-grep searches (drop NAs)umxSexLim
match.arg tryHard
selVars
vs. selDVs across different functions (search for "# New-style build-block" to see these changesumxSuperModel
can take a list of models.tryHard
- allow "yes" for default mxTryHard across all twin and RAM models.umxPlotCP
revamped - now not dependent on labels! (old function now umxPlotCPold
)xmu_model_needs_means
umxDescribeDataWLS
to check whether the form of WLS requested will have means of not.umx_make
: use check_win_devel; setwd for release; spellingumx_dot_mat2dot
add model
, toLabel
and fromLabel
+ fromType
& toType
umx_dot_mat2dot
examplexmu_safe_run_summary
now copes with warnings in models, summary, compare etc. (as it should have)umxModify
now supports find and replace labels with grep (not just find with grep and set free/value)xmu_assemble_twin_supermodel
no longer take bVector (uses existence of weights instead)umxModify
now obeys verbose
optionumx_time
reports % change between model timesumIP
helpumx_make
now supports quick-make as defaulttmx_show
printing.umx_score_scale
help and examples.umxModify
now supports find and replace labels with grep (not just find with grep and set free/value).umxModify
now obeys verbose.umxValues
and elsewhere more robust to new data types.umx_read_lower
examples and input checking.umx_cell_is_on
now has lower and upper triangle with or without diagonal includedumx_dot_mat2dot
now can get parameter values with CIsumxRAM
feedback when no data providedxmu_make_top_twin
lose "models" for shorter name.tmx_show
(was umx_show
- it is mostly a teaching functionumx_dot_define_shapes
umx_dot_rank
umx_mat2dot
--> umx_dot_mat2dot
umx_APA_model_CI
--> xmu_get_CI
umx_add_variances
old function not used and not very safe.thresholds
option from several functions (always doing deviation-based, WLS isn't thresholds, and left-censored will be implemented differently)umxSummarizeTwinData
to create summary tables for papers using twin Data.umxRAM
: support definition variables to some extent in umxRAM.umxMatrix
advice user when they specify umxMatrix("me", 1,1)
.umxModify
nicer free-parameter report as default output with no changes requested (calls parameters).umxRAM
preserve definition variables in data.plot
strip_zero more reliable.plot
dropped deprecated showMeans and showFixed from plot after 3 years (use means=
and fixed =
).umx_scale_wide_twin_data
dropped support for deprecated suffix parameter.suffix
as a synonym for sep
removed after 3-years of deprecation warnings.umxSummary
for ACEv
models: CI now works - (was 'a' not 'A').xmu_safe_run_summary
Runs a model safely, optionally summarizing and comparing it to a base model.tryHard
as a parameter!!autoRun
option in more places.plot
functions now have strip_zero
option (default = strip leading zeroes from parameter estimates)umx_standardize_ACEv
now working!xmu_safe_run_summary
so even bad models are returned for the user to diagnose them.umxRAM
now labels paths when no data are provided (simulation of sketch modes).umx_score_scale
can cope with a single item.xmu_safe_run_summary
don't error on code red non-run models.xmu_twin_check
tells user how to rename selVars and sep when sep is not provided, but is enforced.umx_as_numeric
allows user to select which columns to convert.umxSimplex
start values now flexible and robust (was hard coded for 4-times).xmu_simplex_corner
Takes a full values list (not just 1).umxAPA
uses .Last.value
as default input if none provided.umx_make
supports what = "rhub"
.umxlong2wide
now allows user to retain only desired twin IDs.xmu_mean_var_starts
uses "expMean_" as the name for means cells (was "mean").xmu_safe_run_summary
don't return bVector (already available)umxACE
help diagrams improved with clearer ACE_matrix picture.umxRAM
help gained an example of sketch-mode and diagram.umx_scale
help file improvedxmu_make_mxData
function to make mxData functions out of dataframes (and also drop variables from cov/cor dataframes.plot
s.umxCompare
gains ability to output Weight AIC conditional model probabilities! h/t @mNivardumxReduce
returns AIC weight-based probability of being best model.umxReduce.MxModelGxE
returns best model (invisibly).umxReduce
for GxE, don't run no-A and no-C models with moderation in place.namez
given a list of models will return the names of each.namez
allow global replace.umx_lower2full
can now take a data.frame.umx_aggregate
can now open tables in a web browser.install.OpenMx
can now install a package file if selected in the Finder (MacOS only)install.OpenMx
now works with windows.umx_print
more robust to non table input.xmu_make_mxdata
more robust to non dataframe input.umx_apply
robustness.umx_simplex_corner
can take a numeric to set matrix size.umx_long2wide
warn if twinID (order) has too many levels; improved help; @mdumxAPA
test parameter had no effect.umxSexLim
now works for univariate tests (thanks to Michael Zakharin for reporting!)umxSummary
Corrected Chi^2 df for RAM models.umxCP
handles ordinal, continuous and binary data
umxCPold
umxCPplot
re-written to allow arbitrary labels and correlated factors.umx_set_optimization_options
function to set "mvnRelEps" tolerances which impact, especially, ordinal model.umx_is_class
reports classes if not given a set of classes to checkumx_scale(verbose=TRUE)
now lists the vars it didn't touch as well as those it didn't (also formatted better)umx_make_TwinData
can set mean and SD of dataumx_simplex_corner
can take a numeric to set matrix sizeumx_standardize_CP
was ignoring existing CIsumxAlgebra
This appears broken in some circumstances?umx_polychoric
, umx_polypairwise
, and umx_polytriowise
umxSimplex
twin model!
umxSummary
for simplexiqdat
longitudinal IQ twin data for simplex modelingnamez
alias for the ever-useful umx_names
function.umxAlgebra
(just allows name first).install.OpenMx
URLs for NPSOL and travis builds of OpenMxumxSummary.MxModel.ACE
instead of umxSummary
.umxSummary.MxModelACE
# i.e. delete the last period in the name... Sorry :-(parameters
now returns helpful near-match names as suggestions on not finding actual matches.parameters
now handles vectors of regular selectionsumx_print
now handles vectors.umxConfint
"smart" feature to request only free algebra cells for models I understand (umxCP in the first instance)namez
can handle a model summary (accesses names() of the summary)umxGxE
added option to control plot colorsumxPlotCP
can handle >9 manifests issueumxGxE
example improvedxmu_simplex_corner
helper function for simplex modeling.umx_make_sql
improvedumxIP
nFac now allows specifying different numbers of a, c, and e factors!umxACEv
plot works (shows correlated factors).umxACEv
standardize mostly functional.umxEFA
can now take a formula to select variables.umxIP
and CP examples improved (3-variables, GFF data).umxIP
reporting of as
, cs
, es
simplified into compact stack.umxCP
reporting of as
, cs
, es
simplified into compact stack.umxPlotCP
labeling of variables improved (catching more _Tn).umxEFA
reports factor correlation matrix (thanks @ConorDolan)!umxEFA
can return a loadings object.umx_make
not supports spelling check.umxACEv
diagonal now unbounded by default (which is it's whole purpose)umxACEv
got major improvements to help file.umxSummaryCP
got ability to print to html.plot
made more robust to unexpected labels (now that umxModify
can write newlabels
)!umx_names
Added GFF examples.umxSummaryIP
was assuming nFac = 1umxSummary
works with multi-group models!
umxSuperModel
)umxModify
supports multiple find strings and replace strings!umxAPA
supports glm
, more robust input checking.umxEquate
allows vectors of labels.umxGetParameters
has better help.umxHetCor
docs now note is will return a pos-def version if given a cov matrix.umxAPA
now has t-test and glm
examplesumx_install_OpenMx
(use install.OpenMx
)umxSexLim
multivariate twin sex-limitation.umxGxE_biv
bivariate Gene-environment interaction model.umx_make_TwinData
Can now make bivariate moderated twin data.umxGroup
function as part of measurement invariance support.umx_stack
Slightly more powerful version of base stack.umx_array_shift
Shifts an item off the beginning of a list.umxRAM
can take lists of paths as input (contributed by @bwiernik).umxModify
can write newlabels.umxAPA
can back-out an SE if given b and CI.umxReRun
(use umxModify
)suffix
parameter (use sep
instead)umx_parameters(model, "below", .1)
tmx_genotypic_effect
Part of a suite of teaching functions for biometric genetics!?umxRAM
has a sketch mode. just set data
to a list of manifest variable names.umxSuperModel
function to automate multiple-group model creation.?umxACEv
Variance component version of ACE. (beta)?umxACEcov_fixed
Beta1: Handles main effects of covariates in the means of continuous variables.umxModify
can now equate parameters (set master = ), update is slave set of labels.
optimiser
parameter for umxACE and other twin models: Set the optimizer in your model code!umx_is_numeric
boolean check if variables in a dataframe are numeric.umx_is_class
boolean check if variables in a dataframe match a desired class.umx_twin_check
internal function for common input checks.umx_set_plot_file_suffix(c("gv", "dot")
function (to control the filename used for figures)/umxACE
was broken with large cov inputs h/t @NathanGillespie.umxAggregate
now actually supports user functions as input...umxACEv
variance components methodumxPath(Cholesky = )
method: supports labels, bounds, lbound at 0.umxPath(Cholesky = )
method: return one statement instead of a list for clarity.umxACE
and umxReduce.ACE
run intervalsumxReduce
works better with umxACE
models.umxEFA
Supports minManifests
.umxEFA
Works better when returning a single factor score.umxParameters
now supports digits
.umxSummary
"inline" reporting now includes AIC.umx_aggregate
works with factor input/
umx_aggregate(sex_T1 ~ zyg_2grp, data = x)
umx_long2wide
can passalong
variables.umx_wide2long
much more powerfulumx_msg
supports dataframesumxACE
gains ability to set plot format: format = "graphviz" or "DiagrammeR"
umx_set_auto_plot
take TRUE/FALSE as input.umx_names
: added a find and replace option for namesumxRAM
in "sketch mode" now plots models automatically.install.OpenMx
from University of Virginia, travis, or open travis build page.umx_cor
automatically drops non-numeric columns.umxCI
now supports setting interval and one- or two-sided type (h/t @Conor Dolan).R2HTML
to xtable
umxParameters
now supports non-run models?umxAPA
can format lots of things for you: from dataframes to p-values - try it out! Let me know what you'd like.?umx_parameters
function, report parameter estimates, filtering by name and value!
umxParameters
umx_parameters(model, "below", .1, "loading")
?umx_long2wide
: Merges long data on famID, for an unlimited number of individuals in a family (twinIDs).?umx_wide2long
: Takes a wide df (currently limited to 2 per family), & returns a long-format version.umx_MakeTwinData
.xtable
(R2HTML
is abandoned, strips decimals from AIC, etc.)umx_set_auto_plot(FALSE)
.forEach
option in umxPath
. This is a one.headed version of "unique.pairs".autoRun
.umxGxE
plot colors now use the universal ACE -> RGB scheme.umxACEcov
Now tries to detect violations: Age and Sex are good examples.umxACE
.umxACEcov
!umxACEcov
;umx_check_parallel
(1 and n-1);umx_check_parallel
umxReduce
does a much better job reporting automated umxGxE model reduction.umxAPA
handles lme models.umxPrint
error messages.logic.MxModel
now has an Rd page.confint
. OpenMx now supports this, so I dropped it from umx (added alias to umxConfint
).anova
. OpenMx now supports, this so I dropped it from umx
.umx_fix_first_loadings
now skips latents with fixed variance.umxVersion
(returns mxVersion
+ information on umx).umxACE
start values much better for univariate models.umx_make_TwinData
varName
nThresh
to threshold the created variables, and return as mxFactorsempirical
parameter of mvrnormnDZPairs
to get equal numbersumx_make_TwinData
uses variance input. This was ambiguous previously.install.OpenMx
can install UVA parallel, travis latest (on mac) or opening the travis list.
install.OpenMx
had a broken URL, now corrected.umxRAM
can now be used in "sketch" mode, to plot demos without data: just add the list of manifests as a character string to data
.m1 <- umxRAM("test", data = paste0("itemC", 1:4), umxPath(unique.bivariate = paste0("itemC", 1:4)), umxPath(var="X"))plot(m1)
umx_cont_2_quantiles
now allows returning cut points, better examples, level_names
umx_cont_2_quantiles
lowest threshold was emptyumxAPA
now reports mode for factor dataumxLabel
to rename the returned modelsep
is now the preferred separator (synonym for suffix in umxACE, umxCP, umxIP)umxPath
docsumx_cov_diag
to umx_varumx_write_to_clipboard
umx_r_test
umxCP
example for improved compatibility with OpenMx 2.7umxPath
confint
()umxAPA
table outputumx_make
umxPath(a, forms= , arrows = 2)
bugumxRAM
returns invisiblyumx_aggregate
can summarize multiple DVs in a tableumx_aggregate
can return a formatted table (kable = TRUE)umxAPA
returns lower-triangle of data.frame correlations (by default)umxSE
now included in OpenMx 2.7.0!umx_set_plot_format
uses silent = TRUE internally where neededumx_make_TwinData
fix bug in DZ moderator code and A+C computationumx_set
functions now show legal options by defaultumx_set
functions have silent optionumxFitIndices
RMR and SRMR (h/t Brenton Wiernik!)umxMatrix
with default labels and name as 1st parameterumxPath(defn = "def", labels = "data.age")
umxEquate
supports autoRun and compareumx_names
can, as a convenience, take string vectorsumxGetOpenMx
aliased to install.OpenMx
or umx_install_OpenMx
umxFitIndices
additional fit-indices and now automatically computes reference models if needed.umxRAM
remove_unused_manifests no longer updates manifestVars + leaves variable in data by default.plot
"showFixed" deprecated in favor of easier to type "fixed"umxPath
allows unique.pairs
connectionumxRAM
handles suffix labels
umxSummary
to show parameters from first model in multi-group
umx_show_options
to umx_get_options
umx_check_parallel
typoplot
calls from summaryumxRAM
can now build and run Joint Continuous Ordinal models. Ta da!!umx_show_options
function to help users learn the options availableumxACE
can now implement a form of left-censoring.umxThresholdMatrix
can now implement a form of left-censoring.umxRAM
& umxRAM2Ordinal
can turn off reference models computation with refModels = FALSE
;umx_show
can show thresholdsumx_is_MxModel
can take a list: listOK
optionumx_check_parallel
options for row-wise parallel and number of subjectsumx_time
and umx_check_parallel
to work with new S4 list deprecationumxTwoStage
shorter run-time on 2-stage least squaresumxTwoStage
FIML-based Instrumental variable and Mendelian Randomization (beta)umx_make_MR_data
to simulate SNP-based Mendelian randomization data (beta)umx_set_condensed_slots(TRUE|FALSE)
: Get and set matrix compressionumx_get_OpenMx
(download OpenMP/parallel version of OpenMx with NPSOL)umx_cont_2_quantiles(x, nlevels = )
umx_factor
alias to umxFactorplot(resid = "none")
was not suppressing plotting residualsumxFactor
now handles dataframes and allows non-ordered outputumx_CI
more flexible, now allows removing CIs
umx_time
handling of no input argumentsumx_pb_note
better feedback and setupumxModify
- if free is a string, it will be used as input and the found paths will be freed.umxModify
- show summary as well when comparison = TRUE
plot
defaults for std
and showFixed
changed h/t @MikeNealeumx_scale_wide_twin_data
argument names for consistency: "suffix" "data"umx_residualize
ditto.umxStandardizeACE
plot
using DiagrammeR!umx_set_plot_format("DiagrammeR")
umx_set_plot_format("graphviz")
umx_set_table_format("markdown")
umx_set_table_format("latex")
umx_set_auto_plot(TRUE)
umxEFA
(beta!)loadings
() support for umxEFA
umx_print
, umx_show
, umxCompare
plot
now works on Windows and Unix as well as OS X! (h/t @mhunter)umxReRun
to umxModify
(h/t @hmaes)plot
should generate pdfs for Windows and Unix users nowumxACEcov
support for ACE with covariatesumx_make_TwinData
added to support simulation studiesumx_check_parallel
now returns timing informationumx_time
now supports "start" and "stop")umxAPA
can format more objects in APA style, inc just a p-value)summaryAPA
can now summarize a data.frame with mean, sd, and correlationsumxLabel
now preserves existing labels in umxRAM models: labels = is now savedvcov
() addedumxRAM
can take existing model as input (very useful)umxRAM
reports model fit and comparison (if old model exists)umxPath
now lbounds
[email protected] for v.m.umx_residualize
can now take multiple DVsumxMI
enhanced to cope with more situationsumxSummary
more resilient with missing CIs (#ht Nathan Gillespie!)summaryAPA
now handles data as well as lmumx_print
resilient to 0-row inputumx_fun_mean_sd
)umxCP
twin models! + plot(), umxSummary()umxIP
twin models! + plot(), umxSummary()umxGxE
twin models! + plot(), umxSummary()umxPath
limitation where "to" was not being set.umx_lower2full
confint
(); plot
() etc functions implemented