You are here

semPlot Does Not Work with OpenMx 2.0

7 posts / 0 new
Last post
rabil's picture
Offline
Joined: 01/14/2010 - 16:47
semPlot Does Not Work with OpenMx 2.0

Has any one else noticed that semPlot no longer works with OpenMx for version 2? I've used it to make path diagrams with versions of OpenMx before 2.0.

Is there a better tool for making path diagrams?

mhunter's picture
Offline
Joined: 07/31/2009 - 15:26
Me too!

Yeah, I've noticed that semPlot is not compatible with OpenMx 2.0 and later. I've contacted the developer, Sacha Epskamp. But the fix does not seem to be high on his priority list. I'm considering making the changes myself and submitting a pull request on his GitHub page ( https://github.com/SachaEpskamp/semPlot ) for him to incorporate my future fix.

The umx package will create a very nice .dot file for RAM models that can be turned into a .pdf with the free graphviz program: http://www.graphviz.org/ . The non-free Mac-only program OmniGraffle can also read in these .dot files and display them nicely.

My best hope is to fix semPlot in the next few months.

rabil's picture
Offline
Joined: 01/14/2010 - 16:47
Update

I e-mailed Sacha Epskamp yesterday. He said that the version on GitHub will work with OpenMx >=2.0 with the exception that intercepts are not yet supported.

I tried installing on R 3.2.2:

> devtools::install_github("sachaepskamp/semPlot")

but the install failed.

.
.
.

  • installing source package ‘semPlot’ ...
    ** R
    ** inst
    ** byte-compile and prepare package for lazy loading
    Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) :
    there is no package called ‘car’
    ERROR: lazy loading failed for package ‘semPlot’
  • removing ‘/home/rick/R/x86_64-pc-linux-gnu-library/3.2/semPlot’
  • restoring previous ‘/home/rick/R/x86_64-pc-linux-gnu-library/3.2/semPlot’
    Error: Command failed (1)
    In addition: Warning messages:
    1: In utils::install.packages(pkgs, repos = repos, type = type, ..., :
    installation of package ‘MatrixModels’ had non-zero exit status
    2: In utils::install.packages(pkgs, repos = repos, type = type, ..., :
    installation of package ‘quantreg’ had non-zero exit status
    3: In utils::install.packages(pkgs, repos = repos, type = type, ..., :
    installation of package ‘car’ had non-zero exit status
mhunter's picture
Offline
Joined: 07/31/2009 - 15:26
Cool

Cool that Sacha has made the changes! Try

install.packages(c('MatrixModels', 'quantreg', 'car'))
# then
devtools::install_github("sachaepskamp/semPlot")

That allowed this to work on my machine.

require(semPlot)
require(OpenMx)
data(demoOneFactor)
manifests <- names(demoOneFactor)
latents <- c("G")
factorModel <- 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(observed=cov(demoOneFactor), type="cov", numObs=500))
summary(factorRun <- mxRun(factorModel))
semPaths(factorRun, color = list(lat = rgb(245, 253, 118, maxColorValue = 255), 
     man = rgb(155, 253, 175, maxColorValue = 255)), mar = c(10, 5, 10, 5))
neale's picture
Offline
Joined: 07/31/2009 - 15:14
Three other libraries needed (at least)

In my case I needed RCurl and jsonlite as well:

install.packages(c('MatrixModels', 'quantreg', 'car', 'RCurl', 'jsonlite', 'semTools'))
# then
devtools::install_github("sachaepskamp/semPlot")

It was also a bit R version dependent. Ok with R 3.2.2 but R 3.1 was messy. semPlot also installed many other things:

Installing 49 packages: acepack, arm, car, coda, corpcor, d3Network, DiagrammeR, doParallel, ellipse, fdrtool, foreach, Formula, ggm, glasso, gridBase, gridExtra, gtools, Hmisc, htmlwidgets, huge, igraph, irlba, iterators, jpeg, latticeExtra, lavaan, lisrelToR, lme4, MatrixModels, NMF, pkgmaker, plyr, png, psych, qgraph, quantreg, Rcpp, registry, rjson, rngtools, rockchalk, scales, sna, SparseM, stringi, tables, visNetwork, XML, xtable

But installation finally succeeded (though semTools was also needed). Problems remained however with running Hunter's script under R 3.2.2 on OS X Yosemite:

> semPaths(factorRun, color = list(lat = rgb(245, 253, 118, maxColorValue = 255), 
+      man = rgb(155, 253, 175, maxColorValue = 255)), mar = c(10, 5, 10, 5))
Error in !object@matrices$M$free : invalid argument type

and now I am stuck too :(.

mhunter's picture
Offline
Joined: 07/31/2009 - 15:26
No model with means

Hmm ... Are you sure you're running the same example as me? I think you might be trying to run the raw data version of the model: a model with means.

Rabil noted semPlot has problems with intercepts, i.e. means. The only place I could find code that would generate your error message was inside an if() statement that required the means to be non-null. https://github.com/SachaEpskamp/semPlot/blob/5cb2b0303ceb454a270b8c61bfb360e4ca9ae8d1/R/OpenMx.R#L39

mhunter's picture
Offline
Joined: 07/31/2009 - 15:26
Fragile

It looks like they're actively tweaking some things specifically as it relates to OpenMx plotting.

https://github.com/SachaEpskamp/semPlot/commits/master

The July and early October versions work, but the ones since October 20th break things.

Do this.

devtools::install_github("sachaepskamp/semPlot", ref='aedbb4d61832882393a0eef77d4454626a79608b')

It installs the early October version.