You are here

Bivariate umxACE model data length error

11 posts / 0 new
Last post
gdash's picture
Offline
Joined: 11/29/2021 - 17:56
Bivariate umxACE model data length error

Hello,

I am new to using umx, so I apologize for asking what is perhaps a very simple question. I am trying to run a bivariate ACE model using binary variables (they are structured as ordered factors). When I run the model, I receive the warning message copied below alongside model output:

In matrix(labels, nrow, ncol, byrow = byrow) :
data length [3] is not a sub-multiple or multiple of the number of rows [2]

I saw a few threads describing this error, but they were all in the context of OpenMx code for which nrow and ncol were explicitly specified in the model. Might you be able to advise what the source of this error is and how to remedy, if necessary? Is the output of the bivariate model unreliable given the accompanying warning message?

Here is the code I am using (adapted from Boulder script):

selDVs = c("var1", "var2")
m1 = umxACE(selDVs = selDVs, dzData = dzData,
mzData = mzData, sep = "_T", tryHard = c("ordinal"))

Thank you very much for your time!

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
more info needed: traceback(); umxVersion();

Can you post what traceback() says immediately after?

Does the univariate model run for both var1 and var2?

Also, what does umxVersion() say?

umxACE is pretty bullet proof and user-input check complete functions so...

m1 = umxACE(selDVs = c("var1", "var2"), dzData = dzData, mzData = mzData, sep = "_T", tryHard = "ordinal")
gdash's picture
Offline
Joined: 11/29/2021 - 17:56
Additional Information

Thank you so much for your quick reply! Please find the requested information copied below:

"Can you post what traceback() says immediately after?"
Error: The argument to the '$' or '[' operator applied on a MxModel object must be a single character string

"Does the univariate model run for both var1 and var2?"
Yes, they both run normally and without errors.

"Also, what does umxVersion() say?"
umx version: 4.9.0
OpenMx version: 2.19.8 [GIT v2.19.8]
R version: R version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32
Default optimizer: SLSQP
NPSOL-enabled?: No
OpenMP-enabled?: No

Thank you again! Please let me know if there is any other information I can provide.

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
here's a repro script: works fine here

I can't replicate this. Can you please run the following: It works perfectly for me, at a glance.

# Prep data
require(umx)
data(twinData)
# Cut BMI and ht to form ordinal variables
obLevels = c('normal', 'overweight', 'obese')
cuts = quantile(twinData[, "bmi1"], probs = c(.5, .2), na.rm = TRUE) # 21.6098 20.9519 
twinData$obese1=cut(twinData$bmi1, breaks=c(-Inf,cuts,Inf), labels=obLevels)
twinData$obese2=cut(twinData$bmi2, breaks=c(-Inf,cuts,Inf), labels=obLevels)
 
htLevels = c('short', 'tall')
cuts = quantile(twinData[, "ht1"], probs = c(.5), na.rm = TRUE) # 1.6499
twinData$high1=cut(twinData$ht1, breaks=c(-Inf,cuts,Inf), labels=htLevels)
twinData$high2=cut(twinData$ht2, breaks=c(-Inf,cuts,Inf), labels=htLevels)
 
ordDVs = c("obese1", "obese2", "high1", "high2")
twinData[, ordDVs] = umxFactor(twinData[, ordDVs])
 
mzData = twinData[twinData$zygosity %in% "MZFF", ]
dzData = twinData[twinData$zygosity %in% "DZFF", ]
 
# Run!
m1 = umxACE(selDVs = c("obese", "high"), dzData = dzData, mzData = mzData, sep = '')

with output:

Found 1 pairs of binary variables:'high1' and 'high2'
 
I am fixing the latent means and variances of these variables to 0 and 1
There were also 1 pair(s) of ordinal variables:'obese1' and 'obese2'
No continuous variables
Running ACE with 11 parameters
ACE -2 × log(Likelihood) = 11570.778                                       

Table: Standardized parameter estimates from a 2-factor Cholesky ACE model. A: additive genetic; C: common environment; E: unique environment.

a1 a2 c1 c2 e1 e2
obese 0.795 0.333 0.506
high 0.026 0.899 -0.348 . -0.062 0.258

Table: Means

obese1 high1 obese2 high2
intercept 0.006 0 0.006 0
gdash's picture
Offline
Joined: 11/29/2021 - 17:56
Perhaps a data issue?

Thank you again for your help with this! I ran the script you provided in the R twinData and it worked perfectly on my end, too. Unfortunately, I had less success when I applied the code to my data. I wasn't able to create ordinal factors using the umx code here...I kept getting a "node stack overflow" error after I ran this part:

ordDVs = c("var1_T1", "var1_T2", "var2_T1", "var2_T2")
myData[, ordDVs] = umxFactor(myData[, ordDVs])

For what it's worth, the variables are already categorical (0,1) but, from what I have gathered, they still need to be structured so that umx recognizes them as such? I ended up having success at this step with mxFactor, and ran the umxACE models in question on ordinal factors created that way. For example:

myData$var1_T1 <- mxFactor(myData$var1_T1, levels=c(0:1), ordered=TRUE)

Might that be relevant here? I may be grasping at straws...

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
"node stack overflow"

So the error is not the initial one, nor related to umxFactor, or even umxACE, but rather from specifically a run with your data which prints "node stack overflow" while running your model.

Sounds like an OpenMx error. If you can replicate this, I would immediately run traceback() and then create an issue either at or if you think it is from umx. Include the relevant chunk of console output from umxACE() to the end of traceback() so we can see what this error is and work from there.

Possibly will be helpful to either post the data or use mxGenerateData() to make an anonymised simulation. Honestly the error is not making much sense to me, as a bivariate binary umxACE model is bread-and-butter so we'd see it failing all over the place. I suspect something odd about the data or perhaps your install of R/OpenMx.

Might also be worth updating OpenMx as I see they have a new version on CRAN which fixed some memory leaks, which might be relevant to you.. Newest version:

umx_open_CRAN_page("OpenMx")
[1] ‘2.20.0’

gdash's picture
Offline
Joined: 11/29/2021 - 17:56
Output traceback()

Copied below is the traceback() output- I hope that this corresponds to the output requested!

Here is the output with traceback() from the node stack overflow error when trying use umx to create ordinal factors:

> ordDVs = c("var1_T1", "var1_T2", "var2_T1", "var2_T2")
> myData[, ordDVs] = umxFactor(myData[, ordDVs])
Error: node stack overflow
Error during wrapup: node stack overflow
Error: no more error handlers available (recursive errors?); invoking 'abort' restart
> traceback()
No traceback available

Here is the output with traceback() from using mxFactor to create ordinal factors for analysis:

> myData$var1_T1    <-mxFactor(myData$var1_T1, levels=c(0:1), ordered=TRUE )

> traceback()
1: str(myData)

And here is the output with traceback() from umxACE using factors created with mxFactor (in the step above)

?umxPlotACE options: std=T/F, means=T/F, digits=n, strip_zero=T/F, file=, min=, max =
> #BIVARIATE
> selDVs = c("var1", "var2")
> m1 = umxACE(selDVs = selDVs, dzData = dzData,
+ mzData = mzData, sep = "_T", tryHard = c("ordinal"))
Found 2 pairs of binary variables:'var1_T1', 'var2_T1', 'var1_T2', and 'var2_T2'

I am fixing the latent means and variances of these variables to 0 and 1
No continuous variables

Solution found! Final fit=4667.1459 (started at 4840.7541) (11 attempt(s): 11 valid, 0 errors)

ACE -2 × log(Likelihood) = 4667.146

Table: Standardized parameter estimates from a 2-factor Cholesky ACE model. A: additive genetic; C: common environment; E: unique environment.

| | a1|a2 | c1|c2 | e1|e2 |
|:------|-----:|:--|-----:|:-----|-----:|:-----|
|var1 | 0.596| | 0.315| | 0.738| |
|var2 | 0.799|. | 0.071|0.334 | 0.131|0.478 |

Table: Means (from model$top$expMean)

| |var1_T1 |var2_T1 |var1_T2 |var2_T2 |
|:---------|:-------|:---------|:-------|:---------|
|intercept |0 |0 |0 |0 |

?umxPlotACE options: std=T/F, means=T/F, digits=n, strip_zero=T/F, file=, min=, max =
Warning message:
In matrix(labels, nrow, ncol, byrow = byrow) :
data length [3] is not a sub-multiple or multiple of the number of rows [2]
> traceback(m1)
Error: The argument to the '$' or '[' operator applied on a MxModel object must be a single character string
>

Finally, here is the output from mxGenerateData from the bivariate model.

> mxGenerateData(m1)
$MZ
    var1_T1 var2_T1 var1_T2 var2_T2
1         0         0       0         0
2         0         0       0         0
3         0         0       0         0
4         0         0       0         0
5         0         0       1         0
6         0         0       0         0
7         0         0       0         0
8         0         0       0         0
9         0         0       0         0
10        0         0    <NA>      <NA>
11     <NA>      <NA>       0         0
12        0         0       0         0
13        0         0       0         0
14        1         0    <NA>      <NA>
15        0         0       0         0
16        0         0       0         0
17        0         0    <NA>      <NA>
18     <NA>      <NA>       0         0
19     <NA>      <NA>       1         0
20        0         0       0         0
21        0         0       0         0
22        0         0       0         0
23        1         0       1         0
24        1         0    <NA>      <NA>
25        0         0       0         1
26        0         0       0         0
27        0         0       0         0
28        0         0       0         0
29        0         0       0         0
30        0         0    <NA>      <NA>
31     <NA>      <NA>       0         0
32        0         0       0         0
33     <NA>      <NA>       0         0
34     <NA>      <NA>       0         0
35        1         1    <NA>      <NA>
36        0         0       0         0
37        0         0       0         0
38        0         0       0         0
39        0         0       0         0
40        0         0       0         0
41        0         0       0         0
42        0         0       0         0
43        0         0       0         0
44        0         1       1         1
45        0         0       0         0
46        0         0       1         0
47        0         0    <NA>      <NA>
48        0         0       0         0
49        0         0       1         0
50     <NA>      <NA>       0         0
51        0         0       0         0
52        0         0       0         0
53        0         0       0         0
54        0         0       0         0
55        0         0       0         0
56        1         0       0         0
57        0         0       0         0
58        0         0    <NA>      <NA>
59        0         0       0         0
60        0         0       0         0
61        0         0       0         0
62        0         0    <NA>      <NA>
63        0         0       0         0
64     <NA>      <NA>       0         0
65        0         0       0         0
66        0         0       0         0
67        0         0    <NA>      <NA>
68        0         0       0         0
69        0         0       0         0
70        0         0       0         0
71        1         0       1         1
72        0         0       0         0
73        0         0       0         0
74        0         0       0         0
75        0         0    <NA>      <NA>
76        0         0       0         0
77        0         0       0         0
78        0         0       0         0
79        0         0       0         0
80     <NA>      <NA>       0         0
81        0         0       0         0
82        0         0       0         0
83        0         0    <NA>      <NA>
84        0         0    <NA>      <NA>
85        0         0       0         0
86        0         0       0         0
87     <NA>      <NA>       0         0
88        0         0       0         0
89     <NA>      <NA>       0         0
90        1         0    <NA>      <NA>
91        1         0       1         0
92        0         0    <NA>      <NA>
93     <NA>      <NA>       0         0
94        0         0       0         0
95        0         0       0         0
96        0         0       0         0
97        0         0       0         0
98        0         0       0         0
99        0         0       0         0
100       0         0    <NA>      <NA>
101       0         0    <NA>      <NA>
102       0         0       0         0
103       0         0    <NA>      <NA>
104       0         0       0         0
105    <NA>      <NA>       0         0
106    <NA>      <NA>       0         0
107    <NA>      <NA>       0         0
108       0         0       1         0
109       0         0       0         0
110    <NA>      <NA>       0         0
111       0         0       0         0
112       0         0    <NA>      <NA>
113    <NA>      <NA>       0         0
114       0         0       0         0
115       0         0       0         0
116       0         0       0         0
117       0         0       0         0
118       0         0       0         0
119       0         0       0         0
120       0         0       1         0
121       1         0       0         0
122       0         0    <NA>      <NA>
123       0         0       0         0
124       0         0       0         0
125       0         0       0         0
126       0         0       0         0
127       0         0       0         0
128    <NA>      <NA>       0         0
129       0         0       0         0
130       0         0       0         0
131       0         0       0         0
132       0         0       0         0
133       1         0       0         0
134       0         0       0         0
135       0         0    <NA>      <NA>
136       0         0       0         0
137       0         0       0         0
138    <NA>      <NA>       0         0
139       1         0       0         0
140       0         0       0         0
141       0         0       0         0
142       0         0       0         0
143    <NA>      <NA>       0         0
144       0         0       0         0
145       0         0       0         0
146       0         0    <NA>      <NA>
147       0         0       0         0
148       0         0       0         0
149       0         0       0         0
150       0         0       0         0
151       0         0       0         0
152       0         0       0         0
153       0         0       0         0
154       0         0       0         0
155       0         0       0         0
156       0         0       0         0
157       0         0       1         0
158       0         0       1         0
159       0         0       0         0
160       0         0       0         0
161       0         0       0         0
162       0         0    <NA>      <NA>
163       0         0       0         0
164       0         0       0         0
165       0         0       0         0
166       0         0       0         0
167       0         0       0         0
168       0         0       0         0
169       0         0    <NA>      <NA>
170       0         0       0         0
171       0         0       0         0
172       1         0       0         0
173       0         0       0         0
174       0         0       0         0
175       0         0    <NA>      <NA>
176       0         0       0         0
177       0         0       0         0
178       0         0       0         0
179       1         0       0         0
180       0         0       0         0
181       0         0       1         0
182       0         0       1         1
183       0         0       0         0
184       0         0       0         0
185    <NA>      <NA>       0         0
186       0         0    <NA>      <NA>
187       0         0       0         0
188       0         0       0         0
189    <NA>      <NA>       0         0
190       0         0       0         0
191       0         0       0         0
192       0         0       0         0
193       0         0    <NA>      <NA>
194       0         0       0         0
195       0         0       0         0
196       0         0    <NA>      <NA>
197    <NA>      <NA>       0         0
198       0         0    <NA>      <NA>
199       0         0       0         0
200       0         0       0         0
201       0         0       0         0
202       0         0       0         0
203       0         0       0         0
204       0         0       0         0
205       0         0       0         0
206       0         0       0         0
207       0         0    <NA>      <NA>
208       0         0       0         0
209       0         0       1         0
210       1         0       1         1
211    <NA>      <NA>       0         0
212       0         0       0         0
213       0         0       0         0
214       0         0       0         0
215       0         0       0         0
216       0         0       0         0
217       0         0       0         0
218       0         0    <NA>      <NA>
219    <NA>      <NA>       0         0
220       0         0       0         0
221       0         0       0         0
222       0         0       0         0
223       0         0       0         0
224       0         0    <NA>      <NA>
225       0         0       0         0
226       0         0       0         0
227       0         0       0         0
228    <NA>      <NA>       0         0
229       0         0       0         0
230       1         0       0         0
231       0         0       0         0
232       0         0       0         0
233       1         0       0         0
234       1         0       1         1
235       1         1       0         0
236       0         0       1         0
237       0         0       0         0
238    <NA>      <NA>       0         0
239       0         0       0         0
240       0         0       0         0
241       0         0    <NA>      <NA>
242       0         0       0         0
243       0         0       0         0
244       0         0       0         0
245       0         0       0         0
246    <NA>      <NA>       0         0
247       0         0       0         0
248    <NA>      <NA>       0         0
249       0         0       0         0
250       0         0       0         0
 [ reached 'max' / getOption("max.print") -- omitted 2015 rows ]
 
$DZ
    var1_T1 var2_T1 var1_T2 var2_T2
1      <NA>      <NA>       0         0
2         1         0       0         0
3         0         0       1         0
4         0         0    <NA>      <NA>
5         0         0       0         0
6         0         0       0         0
7         0         0       0         0
8      <NA>      <NA>       1         0
9         0         0       0         0
10        0         0       0         0
11        0         0       0         0
12        0         0       0         0
13        0         0    <NA>      <NA>
14        0         0       0         0
15        0         0       0         0
16     <NA>      <NA>       0         0
17        0         0       0         0
18        0         0       0         0
19        0         0       0         0
20     <NA>      <NA>       0         0
21        0         0       0         0
22        0         0       1         0
23        0         0       0         0
24        0         0    <NA>      <NA>
25        0         0       0         0
26        0         0       0         0
27        0         0       0         0
28        0         0       0         0
29        0         0       0         0
30        0         0       0         0
31        0         0       0         0
32        0         0       0         0
33        0         0       0         0
34        0         0       0         0
35     <NA>      <NA>       0         0
36     <NA>      <NA>       0         0
37        0         0    <NA>      <NA>
38     <NA>      <NA>       1         0
39     <NA>      <NA>       1         0
40        0         0       0         0
41        0         0       0         0
42     <NA>      <NA>       0         0
43        0         0       0         0
44        0         0       0         0
45     <NA>      <NA>       1         0
46     <NA>      <NA>       0         0
47        0         0       0         0
48        0         0       0         0
49        0         0       0         0
50        0         0    <NA>      <NA>
51        0         0       0         0
52        0         0       0         0
53        0         0       0         0
54        0         0       0         0
55        0         0    <NA>      <NA>
56        0         0       0         0
57        0         0       0         0
58        0         0       0         0
59        0         0       1         0
60        0         0       0         0
61        0         0    <NA>      <NA>
62     <NA>      <NA>       0         0
63        0         0       1         0
64        0         0       0         0
65        0         0    <NA>      <NA>
66        0         0       0         0
67        1         0       0         0
68        0         0    <NA>      <NA>
69     <NA>      <NA>       0         0
70     <NA>      <NA>       0         0
71        0         0       0         0
72     <NA>      <NA>       0         0
73        0         0       0         0
74        1         0       0         0
75     <NA>      <NA>       0         0
76        0         0       1         1
77        0         0       0         0
78        1         0       0         0
79     <NA>      <NA>       0         0
80        0         0       0         0
81        1         1       0         0
82        0         0       0         0
83        0         0       0         0
84        0         0       0         0
85        0         0    <NA>      <NA>
86        0         0       1         0
87        0         0       0         0
88        0         0       0         0
89        0         0    <NA>      <NA>
90        0         0       0         0
91        0         0       0         0
92        0         0       0         0
93        0         0    <NA>      <NA>
94        0         0       1         0
95        0         0       0         0
96        0         0       0         0
97     <NA>      <NA>       0         0
98     <NA>      <NA>       0         0
99        0         0    <NA>      <NA>
100       0         0    <NA>      <NA>
101       0         0       0         0
102       0         0    <NA>      <NA>
103       0         0       0         0
104       0         0       0         0
105       0         0       0         0
106       0         0       0         0
107       0         0    <NA>      <NA>
108       0         0       0         0
109       1         0       0         0
110       0         0       0         0
111       0         0    <NA>      <NA>
112       0         0       0         0
113    <NA>      <NA>       0         0
114       0         0       0         0
115    <NA>      <NA>       1         0
116       0         0       0         0
117       0         0    <NA>      <NA>
118    <NA>      <NA>       0         0
119       0         0    <NA>      <NA>
120       0         0       0         0
121       0         0       0         0
122       0         0       0         0
123       0         0       0         0
124       0         0    <NA>      <NA>
125       0         0       0         0
126       0         0       0         0
127       0         0       0         0
128       0         0       0         0
129       0         0    <NA>      <NA>
130       0         0       0         0
131       0         0       0         0
132       0         0       0         0
133       0         0       0         0
134       0         0       0         0
135       0         0       0         0
136       0         0       0         0
137       0         0       0         0
138       0         0       0         0
139       0         0       0         0
140       0         0       0         0
141       0         0       0         0
142       0         0       0         0
143       0         0    <NA>      <NA>
144       0         0       0         0
145       0         0       0         0
146       0         0    <NA>      <NA>
147       0         0       0         0
148    <NA>      <NA>       0         0
149       0         0       0         0
150       0         0       0         0
151       0         0       1         1
152       0         0       0         0
153       0         0       0         0
154       0         0       0         0
155       0         0       0         0
156    <NA>      <NA>       0         0
157       0         0       1         0
158    <NA>      <NA>       0         0
159       0         0       0         0
160       0         0    <NA>      <NA>
161    <NA>      <NA>       0         0
162       0         0       1         0
163       0         0    <NA>      <NA>
164       0         0       0         0
165       0         0       0         0
166    <NA>      <NA>       0         0
167       0         0       0         0
168       0         0       0         0
169    <NA>      <NA>       0         0
170       0         0       0         0
171       0         0       0         0
172       0         0       0         0
173       1         0       0         0
174       0         0       0         0
175    <NA>      <NA>       0         0
176       0         0       0         0
177       0         0    <NA>      <NA>
178       0         0       0         0
179       0         0       0         0
180       0         0       0         0
181       1         0       0         0
182       0         0       0         0
183       0         0    <NA>      <NA>
184    <NA>      <NA>       0         0
185       0         0       0         0
186       0         0       0         0
187       0         0       0         0
188       0         0       0         0
189       0         0       0         0
190       0         0       0         0
191       0         0       0         0
192    <NA>      <NA>       0         0
193       0         0    <NA>      <NA>
194       0         0       0         0
195       0         0    <NA>      <NA>
196       0         0       0         0
197       0         0       0         0
198       0         0       0         0
199       0         0       0         0
200       1         0    <NA>      <NA>
201       0         0       0         0
202       0         0       0         0
203    <NA>      <NA>       0         0
204       0         0       0         0
205       0         0       0         0
206    <NA>      <NA>       0         0
207       0         0       0         0
208       0         0       0         0
209       0         0       0         0
210       0         0       0         0
211       0         0       0         0
212       0         0       0         0
213       0         0       0         0
214       0         0    <NA>      <NA>
215       0         0       1         0
216       0         0    <NA>      <NA>
217       0         0       0         0
218       0         0       0         0
219       0         0    <NA>      <NA>
220       0         0       1         1
221       0         0    <NA>      <NA>
222    <NA>      <NA>       0         0
223       0         0       0         0
224       0         0       0         0
225       0         0       0         0
226       1         0       0         0
227    <NA>      <NA>       0         0
228       0         0       0         0
229       0         1       0         0
230    <NA>      <NA>       0         0
231       0         0       0         0
232       0         0       0         0
233       0         0       0         0
234       0         0       0         0
235       0         0       0         0
236       0         0       0         0
237       0         0       1         0
238       0         0       0         0
239       0         0    <NA>      <NA>
240       0         0       0         0
241       1         0       0         0
242       0         0       0         0
243       0         0       0         0
244       0         0       0         0
245       0         0       0         0
246    <NA>      <NA>       0         0
247       0         0       0         0
248       0         0       0         0
249       0         0    <NA>      <NA>
250       0         0       0         0
 [ reached 'max' / getOption("max.print") -- omitted 1631 rows ]

I also went ahead and updated OpenMx as recommended. Please let me know if there is any other information or output I can provide. Thank you for taking time to assist!

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
success and a bit more info

Glad mxFactor got you working. So your columns might not be what umxFactor is expecting - I like to have error checking that makes this always work or else clearly say why to the user.

Would you mind please post what this code returns so I can see what you are feeding in (before you pass it into mxFactor?

str(myData$var1_T1)
table(myData$var1_T1)
gdash's picture
Offline
Joined: 11/29/2021 - 17:56
Code output

Here is what I get when I run the code you kindly provided with each of the variables.

> str(myData$var1_T1)
 num [1:4146] NA 0 0 0 1 0 0 0 0 0 ...
> table(myData$var1_T1)
 
   0    1 
3331  253 
> str(myData$var1_T2)
 num [1:4146] 0 1 0 0 0 0 0 0 0 0 ...
> table(myData$var1_T2)
 
   0    1 
3270  304 
> str(myData$var2_T1)
 num [1:4146] NA 0 0 0 0 0 0 0 0 0 ...
> table(myData$var2_T1)
 
   0    1 
3540   44 
> str(myData$var2_T2)
 num [1:4146] 0 0 0 0 0 0 0 0 0 0 ...
> table(myData$var2_T2)
 
   0    1 
3524   50 

Thank you again for taking time to assist!

gdash's picture
Offline
Joined: 11/29/2021 - 17:56
Apologies for the multiple

Apologies for the multiple posts! I realized that my last post was a bit convoluted- I was able to structure my variables correctly using mxFactor, but still got the data length error when running the bivariate models on those variables within umxACE. I hope that makes sense! Thank you!

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
umxFactor works great

ah.. that makes sense as umxFactor is working just fine:

tmp = twinData[, c("ht1", "ht2")]
tmp$ht1 = 0; tmp$ht1[twinData$ht1 >1.66] = 1
tmp$ht2 = 0; tmp$ht2[twinData$ht2 >1.66] = 1
x = umxFactor(tmp[, c("ht1", "ht2")])
str(x)
 
'data.frame':    3808 obs. of  2 variables:
 $ ht1: Ord.factor w/ 2 levels "0"<"1": 2 1 1 1 1 1 2 1 2 2 ...
  ..- attr(*, "mxFactor")= logi TRUE
 $ ht2: Ord.factor w/ 2 levels "0"<"1": 2 1 2 1 1 1 2 1 2 2 ...
  ..- attr(*, "mxFactor")= logi TRUE