MxComputeGradientDescent: fitfunction is not finite error

Attachment | Size |
---|---|
dataset for the described code | 323.87 KB |
Hi all,
I'm currently attempting an ordered SEM model with FIML. I'm having an "MxComputeGradientDescent: fitfunction mindfulness.fitfunction is not finite" error. I can't figure out what's wrong. The warning message says something about starting values, but they all seem reasonable. Can anyone find an error?
#### make all variables ordered and create threshold matrix
man.vars = r("BDI1", "SPSI52", names(k), T)
thresh.vals = matrix(nrow=5, ncol=length(man.vars))
thresh.free = matrix(T, nrow=5, ncol=length(man.vars))
for (i in 1:length(man.vars)){
rng = range(k[,man.vars[i]], na.rm=T)
threshholds = (seq(from=rng[1], to=rng[2])) +.5; threshholds = threshholds[which(threshholds
thresh.vals[1:length(threshholds),i] = threshholds
}
thresh.free[is.na(thresh.vals)]=F
#### set up openmx model
latent.vars = c("PPO", "NPO", "RPS", "ICS", "AS", "BDI", "DESCRIBING", "OBSERVING", "ACTING", "ACCEPTING")
#### specity spsi factor loadings
ppo = mxPath(from="PPO", to=c("SPSI7", "SPSI9", "SPSI19", "SPSI28", "SPSI38"), arrows=1, free=T, values=.3)
npo = mxPath(from="NPO", to=c("SPSI1", "SPSI2", "SPSI6", "SPSI12", "SPSI13", "SPSI17", "SPSI32", "SPSI36", "SPSI41", "SPSI50"), arrows=1, free=T, values=.3)
rps = mxPath(from="RPS", to=c("SPSI11", "SPSI29", "SPSI33", "SPSI44", "SPSI49", "SPSI5", "SPSI20", "SPSI39", "SPSI47", "SPSI48", "SPSI18", "SPSI24", "SPSI40", "SPSI43", "SPSI46", "SPSI25", "SPSI26", "SPSI27", "SPSI35", "SPSI37"), arrows=1, free=T, values=.3)
ics = mxPath(from="ICS", to=c("SPSI3", "SPSI4", "SPSI8", "SPSI15", "SPSI21", "SPSI22", "SPSI34", "SPSI45", "SPSI51", "SPSI52"), arrows=1, free=T, values=.3)
as = mxPath(from="AS", to=c("SPSI10", "SPSI14", "SPSI16", "SPSI23", "SPSI30", "SPSI31", "SPSI42"), arrows=1, free=T, values=.3)
#### specify bdi factor loadings
bdi = mxPath(from="BDI", to=c("BDI1", "BDI2", "BDI3", "BDI4", "BDI5", "BDI6", "BDI7", "BDI8", "BDI9", "BDI10", "BDI11", "BDI12", "BDI13", "BDI14", "BDI15", "BDI16", "BDI17", "BDI18","BDI19", "BDI20"), arrows=1, free=T, values=.3)
#### specify other variables
observing = mxPath(from="OBSERVING", to=c("KIMS1", "KIMS5", "KIMS9", "KIMS13", "KIMS17", "KIMS21", "KIMS25", "KIMS29", "KIMS30", "KIMS33", "KIMS37", "KIMS39"), arrows=1, free=T, values=.3)
describing = mxPath(from="DESCRIBING", to=c("KIMS2", "KIMS6", "KIMS10", "KIMS14", "KIMS18", "KIMS22", "KIMS26", "KIMS34"), arrows=1, free=T, values=.3)
acting = mxPath(from="ACTING", to=c("KIMS3", "KIMS7", "KIMS11", "KIMS15", "KIMS19", "KIMS23", "KIMS27", "KIMS31", "KIMS35", "KIMS38"), arrows=1, free=T, values=.3)
accepting = mxPath(from="ACCEPTING", to=c("KIMS4", "KIMS8", "KIMS12", "KIMS16", "KIMS20", "KIMS24", "KIMS28", "KIMS32", "KIMS36"), arrows=1, free=T, values=.3)
#### specify manifest mean and variance (fixed to 0 and 1)
mn.ordinal = mxPath(from="one", to=man.vars, arrows=1, free=F, values=0)
var.ordinal = mxPath(from=man.vars, arrows=2, free=F, values=1)
#### latent variable variance of one and mean of 0
var.latent = mxPath(from= latent.vars, arrows=2, free=F, values=1)
mn.latent = mxPath(from="one", to= latent.vars, free=F, values=0)
dat = mxData(observed=k, type="raw")
##### set the threshold matrix
thresh = mxMatrix(type="Full", nrow=nrow(thresh.vals), ncol=length(man.vars),
dimnames=list(c(), man.vars),
free=thresh.free, values=thresh.vals, name="thresh")
thresh2 = mxExpectationRAM(A="A", S="S", F="F", M="M", thresholds="thresh")
mod = mxModel("mindfulness", type="RAM", manifestVars=man.vars, latentVars=latent.vars,
ppo, npo, rps, ics, as, bdi, observing, describing, acting, accepting, mn.ordinal, var.ordinal,
var.latent, mn.latent, dat, thresh, thresh2)
mxTryHard(mxRun(mod))
Optimizer? Package version?
What package provides the
r()
function in the first line of the syntax?One thing to try (if you haven't already) is switching optimizers, e.g.
mxOption(NULL,"Default optimizer","SLSQP")
switches the default optimizer to SLSQP. The available default optimizers are CSOLNP, SLSQP, and, if you installed OpenMx from the virginia.edu repository, NPSOL.Also, which version of OpenMx are you running? You can see that, as well as the current default optimizer, via
mxVersion()
. If you're running version 2.7, be advised that the most serious known issue with v2.7 is its "over-sensitivity to start values". If that's what the problem is, the release announcement I linked has advice in its second paragraph on how to downgrade to v2.6.9, the most recent stable release. You could also upgrade to a "bleeding-edge" build of OpenMx by compiling the package from source.I notice your syntax includes
mxTryHard()
. You might be able to get your model running if you use non-default values for the various arguments tomxTryHard()
; see the function's documentation.Log in or register to post comments
In reply to Optimizer? Package version? by AdminRobK
r() is from the fifer package
1. r() is from the fifer package. It just selects a range of columns in a dataset.
2. I tried SLSQP and got an error (Error in runHelper(model, frontendStart, intervals, silent, suppressWarnings, :
MxComputeGradientDescent: engine SLSQP unknown)
3. re:mx version:
OpenMx version: 2.0.1.4157
R version: R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin10.8.0
I tried updating OpenMx using the link you sent, but got the following error message: "Error: package ‘StanHeaders’ 2.6.0-10 was found, but >= 2.7 is required by ‘OpenMx’" I attempted to install StanHeaders through cran and that didn't seem to fix it.
4. I updated extratries to 100 and that didn't seem to do anything. Any other options to explore?
Log in or register to post comments
In reply to r() is from the fifer package by fife
definitely update beyond v2.0.1
v2.0.1 is pretty out-of-date, and in fact predates our inclusion of SLSQP, which was added for v2.2.
Hmm. You might need to restart R between updating StanHeaders and trying to install OpenMx.
Wow, so all 101 attempts ended with errors?
Log in or register to post comments
Update OpenMx
I agree with everything Rob has suggested.
Here are a couple of additional carrots for updating OpenMx to 2.7. First, there is a new function called
mxGetExpected()
. You give this function a model and e.g. "covariance" to get the model-implied covariance matrix for your model. This can be very helpful when assessing starting values. Second, there soon will be another new function calledmxAutoStart()
which will provide automatic starting values quickly that are extremely close to the ML estimates.Log in or register to post comments
I hadn't realized openmx was
I hadn't realized openmx was on cran now. I was still using that old source('....') code to install it. I guess that's still pointing to an old version. After updating R and OpenMx, I get a new error:
Begin fit attempt 11 of at maximum 11 tries
Error : In model 'mindfulness' the thresholds in column 'PANAS3' of matrix/algebra 'thresh' are not in ascending order.
The current order is: '1.70457977155456', '2.82656906684861', '3.43010245903861', and '3.21088330633938' and
ascending order is: '1.70457977155456', '2.82656906684861', '3.21088330633938', and '3.43010245903861' .
Only the first 4 element(s) of this column are inspected.
That happens at every iteration: one of the variables has trouble. I'm not sure why they get out of ascending order; I tell it what order to be in and it seems to break those boundaries.
Log in or register to post comments
umxThresholdMatrix()
The simplest answer is probably to use
umxThresholdMatrix()
from the 'umx' package, and include the elements of the list it outputs into your MxModel.Log in or register to post comments
I'm getting a new error. Here
I'm getting a new error. Here's my input:
thresh = umxThresholdMatrix(k[,man.vars])
mod = mxModel("mindfulness", type="RAM", manifestVars=man.vars, latentVars=latent.vars,
ppo, npo, rps, ics, as, bdi, observing, describing, acting, accepting, mn.ordinal, var.ordinal,
var.latent, mn.latent, dat, thresh)
mxOption(NULL,"Default optimizer","SLSQP")
mxRun(mod)
And here's my output:
Error: The RAM model 'mindfulness' contains data that requires thresholds for columns 'BDI1', 'BDI2', 'BDI3', 'BDI4', 'BDI5', 'BDI6', 'BDI7', 'BDI8', 'BDI9', 'BDI10', 'BDI11', 'BDI12', 'BDI13', 'BDI14', 'BDI15', 'BDI16', 'BDI17', 'BDI18', 'BDI19', 'BDI20', 'PANAS1', 'PANAS2', 'PANAS3', 'PANAS4', 'PANAS5', 'PANAS6', 'PANAS7', 'PANAS8', 'PANAS9', 'PANAS10', 'PANAS11', 'PANAS12', 'PANAS13', 'PANAS14', 'PANAS15', 'PANAS16', 'PANAS17', 'PANAS18', 'PANAS19', 'PANAS20', 'MAAS1', 'MAAS2', 'MAAS3', 'MAAS4', 'MAAS5', 'MAAS6', 'MAAS7', 'MAAS8', 'MAAS9', 'MAAS10', 'MAAS11', 'MAAS12', 'MAAS13', 'MAAS14', 'MAAS15', 'KIMS1', 'KIMS2', 'KIMS3', 'KIMS4', 'KIMS5', 'KIMS6', 'KIMS7', 'KIMS8', 'KIMS9', 'KIMS10', 'KIMS11', 'KIMS12', 'KIMS13', 'KIMS14', 'KIMS15', 'KIMS16', 'KIMS17', 'KIMS18', 'KIMS19', 'KIMS20', 'KIMS21', 'KIMS22', 'KIMS23', 'KIMS24', 'KIMS25', 'KIMS26', 'KIMS27', 'KIMS28', 'KIMS29', 'KIMS30', 'KIMS31', 'KIMS32', 'KIMS33', 'KIMS34', 'KIMS35', 'KIMS36', 'KIMS37', 'KIMS38', 'KIMS39', 'SPSI1',
Log in or register to post comments
In reply to I'm getting a new error. Here by fife
mxThreshold() ?
I think you need to use
mxThreshold()
, i.e. include the output ofmxThreshold()
in your MxModel object. See its entry in the documentation.Log in or register to post comments
example
It might help to see an example script of an ordinal RAM-type model: https://github.com/OpenMx/OpenMx/blob/master/inst/models/passing/OrdinalPathTest.R .
Log in or register to post comments
i got it. I didn't realize i
i got it. I didn't realize i had to wrap umxThresholdMatrix within mxThreshold
thresh = mxThreshold(umxThresholdMatrix(k[,man.vars]))
Now I'm good. Thanks!
Log in or register to post comments