You are here

Ordinal error: thresholds in column 'x' are not in sorted order

running an ordinal model...

fit = mxRun(model, intervals=F)
Running Full mv ordinal
Error: In model 'Full mv ordinal' the thresholds in column 'integration1' are not in sorted order.

Can this error be made more specific? Does it refer to (mxData as it seems to suggest)?* If so, in which group etc. Or if the thresholds matrix of the matrix pointed to by the "thresholds" parameter of an mxFIMLObjective of a model?

More info would help debugging. Esp to say what threshold was out of order (not even sure how this is possible given that the thresholds matrix is pre-multipled by a lowerOnes %*%... so scratching my head at present)

*Not the case, I think, as the data have had mxOrder applied
is.ordered(dzData$integration1)
[1] TRUE

Reporter: 
Created: 
Wed, 11/03/2010 - 08:28
Updated: 
Mon, 02/28/2011 - 13:15

Comments

The error message could add more information. Classic Mx would tell you what the thresholds were for each variable, and list variables where the ordering was violated. It would also inform the user of the correlation matrix being passed to the numerical integration routine.

It is not sufficient to premultiply the matrix of thresholds with a lower triangular matrix of 1's. It is also necessary to ensure that thresholds 2 to maxthresh are lbounded to be strictly positive (say .01). Yet the error can still occur even when this is also specified. When? If the correlation matrix for integration is not positive definite. Hence the utility of informing the user of the correlation matrix used for integration. However, it is my experience that users are often find difficulty with using this information and require some guidance.

OK I added a more descriptive error message in the subversion trunk. See if that helps.

much nicer error, unfortunately I get to see it :-)

fit1 = mxRun(model1, intervals=F, unsafe=T)
Running Full mv ordinal
Error: In model 'Full mv ordinal' the thresholds in column 'meaningfulnesssociety1' of matrix/algebra 'top.thresholdsMatrix' are not in ascending order. The current order is: '-3', '-6', '-9', '-7.33333333333333', '-5.66666666666667', '-4', '-2.33333333333333', '-0.666666666666665', '1', and '2.66666666666667' and ascending order is: '-9', '-7.33333333333333', '-6', '-5.66666666666667', '-4', '-3', '-2.33333333333333', '-0.666666666666665', '1', and '2.66666666666667' . Only the first 10 value(s) of this column are inspected.

As confirmed looking inside top.thresholdsMatrix.
> mxEval(top.thresholdsMatrix, fit1)
meaningfulnesssociety1 integration1 religBeliefsSummed1 meaningfulnesssociety2 integration2 religBeliefsSummed2
th0 -3.000000 0.6666667 0.0001000 -3.000000 0.6666667 0.0001000
th1 -6.000000 1.3333333 0.0002000 -6.000000 1.3333333 0.0002000
th2 -9.000000 2.0000000 0.0003000 -9.000000 2.0000000 0.0003000
th3 -8.333333 2.6666667 0.8136373 -8.333333 2.6666667 0.8136373

But given that is just two of these side by side:
mxAlgebra(lowerOnes %*% baseAndIncrements, name="thresholds" )

And that baseAndIncrements knows that it has to contain positive steps (and does:

mxEval(top.baseAndIncrements, fit1)
[,1] [,2] [,3]
[1,] -3.0000000 0.6666667 0.0001000
[2,] -3.0000000 0.6666667 0.0001000
[3,] -3.0000000 0.6666667 0.0001000
[4,] 0.6666667 0.6666667 0.8133373

What gives?

So, t0 < t1 < t2 < t3 should be true for all variables. However, -3 is not less than -6, which is not less than -9 either...

meaningfulnesssociety1 integration1 religBeliefsSummed1 meaningfulnesssociety2 integration2 religBeliefsSummed2
th0 -3.000000 0.6666667 0.0001000 -3.000000 0.6666667 0.0001000
th1 -6.000000 1.3333333 0.0002000 -6.000000 1.3333333 0.0002000
th2 -9.000000 2.0000000 0.0003000 -9.000000 2.0000000 0.0003000
th3 -8.333333 2.6666667 0.8136373 -8.333333 2.6666667 0.8136373

The increment matrix (if I understand top.baseAndIncrements correctly) has negative numbers in at least one of the elements top.baseAndIncrements[2:4,1:3]. Therefore I surmise that the top.baseAndIncrements needs lbounds for these elements and should be initialized to something like:

[,1] [,2] [,3]
[1,] -3.0000000 0.6666667 0.0001000
[2,] 1.0000000 0.6666667 0.5000
[3,] 1.0000000 0.6666667 0.5000
[4,] 0.6666667 0.6666667 0.8133373

I think with the new error message I would have found this reasonably quickly.

I HAD lbounds on fit1@submodels$top@matrices$baseAndIncrements... but forgot to switch the default fill from columns to rows first so...
@lbound
[,1] [,2] [,3]
[1,] -5e+00 1e-04 1e-04
[2,] -5e+00 1e-04 1e-04
[3,] -5e+00 1e-04 1e-04
[4,] 1e-04 1e-04 1e-04

@lbound
[,1] [,2] [,3]
[1,] -5e+00 -5e+00 -5e+00
[2,] 1e-04 1e-04 1e-04
[3,] 1e-04 1e-04 1e-04
[4,] 1e-04 1e-04 1e-04
[5,] 1e-04 1e-04 1e-04
[6,] 1e-04 1e-04 1e-04
[7,] 1e-04 1e-04 1e-04
[8,] 1e-04 1e-04 1e-04
[9,] 1e-04 1e-04 1e-04
[10,] 1e-04 1e-04 1e-04

Anyhow: The new message focuses attention nicely... Thanks Mike, and Michael :-)

However, had the same error arisen due to non- posdef correlation matrix, which does occur with classic Mx, it would not be very easy to find it. I suggest that the correlation matrix & eigenvals also be printed.

yes, because now...

> fit1 = mxRun(model1)
Running Full mv ordinal
Warning message:
The job for model 'Full mv ordinal' exited abnormally with the error message: Objective function returned a value of NaN.

Automatically closed -- issue fixed for 2 weeks with no activity.

It would be nice to implement Mike N's suggestion of printing correlation matrix and eigenvalues to help diagnose whatever is going wrong when we get this error* ... which seems to be when ever real ordinal data are being used ;-)

t

The job for model 'Full mv ordinal' exited abnormally with the error message: Objective function returned a value of NaN.