Hello, I have got a question about the thresholds in SEM of ordinal variables and really need your help.
1) I found tow kinds of scripts of saturate SEM of one ordinal variable, one script constrains the free status of thresholds, and another one does not. I can't figure out which one to follow.
the first one:
nth <- 3 frTh <- matrix(rep(c(F,F,(rep(T,nth-2)))),nrow=nth,ncol=nv) # free status for thresholds thinMZ <- mxMatrix( type="Full", nrow=nth, ncol=ntv, free=frTh, values=svTh, lbound=lbTh, labels=labThMZ, name="thinMZ" )
nth <- 3 thinMZ <- mxMatrix( type="Full", nrow=nth, ncol=ntv, free=TRUE, values=svTh, lbound=lbTh, labels=labThMZ, name="thinMZ" )
2)
If I do need to constrain the free status of thresholds, then how many thresholds should I fix?
In the first script, the number of thresholds is 3 and two shresholds are fixed. If my ordinal variable is categorized into 5 groups, and then the number of thresholds should be 4, then how many thresholds should I fix? three or two? In fact, I don't konw the reason for fixing thresholds. So, please don't mind my kind of stupid question.
I would be really appreciated for your reply!
Thanks!
If your ordinal variable has two or more thresholds (three or more ordered categories), then for model identification, you need to choose one of the following: (1) fix the mean (or regression intercept) and variance, and free all thresholds; (2) free the mean (or regression intercept) and fix the variance and one of the thresholds; or (3) free the mean (or regression intercept) and the variance, and fix two of the thresholds. Most people do either (1) or (3). In the case of (1), usually the mean (or intercept) and variance are fixed to 0 and 1, respectively. In the case of (3), people usually fix the lowest two thresholds to 0 and 1, respectively.
The choices are arbitrary, but sometimes one choice is preferable to others because it makes results easier to interpret. For instance, option (3) is often used with longitudinal data, because it's easier to interpret the variance of the latent continuum changing with time, as opposed to interpreting the spread of the thresholds changing with time.
Note that in biometrical variance-components analysis (as with twin data, etc.), fixing the variance to 1 will often require an MxConstraint. An alternative to using an MxConstraint is to fix the nonshared-environmental variance component to 1, which does change the interpretation of the genetic and shared-environmental variance components..
I'm really grateful for your detailed reply. However, even though I ran the totally same code as the script I found (intercept and variance are fixed to 0 and 1), the result showed 'Model is not locally identified'. The code is as follows and I hope you can help me to figure out where the problem is.
Thank you so much!
That's probably a false alarm. Try
mxCheckIdentification()
again, withdetails=TRUE
, to see the function's guess as to which parameters are unidentified. Also, try running your model (perhaps withmxTryHardOrdinal()
), and check to see ifmxCheckIdentification()
says it's locally unidentified at the solution, too.I have one more question, how can I define the threshold matrix if the ordinal variable1 has 4 thresholds and ordinal variable2 has 3 threshold.
I don't know how to define threshold matrix.
Thanks so much!
See here. Specifically, under "Threshold Specification", it says "Rows of the threshold matrix beyond the number of thresholds in a particular variable should be fixed parameters with starting values of
NA
."Hello again! I'm sorry for turning to you for help again.
1) After I ran
mxCheckIdentification(), details=TRUE
, the result showed the coefficients of covatiates were not identified. Does that matters?2) I followed your advice by fixing corresponding thresholds with starting values of NA. However, I got the waring as follows:
**Computing Hessian and/or standard errors and/or confidence intervals from imperfect solutionError : In model 'Sat' I was expecting 3 thresholds in column 'smk_num_4g1' of matrix/algebra 'MZ.threMZ' but I hit NA values after only 0 thresholds. You need to increase the number of thresholds for 'smk_num_4g1' and give them values other than NA
Retry limit reached; solution not found. Best fit=25943569000 (started at 47142898000) (16 attempt(s): 16 valid, 0 errors)**
Here is my script and I'm sorry to bother you to check what's wrong with it. Thank you so much!!!!
Wish you have a good day!
Thanks♪(・ω・)ノ
What do you get from
str(mzDataF)
andstr(dzDataF)
?im sorry i dont have my data at hand. it is 11 pm in my country. i will get up as early as possible tomorrow morning to check the result of it. but i define mzdataF and dzdataF according to the demo code i uploaded, so i think it would be right.
please leave more information since when i get up you would possibly get off work.
thank you very much!!!
Having taken a second look at your post, I'm not sure that there's anything wrong with your script. I can't find anything suspicious in your script, except for the possibility that your use of
cbind()
might have returned a matrix rather than a dataframe at some point.Did
mxTryHardOrdinal()
return a fitted MxModel object? If so, doesmxCheckIdentification()
still say the model is unidentified?Hi, Rob!
1)After I ran
str(mzDataF)
, it turned out that it was a dataframe. According to the warning, it seems that there is something wrong in the matrix of MZ.threMZ?2)
mxTryHardOrdinal()
can return a fitted solution, butmxCheckIdentification()
still say the model is not identified and the non-identified parameters are two coefficients of age and region_type.Thanks again!
What's the actual output of
str(mzDataF)
?Hi, the result was in the picture I uploaded.
Thanks!
Per its documentation,
mxCheckIdentification()
doesn't necessarily give accurate results when the MxModel uses definition variables.Hi.
I am wondering if you solved the issue with the error OpenMx gives when using this script? I have one ordinal variable with three thresholds and one dichotomous, so the matrix of thresholds have two NA values as it is written in the documentation. This gives the following error: "I was expecting 1 thresholds in column ... of matrix/algebra 'MZ.expThreshold' but I hit NA values after only 0 thresholds. You need to increase the number of thresholds for ... and give them values other than NA". I suspect this comes from multiplication of a lower matrix with the matrix that contains NA.
When I replace NA's with zero's for example, I don't get this error and the model runs. However, a new error message occurs: "...fit is not finite (Found 1 thresholds too close together in column 3.)"
So how can we specify a threshold matrix for several variables when variables have different number of thresholds, so that multiplication works?
Would you mind posting the syntax you use to create the MxMatrices and MxAlgebras for your thresholds?
Here is the respective code chunk. I have four variables in the analysis, the first one is ordinal with four categories, the second and the third ones are continuous, and the fourth one is dichotomous.
I believe the product of Low and Threshold produces only NA's in the second column. At least this is what is happening when I do such multiplication with conventional matrices in R.
At the moment I figured out a workaround by defining thresholds separately for each variable and then concatenating them together. But I wonder if this can be avoided and if my code was wrong.
Thank you again!
I am not sure what the recommended practice is in this situation. I've brought this thread to the attention of the rest of the OpenMx developers.
Does your workaround let you run your model, and do you get sensible-looking results?
It does run and the results seem to be ok. Would be nice if there was a more straight forward solution instead of defining thresholds for each ordinal variable separately. Thank you!
The advice to leave unused threshold cells NA should probably change to "leave these at 0 or some other number - they will be ignored."
You might well benefit from using
umxThresholdMatrix()
This handles all the details of building a thresholds matrix automatically, including sizing it, filling with reasonable defaults, and ensuring that levels are kept in order by using positive offsets instead of thresholds. It also handles twins properly. See
?umx::umxThresholdMatrix
for examples.Thanks! This seems to work. I thought that these unused thresholds will still be used when multiplied by a lower matrix. However, I was mistaken. Thank you again!