I'm running a demo script for a one factor model with ordinal data. I'm using OpenMx 1.4-3532 and R version 3.1.2 (2014-10-31). I get the following error message:
> thresholds <- mxThreshold( vars=c("z1","z2","z3"), nThresh=c(1,1,2),
+ free=TRUE, values=c(-1,0,-.5,1.2) )
Error: could not find function "mxThreshold"
Using "library(help=OpenMx)", "mxThreshold" does not appear. What gives?
Do you have OpenMx loaded?
Ah... I think this requires OpenMx 2.0?
Yes, I have OpenMx loaded (!). The info on mxThreshold seems to go back a few years so I didn't think it was something brand new.
I installed the 2.0 beta and it has the mxThresholds function. Unfortunately, the beta has problems computing confidence intervals. It will compute one interval for a scalar, but if you try to do two confidence intervals it seems to fail:
> oneFactorModel.fit <- mxRun(oneFactorModel,intervals=TRUE)
Running Common Factor Model Path Specification
> summary(oneFactorModel.fit)
Error in if (ci[1] == ci[3] || ci[1] > ci[2] || ci[2] > ci[3]) { :
missing value where TRUE/FALSE needed
I'm running a slightly modified version of the one factor ordinal model where I constrain the ith residual variance to equal 1 - l_i^2 where l1 is the factor loading. (And I've constrained the mean and variance of the common factor to 0 and 1, respectively. I've set the residual variances to free=TRUE. I'm using mxAlgebra and mxConstraint functions.) If I don't ask for confidence intervals, it gives what appears to be the correct estimates. (Using the previoius approach without using the mxThreshold function, I could get what appear to be the correct solutions, but there was always a warning message no matter how many random starting values I tried - all of which produced almost identical estimates. Using mxThreshold there are never any warning or error messages as long as I don't ask for 2 or more confidence intervals.) If I ask just for one scalar confidence interval, it appears to always work. It only fails if I ask for more than one or for a matrix. Unfortunately, I cannot provide the code with the data.
I just noticed that this popped up in a window after one of the segfaults:
#
The crashed program seems to use third-party or local libraries:
/usr/local/lib/R/site-library/digest/libs/digest.so
/usr/local/lib/R/site-library/OpenMx/libs/OpenMx.so
It is highly recommended to check if the problem persists without those first.
Do you want to continue the report process anyway?
#
The digest package is needed in order to install the beta version of OpenMx.
Thanks for that!
shouldn't be giving people an error like "(ci[1] == ci[3] || ci[1] > ci[2] || ci[2] > ci[3])"
Might be an issue with the code mxThreshold is adding, and summary might need some check code adding in.
If the model is just "trunk/demo/OneFactorOrdinal_MatrixRawRAM.R" with the ith residual variance mxConstrained = 1 - l_i^2 plus scaled common factor, it should be OK to share? I think that would help to post it here.
Also, as this might be fixed in trunk, paste the results of
The error message referring to "(ci[1] == ci[3] || ci[1] > ci[2] || ci[2] > ci[3])" is almost certainly occurring because one of the confidence limits is being estimated as
NaN
(or maybeNA
), which in turn (I suspect) is due to a problem with CSOLNP. The error message is thrown by R, not by OpenMx per se. He can still see the CIs withoneFactorModel.fit$output$confidenceIntervals
.Thanks. Using NPSOL doesn't solve the problem:
> mxOption(NULL,"Default optimizer","NPSOL")
> oneFactorModel.fit.2 <- mxRun(oneFactorModel,intervals=TRUE) # Causes OpenMx 2.0 & R to crash
Running Common Factor Model Path Specification
Warning message:
In model 'Common Factor Model Path Specification' Optimizer returned a non-zero status code 6. The model does not satisfy the first-order optimality conditions to the required accuracy, and no improved point for the merit function could be found during the final linesearch (Mx status RED)
> summary(oneFactorModel.fit.2)
Error in if (ci[1] == ci[3] || ci[1] > ci[2] || ci[2] > ci[3]) { :
missing value where TRUE/FALSE needed
> oneFactorModel.fit$output$confidenceIntervals
NULL
With CSOLNP I do not get the warning message. I do get parameter estimates and a lot of other information, but no confidence intervals now with NPSOL. Using the non-beta OpenMx, the upper limit for the factor loading for the 4th rater is NA (the model code does not use mxThreshold).
Does it still crash R with NPSOL? I'm guessing no, but just making sure. Also, you're not seeing CIs because the name of the model you fit with NPSOL is
oneFactorModel.fit2
, notoneFactorModel.fit
. You need to enteroneFactorModel.fit2$output$confidenceIntervals
.The fact that
summary()
is choking on anNA
for one of the confidence limits is pretty annoying, though.The problem with
summary()
throwing an error when a CI contains anNA
appears to have been repaired with revision 3957, so the problem won't exist in the next release of the package.Richard, what OS do you run? Would you be able to build OpenMx from source checked out from the repository?
I second Bates' request for
mxVersion()
output. I strongly suspect that problems with CIs, and any mysterious crashes, are connected to CSOLNP. If you're currently using CSOLNP, switch to NPSOL withmxOption(NULL,"Default optimizer","NPSOL")
before running your model, and try again.I can post the code but I cannot provide the data that is used.