curious lack of warning/error
Posted on

Attachment | Size |
---|---|
curiousProblem.R | 1.99 KB |
dz.csv | 1.58 KB |
Forums
In fitting a bivariate threshold model using a definition variable, OpenMx converged but the final result gave the following predicted covariance matrix
InitT1 InitT2
InitT1 1.00000 1.48088
InitT2 1.48088 1.00000
InitT1 InitT2
InitT1 1.00000 1.48088
InitT2 1.48088 1.00000
Obviously not positive definite. Yet I did not get any warnings or errors.
Script and data attached.
Greg
PS Could the problem be in
omxMnor(preCov, c(0, 0), c(-Inf, -Inf), c(t, t))
Log in or register to post comments
In reply to PS Could the problem be in by carey
It's a bug!
> omxMnor(matrix(c(1,0,0,1),2,2), c(0, 0), c(-Inf, -Inf), c(0,0))
[,1]
[1,] 0.25
> omxMnor(matrix(c(1,0,0,1),2,2), c(0, 0), c(-Inf, -Inf), c(1.282,1.282))
[,1]
[1,] 0.8101416
> omxMnor(matrix(c(1,90,90,1),2,2), c(0, 0), c(-Inf, -Inf), c(1.282,1.282))
[,1]
[1,] 0.5056822
> omxMnor(matrix(c(1,90,1,90),2,2), c(0, 0), c(-Inf, -Inf), c(1.282,1.282))
[,1]
[1,] 0.5370363
Log in or register to post comments
In reply to It's a bug! by neale
Well maybe it's a bug
and also fixed a couple of minor errors in the example script (reading & mxFactoring the data)
> omxMnor(matrix(c(1,.5,.5,1),2,2), c(0, 0), c(-Inf, -Inf), c(0,0))
[,1]
[1,] 0.3333333
> omxMnor(matrix(c(1,.3,.5,1),2,2), c(0, 0), c(-Inf, -Inf), c(1, 1))
[,1]
[1,] 0.7281473
> omxMnor(matrix(c(1,.3,.3,1),2,2), c(0, 0), c(-Inf, -Inf), c(1, 1))
[,1]
[1,] 0.7281473
I don't see anything wrong with the standardization code (in omxAlgebraFunctions.c) called before the call to SADMVN to get the integral:
void omxStandardizeCovMatrix(omxMatrix* cov, double* corList, double* weights) {
// Maybe coerce this into an algebra or sequence of algebras?
if(OMX_DEBUG) { Rprintf("Standardizing matrix."); }
int rows = cov->rows;
for(int i = 0; i < rows; i++) {
weights[i] = sqrt(omxMatrixElement(cov, i, i));
}
for(int i = 0; i < rows; i++) {
for(int j = 0; j < i; j++) {
corList[((i*(i-1))/2) + j] = omxMatrixElement(cov, i, j) / (weights[i] * weights[j]);
}
}
}
Log in or register to post comments
In reply to It's a bug! by neale
Any fix soon? Bet many users
In the interim, suggest using constraints to make certain the matrix is pd.
Log in or register to post comments