You are here

Cholesky model WLS

11 posts / 0 new
Last post
MichelNivard's picture
Offline
Joined: 05/16/2017 - 10:55
Cholesky model WLS

Hi,

I am running Hermine's Cholesky script (Boulder "cdrom" 2016) only change I make is that I Use mxDataWLS to precompute the polychoric correlations and WLS weights:

DZdata <- mxDataWLS(DZ)

This runs without errors.

I then proceed to adjust the mxExpectation to reflect the nature of the data:

expMZ <- mxExpectationNormal( covariance="expCovMZ", means="meanG",thresholds="Tr", dimnames=selVars )
expDZ <- mxExpectationNormal( covariance="expCovDZ", means="meanG",thresholds="Tr", dimnames=selVars )

(Threshodls fixed at 0 and 1, so covariance and means can be freely estimated)

I proceed to specify the correct fit function:

funWLS <- mxFitFunctionWLS()

When I run the model I get the following error:
Running mulACEc with 185 parameters
Error in svd(X) : infinite or missing values in 'x'

Any suggestions?

MichelNivard's picture
Offline
Joined: 05/16/2017 - 10:55
I found the issue, the

I found the issue, the Weights matrix in the WLS data object contained NaN and Inf values.

MichelNivard's picture
Offline
Joined: 05/16/2017 - 10:55
Any sugestion on how to

Any sugestion on how to proceed? Does the fact that the fullWeights matrix is illbehaved detrimental to my analysis? Or are their ways to proceed? Open

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
can't replicate the WLS twinData problem?

So you'r using this script as a basis, and you're getting NaN and Inf in the "Weights" matrix when you create a WLS data object?

A reproducible code chunk always helps:

# Load and make a copy of the Data
data(twinData)
binData = twinData
# Create Binary "obesity" Variables based on bmi, and turn them into ordered factors
binData$ob1 = ifelse(twinData[,'bmi1'] > 22, 1, 0)
binData$ob2 = ifelse(twinData[,'bmi2'] > 22, 1, 0)
binData$ob1 = mxFactor(binData$ob1, levels = 0:1)
binData$ob2 = mxFactor(binData$ob2, levels = 0:1)
 
#select the MZ and DZ pairs
mzData    <- binData[binData$zyg %in% 1, c("ob1", "ob2")]
dzData    <- binData[binData$zyg %in% 3, c("ob1", "ob2")]
#and make into WLS
dzDataWLS <- mxDataWLS(dzData)

This object doesn't have a Weights slot, but the acov/fullWeights matrix looks OK?

 dzDataWLS@acov; dzDataWLS@fullWeight
     [,1]        [,2] [,3] [,4] [,5]        [,6]        [,7]
[1,]    0   0.0000000    0    0    0   0.0000000   0.0000000
[2,]    0 109.6199337    0    0    0  -0.8991427  -0.2871061
[3,]    0   0.0000000    0    0    0   0.0000000   0.0000000
[4,]    0   0.0000000    0    0    0   0.0000000   0.0000000
[5,]    0   0.0000000    0    0    0   0.0000000   0.0000000
[6,]    0  -0.8991427    0    0    0 175.0299098 -41.9596843
[7,]    0  -0.2871061    0    0    0 -41.9596843 170.9643746
MichelNivard's picture
Offline
Joined: 05/16/2017 - 10:55
Tim,

Tim,

Your obviously right it would be great to reproduce the error. However it seems to be dependent on the data, and I am not allowed upload my data.

Ill work on simulating data which reproduces the error.

Michel

mhunter's picture
Offline
Joined: 07/31/2009 - 15:26
Working on it

Hi Michel,

I'm not sure what the problem is with this just yet. WLS is generally safe to use and I'm very glad someone outside the dev team is trying it!

I'll be checking into this over the next few days to see what the problem is and hopefully solve it swiftly. My current guess is there's a small bug in WLS. For arguments sake, is there anything strange about the data? Tons of missingness? 400 variables?

MichelNivard's picture
Offline
Joined: 05/16/2017 - 10:55
Hi,

Hi,

78 variables, I can reproduce the error with as little as 10 variables in the model. Missingness is << 10% for any given variable.

If there is a bug it must be local to MxDataWLS() because clearly the NaN's in the Weights matrix are the error.

summary(as.vector(MZdata$fullWeight))
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
-Inf -72 0 NaN 73 Inf 310

The summary of the data:

q1m7t1 q3m7t1 q8m7t1 q10m7t1 q13m7t1 q16m7t1 q17m7t1 q20m7t1 q21m7t1 q22m7t1 q1m7t2
0 :3535 0 :1554 0 :2566 0 :2601 0 :4263 0 :3872 0 :3049 0 :3915 0 :3954 0 :2047 0 :3460
1 : 750 1 :2423 1 :1473 1 :1451 1 : 161 1 : 548 1 :1225 1 : 480 1 : 459 1 :2208 1 : 798
2 : 159 2 : 468 2 : 360 2 : 394 2 : 19 2 : 37 2 : 170 2 : 49 2 : 26 2 : 181 2 : 160
NA's: 92 NA's: 91 NA's: 137 NA's: 90 NA's: 93 NA's: 79 NA's: 92 NA's: 92 NA's: 97 NA's: 100 NA's: 118
q3m7t2 q8m7t2 q10m7t2 q13m7t2 q16m7t2 q17m7t2 q20m7t2 q21m7t2 q22m7t2
0 :1723 0 :2633 0 :2570 0 :4258 0 :3898 0 :3165 0 :3940 0 :3971 0 :2170
1 :2288 1 :1423 1 :1484 1 : 148 1 : 515 1 :1111 1 : 441 1 : 423 1 :2086
2 : 411 2 : 297 2 : 378 2 : 14 2 : 21 2 : 156 2 : 46 2 : 30 2 : 168
NA's: 114 NA's: 183 NA's: 104 NA's: 116 NA's: 102 NA's: 104 NA's: 109 NA's: 112 NA's: 112

Best,
Michel

AdminNeale's picture
Offline
Joined: 03/01/2013 - 14:09
N?

Hi Michel

What is the sample size here? Weight matrices can get non-positive definite if the sample size is small. Even with 10 variables we are looking at 10*11/2 = 55 statistics if there is only one threshold per trait. With 78 variables we are talking over 3,000 statistics.

Another possible source of the issue occurs to me - if the data are ordinal and whole rows or columns are empty, then I suspect the threshold estimates could get messy, as one would want to be exactly on top of the next one, and underidentification could occur.

Cheers
Mike

MichelNivard's picture
Offline
Joined: 05/16/2017 - 10:55
Sample size

N MZ -= 4.4k n DZ = 8.5k

Should be sufficinent for the 20 item subset in which the issue now occurs right?

As to your comment about empty rows or columns, rows or columns of what matrix exactly? The data?

mhunter's picture
Offline
Joined: 07/31/2009 - 15:26
Which version?

This is perhaps a silly question, but are you using the latest version of OpenMx? Between 2.6.9 and 2.7.11 there were quite a few improvements to WLS, particularly with regard to missing data.

MichelNivard's picture
Offline
Joined: 05/16/2017 - 10:55
2.7.11

2.7.11