You are here

Definition variables not working correctly

By switching on debugging OMX_DEBUG and OMX_DEBUG_ROWS in omxFIMLObjective.c I could see the predicted covariance matrices being used to compute the likelihood. Now, what is interesting is that they are fine (i.e. they agree with oldMx) for the first two cycles through the 5 data vectors of the attached example. But the second two cycles differ and they are incorrect. The problem is set up with zero free parameters, so not many cycles are involved (and I'm not sure why there are 4 but perhaps some are for checking purposes). Here's an output snippet from one of the latter cycles:

Beginning FIML Evaluation.
Means: (1 x 2) [col-major]
21.381010 21.381010
Processing Definition Vars.
Populating column 2 (value 24.00) into matrix 29034872.
Local Means: (1 x 2) [col-major]
21.381010 21.381010
Local Data Row: (1 x 2) [col-major]
22.592700 23.297300
Local Covariance Matrix: (2 x 2) [col-major]
0.779381 0.311257
0.311257 0.792818
Change in Total Likelihood is -0.652 + 4.953 + 3.676 = 7.977, total Likelihood is 7.977

This was 8.072 originally. The covariance matrix seems to be dirty, in that the previous covariance matrix printed earlier in the output was:

Local Covariance Matrix: (2 x 2) [col-major]
0.792818 0.311257
0.311257 0.792818

so it seems like only the first element of this covariance matrix was updated, rather than the whole thing. The way the model is set up:

    mxAlgebra(rbind (cbind(A + C + E  , h %x% A + C),
                     cbind(h %x% A + C, A + C + E)), dimnames = list(selVars, selVars), 

the two variances should never differ. Note that the -2 ln likelihood on the first two passes, 22.581, agrees with the oldMx output, but the latter two passes it is different and incorrect.

Due to inability to attach .mxo files (another ticket needed for this imho), I paste here the output from Mx1, which OpenMx definition variables script UnivariateTwinAnalysisModerated_Matrix_FixedValues3DZonly.R should match.

MATRIX A
This is a FULL matrix of order 1 by 1
1
1 0.33519982

MATRIX B
This is a FULL matrix of order 1 by 1
1
1 0.00000000

MATRIX C
This is a FULL matrix of order 1 by 1
1
1 -0.94893229

MATRIX E
This is a FULL matrix of order 1 by 1
1
1 -0.10128330

MATRIX H
This is a FULL matrix of order 1 by 1
1
1 0.50000000

MATRIX M
This is a FULL matrix of order 1 by 1
1
1 21.38100968

MATRIX R
This is a FULL matrix of order 1 by 1
1
1 25.00000000

MATRIX S
This is a FULL matrix of order 1 by 1
1
1 25.00000000

MATRIX T
This is a FULL matrix of order 1 by 1
1
1 0.01743014

MATRIX U
This is a FULL matrix of order 1 by 1
1
1 0.03321213

MATRIX V
This is a FULL matrix of order 1 by 1
1
1 -0.01312430

Vector of OBSERVED means
BMI1 BMI2
Mean 21.90210000 21.74204000

Vector of EXPECTED means
BMI1 BMI2
Mean 21.38100968 21.38100968

(OBSERVED MATRIX is nonexistent for raw data)

EXPECTED COVARIANCE MATRIX
BMI1 BMI2
BMI1 0.79281833
BMI2 0.31125736 0.79281833

Function value of this group: 22.58140797
Where the fit function is -2 * Log-likelihood of raw data

Your model has 0 estimated parameters and 10 Observed statistics

-2 times log-likelihood of data >>> 22.581

Reporter: 
Created: 
Mon, 09/21/2009 - 12:59
Updated: 
Thu, 10/08/2009 - 18:35

Comments

the R attachment just seems to be the datafile again?

Oops deleted the wrong one... here's the right one. I note in passing that with edit it is not possible to change files previously uploaded.

It's also worth noting that because this bug crops up only on some data vectors and not others, it is possible to get pretty decent looking parameter estimates from models, as if everything is hunky dory except for not quite agreeing with Mx1.0 on the matter of -2lnL

Mike

r846 works for the code provided.

Since this is a simplified version of a larger script, please try the new code with the complete script, and reopen the issue with a new example if the problem continues to present itself.

Looks like the problem was in the way objective functions marked themselves as dirty/clean at each iteration cycle. The error showed up only in the case of FIML objectives that were included in the calculation of another objective function but still had definition variables.

Automatically closed -- issue fixed for 2 weeks with no activity.