Hi all,

I encounter a problem of "x is not positive definite" when using Cheung's Two-stage MASEM. Could anyone provide some clues?

I attach part of my dataset as samples. My R-syntax is "random1<-tssem1(entrymode,samplesize,method="REM",RE.type="Diag")" . This command ends with an error information:

Error in (function(x, n, cor.analysis = TRUE, dropNA = FALSE, as.matrix = TRUE), : x is not positive definite!

Actually, I utilized Cheung's TSSEM one year ago with "metaSEM_0.8-2". The old version could inform me which matrix is non-positive, so that I could delete the matrix and went though the fist stage. But now I updated to "metaSEM_0.8-4". This new version seems not to tell us which one is non-positive.

Best,

Ryan

Attachment | Size |
---|---|

sample data.txt | 11.98 KB |

Hi, Ryan.

Since there are lots of missing data in your sample data, it is reasonable to expect that the analysis will not work.

The attached file shows how to test the positive definiteness of each study and to display the pattern of data that are not missing. The analysis was based on 0.8-5 (the developmental version of metaSEM). It is available at https://dl.dropboxusercontent.com/u/25182759/metaSEM_0.8-5.tar.gz

Hope it helps.

Regards,

Mike

Thanks Mike!

I will try your suggestions soon, but it seems to tell me whether the whole dataset (an integration of all matrices) is positive definite or not. If it may tell which individual matrices are not, I will be able to delete them and go through the first stage. In fact, deleting non-positive definite matrices is what I did in my previous work with TSSEM. After deleting the non-positive ones, I did obtained an integrated matrix that entered into the stage two.

By the way, I tried also 'is.positive.definite' (from "matrixcalc") and 'cor.smooth' (from "psych"). I utilized the first one to test whether an individual matrix is positive definite, and the latter one to ''smooth" non-positive matrix to positive. Both worked well.

But the two syntax have two problems for application in TSSEM. First, they require different format of matrix to TSSEM. Specifically, they ask a whole matrix rather than a lower triangle. Also, they can only deal matrix one by one, but not a group of matrices together. It would be a huge task, if someone (including me) has tens or hundreds of matrices. Certainly, the 'cor.smooth' can help us retain some non-positive definite matrices.

Best,

Ryan

Hi, Ryan.

I fully understand the need to check the positive definiteness of the data. That's why I have written the is.pd() function. The revised version (based on 0.8-5) returns TRUE (for pd matrix), FALSE (for non-pd matrix), and NA (for matrices with NA). It accepts a list of matrices as input, e.g.,

library(metaSEM)

## PD

A <- diag(1, 3)

## non-PD

B <- matrix(c(1, 2, 2, 1), ncol = 2)

## Return NA when there are NA in the matrix

C <- A

C[2, 1] <- C[1, 2] <- NA

(my.df <- list(A, B, C))

## [[1]]

## [,1] [,2] [,3]

## [1,] 1 0 0

## [2,] 0 1 0

## [3,] 0 0 1

##

## [[2]]

## [,1] [,2]

## [1,] 1 2

## [2,] 2 1

##

## [[3]]

## [,1] [,2] [,3]

## [1,] 1 NA 0

## [2,] NA 1 0

## [3,] 0 0 1

is.pd(my.df)

## [1] TRUE FALSE NA

Cheers,

Mike

Thanks Mike!

I tried your suggestions. The output is attached.

Sorry to say, but it seems that "is.pd" and "pattern.na" are not helpful enough for "NA"s. Specifically, while the output shows that matrices No 1 and 2 are "NA", I can still run through "tssem1" with the two matrices. As my computer is still running tssem1 with the two matrices, I didn't attach the output. You know the stage one always takes a long computing time. But at least, the two matrices are accepted by "tssem1".

This suggests that if I include 3 or 13 or 113, the "tssem1" may also run. However, I don't know which individual matrix may work. I probably have to test one by one ;)

Would you please recommend another solution?

Best,

Ryan

p.s., the No 119 matrix is a zero matrix. All elements (except diagonal ones) are zeros.

Dear Ryan,

From your attachment, there are 24 variables. This leads to 276 correlation coefficients. Even if the random effects are uncorrelated, you still need to estimate 276 fixed effects (correlation coefficients) and 276 random effects (variances of the correlation coefficients) in the stage 1 analysis. Since there are only 119 studies with lots of missing data (as indicated by the pattern.na() function), I will be surprised if my package works!

Regards,

Mike

Dear Mike,

Thanks for your reply!

I will think about this.

Best,

Ryan

Dear Ryan, Dear Mike,

I encountered a similar problem in stage two of the analysis. The error reads as follows.

Error in wls(Cov = pooledS, asyCov = asyCov, n = tssem1.obj$total. n, Amatrix = Amatrix; :

"asyCov" is non positive definite.

Stage 1 runs fine.

I traced the matrix to the following line of code:

asyCov <- vcov(tssem1.obj, select="fixed")

is.pd(vcov(tssem1,obj, select="fixed") indeed returns FALSE.

Is it possible to correct the matrix as Ryan suggested in this thread? If a correction is possible, what part of the tssem1.obj should we override?

What could be the underlying cause? Why would stage one return a matrix which is non positive definite?

If its due to the underlying correlation matrices, are there guidelines on how many matrices should be incorporated and how many missing variables and missing correlations are allowed?

I thought it would be best to post here. Didn't intent to hijack the thread.

Regards,

Nick

Hi, Nick.

Could you send me the data, input and output to my email? I will try to take a look at it.

My guess is that it is likely to be caused by either the missing data or the small number of studies. Wothke (1993) gave a useful overview on this issue.

If you really want to fix it manually, you may use the wls() function directly.

Wothke, W. (1993). Nonpositive definite matrices in structural modeling. In K. A. Bollen & J. S. Long (Eds.), Testing Structural Equation Models (pp. 256–293). Newbury Park, CA: Lawrence Erlbaum Assoc.

Regards,

Mike