Output codes detail the cause of the error.
This status element is returned from the optimizer.
NA means that optimization was not attempted. For example, this status will be obtained if you only evaluate the fitfunction at one point,
mxComputeOnce('fitfunction', 'fit')
0 indicates a successful optimization--no error returned.
1 means that an optimal solution was found (like status 0), but that the sequence of iterates did not converge. In practice, this is the same as status 0, but involves slightly different criteria and is distinguished for technical reasons. This code is labeled (Mx status GREEN).
2 or 3 means that the box constraints or non-linear constraints, respectively, could not be satisfied.
4 means that the iteration limit was reached with no solution found. You can use mxOptions() to set a higher iteration limit, or just run mxRun() using the output—it will restart from the most recent set of estimates, and make another run of the same number of iterations.
5 means that the Hessian at the solution is not convex. There is likely a better solution, but the optimizer is stuck in a region of confusing geometry (like a saddle point).
6 means that gradient is not close enough to zero but the optimizer could find no way to improve the estimate. A variety of situations can lead to this outcome. Check whether the model is identified (mxCheckIdentification). It is also possible that gradients are just slightly larger than the arbitrary threshold used by OpenMx. The estimates resulting from this run MIGHT not be optimal estimates, and it would be risky to treat them as solutions without further investigation, so this code is labeled (Mx status RED). Sometimes re-running the model from its solution [firstRun
7 means that the analytic derivatives are incorrect. This should be reported to developers.
9 means that an invalid parameter was passed to the optimizer. This should be reported to developers.
10 means that the parameter vector is outside the feasible set. This most often happens when the starting values are infeasible. Given feasible starting values, optimizer should under no circumstances escape the feasible set.
Any other status codes should be reported to developers.
output$status$status is zero unless there was an error in the backend.
The third element of status provides human readable information on what went wrong. Examples are:
Note, while R coders often use the period character inside variable names, this is not legal in OpenMx, which uses this character to specify the container model for variables.
R is saying that it found a "symbol" (a character) that is illegal in the context it was expecting: Perhaps you are trying to start a variable name with a number, or some other illegal character in that context.
R will give you a hint where: the error message includes the code as close as R can guess to where you made the typo. Let me google that for you: ah yes:
>> 0708smolts <- read.csv("myfile.csv", header=T, sep=",") > Error: unexpected symbol in "0708smolts"
Bit confusing: perhaps you think there's a bad symbol in the file, or the sep value is wrong, or...
But no: Look at the error: something is wrong with "0708smolts". What could it be? yip... programs that do math don't like it when you try and start a variable name with a digit.
FYI, try and avoid using mathematical symbols in names as well: what would you do if were a calculator and you got told "young-man = woman"? That's right, attempt to subtract set man to woman, then subtract the result from young...
to = c(,'x','y','z')
mxMatrix("Name", nrow = 3,ncol=3,free=TRUE, values=.5,)
mxMatrix(type = "Full", nrow = 1, ncol = 1, free = FALSE, values = "l1", labels = "aa", lbound = 0, ubound = 2, name = "la"),
We try and convert the character "l1" to a numeric value, can't, return an NA... hence the error: NAs induced by coercion.
Warning messages: 1: In convertVFN(values, free, labels, lbound, ubound, nrow, ncol) : NAs introduced by coercion...
Error: The expected means matrix associated with the FIML objective function in model 'univSat4' does not contain dimnames.
model <- mxModel("univSat4", mxMatrix(type = "Symm", nrow=1, ncol=1, free=T, values=1, name="expCov"), mxMatrix(type = "Full", nrow=1, ncol=1, free=T, values=0, name="expMean"), mxData(observed = testData, type="raw"), mxFIMLObjective(covariance = "expCov", means="expMean") # triggers error ) fit = mxRun(model)
Add dimnames to the covariance and means matrices:
mxMatrix("Symm", 1, 1, T, 1, name = "expCov", dimnames=list(selVars, selVars), mxMatrix("Full", 1,1, T, 0, name = "expMean", dimnames=list(selVars, selVars)),
mxFIMLObjective(covariance = "expCov", means="expMean", dimnames=selVars)
Suspect your start values, data, and mapping of model onto data. This model for instance will return an error with default start values
require(OpenMx) data(demoOneFactor) DV = "x4" threePred = c("x1", "x2", "x3") manifests = names(demoOneFactor) manifests = c(threePred, DV) dat = demoOneFactor[,manifests] fit1 = mxModel("base", type="RAM", latentVars = "G", manifestVars = manifests, mxPath(from = "G", arrows = 2, free = T), mxPath(from = manifests, arrows=2), # manifest variances mxPath(from = manifests, arrows=2, connect="unique.bivariate"), mxPath(from = manifests, to = "G"), mxData(cov(dat), type = "cov", numObs = 500) ) summary(mxRun(fit1, unsafe=T))
Starting the variances at their likely values will run.
fit1 = mxModel("base", type="RAM", latentVars = "G", manifestVars = manifests, mxPath(from = "G", arrows = 2, free = T), mxPath(from = manifests, arrows=2, values=diag(cov(dat))), # manifest variances mxPath(from = manifests, arrows=2, connect="unique.bivariate"), mxPath(from = manifests, to = "G"), mxData(cov(dat), type = "cov", numObs = 500) ) summary(mxRun(fit1, unsafe=T))