# Error running joint ordinal-continuous model - 'Requested improper index (1) from (1, 1) vector'

10 posts / 0 new
Offline
Joined: 03/20/2012 - 08:21
Error running joint ordinal-continuous model - 'Requested improper index (1) from (1, 1) vector'

Running a slightly modified version of the joint ordinal-continuous example from the manual on Mac OSX, on the latest version of OpenMx (single-threaded download). Getting the following error when using mxRun:

> m1 <- mxRun(TestModel)
Running SES
Error in runHelper(model, frontendStart, intervals, silent, suppressWarnings, :
Requested improper index (1) from (1, 1) vector.

Can provide model and data on request. Any clues?

Stuart

Offline
Joined: 07/31/2009 - 15:24
Hmm. So the error message is

Hmm. So the error message is misleading. What it's trying to convey is that the script is attempted to access the 2nd element of a vector that has only a single element. I'm cleaning up the error message, it will be better in version 1.2.1. If you attach a copy of your script to a forum post, along with some fake data, we can assist in debugging.

Offline
Joined: 07/31/2009 - 14:25
Error in ordinal CFA

hi michael et al.

So. attached are a script and rda file (as dat to get through the suffix filter) which generate this error.

They are identical to a version that works (posted to the wiki), barring having more levels (7 and 4 levels of ordinal data)

require(OpenMx)
manifests      = c("cont1", "ord1", "ord2")
ordinalVars    = manifests[2:3]
continuousVars = manifests[1]

m1 <- mxModel("joint CFA", type="RAM",
manifestVars = manifests,
latentVars = "F1",
mxPath(from="F1", to = manifests, arrows=1, free=T, values=1, labels=paste("l",1:3,sep="")),

# Manifest continuous mean & residual variance (both free)
mxPath(from="one", to = continuousVars, arrows=1, free=T, values=0, labels="meancont1"),
mxPath(from=continuousVars            , arrows=2, free=T, values=1, labels="e1" ),

# Ordinal manifests mean and variance fixed at 0 (the threshold matrix will esimate these)
mxPath(from="one", to = ordinalVars, arrows=1, free=F, values=0, labels=c("meanord1","meanord2")),
mxPath(from=ordinalVars            , arrows=2, free=F, values=1, labels=c("e2","e3")),

# fix latent variable variance @1 & mean @0
mxPath(from="F1"          , arrows=2, free=F, values=1, labels ="varF1"),
mxPath(from="one", to="F1", arrows=1, free=F, values=0, labels="meanF1"),

mxMatrix("Full", nrow=6, ncol=2, name="thresh",
dimnames = list(c(), ordinalVars),
free  = c(T, T, T, T, T, T,
T, T, T, F, F, F),
values= c(-3,-2,-1, 0, 1, 2,
-2, 0, 2,NA,NA,NA),
),
# Tell the mxRAMObjective that we have not only A,S,F and M matrices, but also some ordinal vars with thresholds
mxRAMObjective(A="A", S="S", F="F", M="M", thresholds = "thresh"),
# And last but not least, the data
mxData(df, type="raw")
)

# run!
m1 = mxRun(m1);
# Error in runHelper(model, frontendStart, intervals, silent, suppressWarnings,  :
#  Requested improper index (2) from vector of length (1).

PS: be good to add rda to the list of acceptable files....

Offline
Joined: 07/31/2009 - 15:24
I tracked down the bug as far

I tracked down the bug as far as omxFIMLSingleIteration.c:481. The behavior is weird, because ofo->ordMeans is being initialized as a 3 x 1 matrix (verified in the debugger) but at some point it's transformed into a 1 x 1 matrix. I'm going to hand this over to tbrick.

Offline
Joined: 07/31/2009 - 14:25
thanks!

Thanks Michael: Glad the problem localised somewhat now. Interesting to know what it was about more thresholds that triggers this.

Offline
Joined: 07/31/2009 - 14:25
Any thoughts on this bug?

Hi all,
Just wondering what the conclusion is here; Is mixed continuous and ordinal RAM is broken for now, or (hope...) is there a work around in specifying the thresholds etc?

Offline
Joined: 07/31/2009 - 15:10
Patched.

tbates and StuartJRitchie,

Thanks for finding this! There's a case in joint FIML when:
1) there are no definition variables and
2) the first (sorted) row with a new number of ordinal variables
3) has all continuous variables missing
that wasn't being handled properly.

A patch is checked in (r2009), so if you get the latest version, it should be fixed.

tbates, can we add your example case to the test set to catch similar problems if they show up in the future?

Thanks again!

Offline
Joined: 07/31/2009 - 14:25
yay

Thanks for the patch Tim!

Fine to add the example case to the test set.

best, t

Offline
Joined: 07/31/2009 - 14:25
Error: thresholds contain NA values

If the user provides fewer free thresholds than there are levels in a variable (for instance 4 free cells for a 6-level factor (which should have 5 thresholds), they get this error

Error: In model 'X' the thresholds in column 'XXX' of matrix/algebra 'thresh' contain NA values. Only the first 5 elements of this column are inspected.

As it is normal for NA thresh to contain NA values this is hard to translate into the real problem. Also, while "only the first five are inspected" might be intended to note that if the matrix contained free values after an NA, they would not have been seen, that also is not apparent in the message.

I suggest: "I was expecting 5 thresholds for column XXX, but I only found 4 free values before I hit NAs in column XXX of your thresholds matrix. You need to increase the number of free thresholds for XXX, and give them values other than NA."

Offline
Joined: 07/31/2009 - 14:25
submitted patch

submitted a patch for this - appreciate someone having a look at whether it does what is required