Error Meesage from mxGenerateData from Documentation Example Code

Posted on
Picture of user. rabil Joined: 01/14/2010
I included "facLoads" in the mxModel arguments so I could get estimates of the factor loadings. (It was missing from code in the on-line documentation.)

When I try to use mxGenerateData, it gives an error.

http://openmx.psyc.virginia.edu/docs/OpenMx/2.6.7/_static/demo/OneFactorJoint_PathRaw.R

#
# Copyright 2007-2012 The OpenMx Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# -----------------------------------------------------------------------------
# Program: OneFactorJoint_PathRaw.R
# Author: Ryne Estabrook
# Date: 2014.05.09
#
# ModelType: Factor
# DataType: Ordinal
# Field: None
#
# Purpose:
# One Factor model to estimate factor loadings, residual variances, means and thresholds
# Path style model input - Raw data input
#
# RevisionHistory:
# Hermine Maes -- 2014.11.02 piecewise specification
# -----------------------------------------------------------------------------

require(OpenMx)
# Load Library
# -----------------------------------------------------------------------------

data(myFADataRaw)

oneFactorJoint <- myFADataRaw[,c("x1","x2","x3","z1","z2","z3")]

oneFactorJoint$z1 <- mxFactor(oneFactorJoint$z1, levels=c(0, 1))
oneFactorJoint$z2 <- mxFactor(oneFactorJoint$z2, levels=c(0, 1))
oneFactorJoint$z3 <- mxFactor(oneFactorJoint$z3, levels=c(0, 1, 2))

# Prepare Data
# -----------------------------------------------------------------------------

dataRaw <- mxData( observed=oneFactorJoint, type="raw" )
# residual variances
resVars <- mxPath( from=c("x1","x2","x3","z1","z2","z3"), arrows=2,
free=c(TRUE, TRUE, TRUE, FALSE, FALSE, FALSE),
values=1, labels=c("e1","e2","e3","e4","e5","e6") )
# latent variance
latVar <- mxPath( from="F1", arrows=2,
free=FALSE, values=1, labels ="varF1" )
# factor loadings
facLoads <- mxPath( from="F1", to=c("x1","x2","x3","z1","z2","z3"), arrows=1,
free=TRUE, values=1, labels=c("l1","l2","l3","l4","l5","l6") )
# means
means <- mxPath( from="one", to=c("x1","x2","x3","z1","z2","z3","F1"), arrows=1,
free=c(TRUE,TRUE,TRUE,FALSE,FALSE,FALSE,FALSE), values=0,
labels=c("meanx1","meanx2","meanx3","meanz1","meanz2","meanz3","meanF") )
# thresholds
thresholds <- mxThreshold(vars=c("z1","z2","z3"), nThresh=c(1,1,2),
free=TRUE, values=c(-1, 0, -.5, 1.2),
labels=c("var1_th1","var2_th1","var3_th1","var3_th2") )

oneFactorJointModel <- mxModel("Common Factor Model Path Specification", type="RAM",
manifestVars=c("x1","x2","x3","z1","z2","z3"), latentVars="F1",
dataRaw, resVars, latVar, means, thresholds, facLoads)

# Create an MxModel object
# -----------------------------------------------------------------------------

oneFactorJointFit <- mxRun(oneFactorJointModel,intervals=TRUE)
# Fit the model with mxRun
# -----------------------------------------------------------------------------

summary(oneFactorJointFit)
oneFactorJointFit$output$estimate
# Print a summary of the results
# -----------------------------------------------------------------------------

mxGenerateData(oneFactorJointModel,100)
> mxGenerateData(oneFactorJointModel,100)
Error in cut.default(as.vector(data[, avar]), c(-Inf, delthr, Inf), labels = levthr) :
'breaks' are not unique

How can I fix this?

Replied on Thu, 10/20/2016 - 17:29
Picture of user. AdminHunter Joined: 03/01/2013

Strange. It works fine on my Windows machine. What's your mxVersion? Mine is


> mxVersion()
OpenMx version: 2.6.8.192 [GIT v2.6.8-192-g550639d]
R version: R version 3.2.4 Revised (2016-03-16 r70336)
Platform: x86_64-w64-mingw32
Default optimiser: CSOLNP

Replied on Thu, 10/20/2016 - 17:37
Picture of user. rabil Joined: 01/14/2010

In reply to by AdminHunter

> mxVersion()
OpenMx version: 2.6.9 [GIT v2.6.9]
R version: R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu
Default optimiser: SLSQP

Any thoughts?

Replied on Thu, 10/20/2016 - 17:58
Picture of user. AdminHunter Joined: 03/01/2013

In reply to by rabil

Inspecting the change log, it looks like a few changes have occurred since 2.6.9 that alter the data generation ... apparently for the better. The latest version on GitHub (v2.6.8-255-g096de3b), works fine for this case, but the the older version on CRAN that you have failed. I replicated the failure you found on the CRAN version. The older version couldn't handle joint ordinal and continuous data generation. This works in the next release!
Replied on Fri, 10/21/2016 - 23:45
Picture of user. rabil Joined: 01/14/2010

In reply to by jpritikin

I tried to install, but I get an error:

> require(devtools)
Loading required package: devtools
> install_github("OpenMx/OpenMx", ref="stable")
Downloading GitHub repo OpenMx/OpenMx@stable
from URL https://api.github.com/repos/OpenMx/OpenMx/zipball/stable
Error: Does not appear to be an R package (no DESCRIPTION)

Replied on Sat, 10/22/2016 - 00:23
Picture of user. rabil Joined: 01/14/2010

In reply to by rabil

The directions here for installing from github also do not seem to work:

http://openmx.psyc.virginia.edu/wiki/howto-build-openmx-source-repository

git clone git@github.com:OpenMx/OpenMx.git
Cloning into 'OpenMx'...
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

This was also suggested but does not work:

git clone https://github.com:OpenMx/OpenMx.git
Cloning into 'OpenMx'...
fatal: repository 'https://github.com:OpenMx/OpenMx.git/' not found