Bivariate umxACE model data length error

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!
more info needed: traceback(); umxVersion();
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")
```
Log in or register to post comments
In reply to more info needed: traceback(); umxVersion(); by tbates
Additional Information
"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.
Log in or register to post comments
here's a repro script: works fine here
# 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 |
Log in or register to post comments
In reply to here's a repro script: works fine here by tbates
Perhaps a data issue?
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...
Log in or register to post comments
In reply to Perhaps a data issue? by gdash
"node stack overflow"
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’
Log in or register to post comments
In reply to "node stack overflow" by tbates
Output traceback()
Here is the output with traceback() from the node stack overflow error when trying use umx to create ordinal factors:
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 )
And here is the output with traceback() from umxACE using factors created with mxFactor (in the step above)
Finally, here is the output from mxGenerateData from the bivariate model.
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 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
11
12 0 0 0 0
13 0 0 0 0
14 1 0
15 0 0 0 0
16 0 0 0 0
17 0 0
18
19
20 0 0 0 0
21 0 0 0 0
22 0 0 0 0
23 1 0 1 0
24 1 0
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
31
32 0 0 0 0
33
34
35 1 1
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
48 0 0 0 0
49 0 0 1 0
50
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
59 0 0 0 0
60 0 0 0 0
61 0 0 0 0
62 0 0
63 0 0 0 0
64
65 0 0 0 0
66 0 0 0 0
67 0 0
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
76 0 0 0 0
77 0 0 0 0
78 0 0 0 0
79 0 0 0 0
80
81 0 0 0 0
82 0 0 0 0
83 0 0
84 0 0
85 0 0 0 0
86 0 0 0 0
87
88 0 0 0 0
89
90 1 0
91 1 0 1 0
92 0 0
93
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
101 0 0
102 0 0 0 0
103 0 0
104 0 0 0 0
105
106
107
108 0 0 1 0
109 0 0 0 0
110
111 0 0 0 0
112 0 0
113
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
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
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
136 0 0 0 0
137 0 0 0 0
138
139 1 0 0 0
140 0 0 0 0
141 0 0 0 0
142 0 0 0 0
143
144 0 0 0 0
145 0 0 0 0
146 0 0
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
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
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
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
186 0 0
187 0 0 0 0
188 0 0 0 0
189
190 0 0 0 0
191 0 0 0 0
192 0 0 0 0
193 0 0
194 0 0 0 0
195 0 0 0 0
196 0 0
197
198 0 0
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
208 0 0 0 0
209 0 0 1 0
210 1 0 1 1
211
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
219
220 0 0 0 0
221 0 0 0 0
222 0 0 0 0
223 0 0 0 0
224 0 0
225 0 0 0 0
226 0 0 0 0
227 0 0 0 0
228
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
239 0 0 0 0
240 0 0 0 0
241 0 0
242 0 0 0 0
243 0 0 0 0
244 0 0 0 0
245 0 0 0 0
246
247 0 0 0 0
248
249 0 0 0 0
250 0 0 0 0
[ reached 'max' / getOption("max.print") -- omitted 2015 rows ]
$DZ 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
var1_T1 var2_T1 var1_T2 var2_T2
1
2 1 0 0 0
3 0 0 1 0
4 0 0
5 0 0 0 0
6 0 0 0 0
7 0 0 0 0
8
9 0 0 0 0
10 0 0 0 0
11 0 0 0 0
12 0 0 0 0
13 0 0
14 0 0 0 0
15 0 0 0 0
16
17 0 0 0 0
18 0 0 0 0
19 0 0 0 0
20
21 0 0 0 0
22 0 0 1 0
23 0 0 0 0
24 0 0
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
36
37 0 0
38
39
40 0 0 0 0
41 0 0 0 0
42
43 0 0 0 0
44 0 0 0 0
45
46
47 0 0 0 0
48 0 0 0 0
49 0 0 0 0
50 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
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
62
63 0 0 1 0
64 0 0 0 0
65 0 0
66 0 0 0 0
67 1 0 0 0
68 0 0
69
70
71 0 0 0 0
72
73 0 0 0 0
74 1 0 0 0
75
76 0 0 1 1
77 0 0 0 0
78 1 0 0 0
79
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
86 0 0 1 0
87 0 0 0 0
88 0 0 0 0
89 0 0
90 0 0 0 0
91 0 0 0 0
92 0 0 0 0
93 0 0
94 0 0 1 0
95 0 0 0 0
96 0 0 0 0
97
98
99 0 0
100 0 0
101 0 0 0 0
102 0 0
103 0 0 0 0
104 0 0 0 0
105 0 0 0 0
106 0 0 0 0
107 0 0
108 0 0 0 0
109 1 0 0 0
110 0 0 0 0
111 0 0
112 0 0 0 0
113
114 0 0 0 0
115
116 0 0 0 0
117 0 0
118
119 0 0
120 0 0 0 0
121 0 0 0 0
122 0 0 0 0
123 0 0 0 0
124 0 0
125 0 0 0 0
126 0 0 0 0
127 0 0 0 0
128 0 0 0 0
129 0 0
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
144 0 0 0 0
145 0 0 0 0
146 0 0
147 0 0 0 0
148
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
157 0 0 1 0
158
159 0 0 0 0
160 0 0
161
162 0 0 1 0
163 0 0
164 0 0 0 0
165 0 0 0 0
166
167 0 0 0 0
168 0 0 0 0
169
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
176 0 0 0 0
177 0 0
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
184
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
193 0 0
194 0 0 0 0
195 0 0
196 0 0 0 0
197 0 0 0 0
198 0 0 0 0
199 0 0 0 0
200 1 0
201 0 0 0 0
202 0 0 0 0
203
204 0 0 0 0
205 0 0 0 0
206
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
215 0 0 1 0
216 0 0
217 0 0 0 0
218 0 0 0 0
219 0 0
220 0 0 1 1
221 0 0
222
223 0 0 0 0
224 0 0 0 0
225 0 0 0 0
226 1 0 0 0
227
228 0 0 0 0
229 0 1 0 0
230
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
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
247 0 0 0 0
248 0 0 0 0
249 0 0
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!
Log in or register to post comments
success and a bit more info
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)
Log in or register to post comments
In reply to success and a bit more info by tbates
Code output
> 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!
Log in or register to post comments
In reply to Code output by gdash
Apologies for the multiple
Log in or register to post comments
In reply to Apologies for the multiple by gdash
umxFactor works great
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
Log in or register to post comments