Hi Mike and other users,

I have a question concerning the the function asycov in the preparatory process for a Meta-Analysis using SEM and the WLS-Function. I have a manually created pooled correlation matrix (6x6) as there are some correlations I didn’t compute by myself. The problem is, that there are 4 missing values which resulted in the following error term when trying to calculate the covariance matrix with the asycov function:

if (!is.pd(x.new)) stop("x is not positive definite!\n"). I tried another smaller correlation matrix with missing values and it worked. Do you know why it does not work in the other case and how I could solve this problem?

I really appreciate your help on that.

Greta

> n3 <-467930

> Matrix3 <- matrix(c(1.0, 0.6267997, 0.1903595, 0.2466638,-0.0789343,0.318283,0.6267997, 1.0, 0.1424942, 0.1421640,-0.0007575,0.2492502,0.1903595, 0.1424942, 1.0, 0.30272,NA ,NA,0.2466638, 0.1421640, 0.3027200, 1.0, -0.185531, 0.2236561,-0.0789343, -0.0007575,NA ,-0.185531,1,-0.2447741,0.318283,0.2492502,NA,0.2236561,-0.2447741,1), ncol=6)

> Matrix3

[,1] [,2] [,3] [,4] [,5] [,6]

[1,] 1.0000000 0.6267997 0.1903595 0.2466638 -0.0789343 0.3182830

[2,] 0.6267997 1.0000000 0.1424942 0.1421640 -0.0007575 0.2492502

[3,] 0.1903595 0.1424942 1.0000000 0.3027200 NA NA

[4,] 0.2466638 0.1421640 0.3027200 1.0000000 -0.1855310 0.2236561

[5,] -0.0789343 -0.0007575 NA -0.1855310 1.0000000 -0.2447741

[6,] 0.3182830 0.2492502 NA 0.2236561 -0.2447741 1.0000000

> asyCov(Matrix3, n3, cor.analysis=TRUE, dropNA = FALSE, as.matrix=TRUE)

Fehler in if (!is.pd(x.new)) stop("x is not positive definite!\n") :

Fehlender Wert, wo TRUE/FALSE nötig ist

Hi Greta,

Since there are two missing correlations in the matrix, I don't know how you can use it to fit models. The logical approach is to delete the variable (x3) and simplify your models (see Approach 1 below).

If you still want to estimate the asymptotic covariance matrix with the missing correlations, a workaround is to replace NA with 0 before calculating the asymptotic covariance matrix (see Approach 2 below). This may have some negative consequences. Please use it on your own risk.

## Approach 1

Matrix_withoutx3 <- Matrix3[-3, -3]

asyCov(Matrix_withoutx3, n3)

## Approach 2

Matrix_replacedx3 <- Matrix3

Matrix_replacedx3[is.na(Matrix_replacedx3)] <- 0

asyCov(Matrix_replacedx3, n3)

Mike

Hi Mike,

thanks a lot for your help, I greatly appreciate your support! I deleted the variables and simplified the models. Then, I followed the instructions on page 270 ff. in your book for the random-effects model in a path model. But when running the wls-function, I still have problems with my models

8a (OpenMx Status 1: 6, also after rerun()),

10a and 10b (with 10b I tried 2 alternative Smatrices: The first one is provided in your book and the second one in another forum entry here.) But there is an error term:

"Fehler in wls(M10b, AsyCov10b, n10b, Amatrix = A10b, Smatrix = S10b, intervals.type = "LB", :

Objekt 'out' nicht gefunden

Zusätzlich: Warnmeldung:

In runHelper(model, frontendStart, intervals, silent, suppressWarnings, :

SLSQP: Failed due to singular matrix E or C in LSQ subproblem or rank-deficient equality constraint subproblem or positive directional derivative in line search"

I'm a bit confused why it doesn't work especially with these 3 matrices.

For the matrices 8b, 9 and 12, there are NAs for the lbound and ubound.

I recognize that these are the models with multiple mediators AND multiple outcomes.

Can you maybe also help me with this?

Thanks!

Greta

Hi Greta,

Some of these errors are related to the errors in finding the 95% CI of the RMSEA. I have modified the summary.wls() so that it returns NA rather than throwing out an error when it fails in finding the 95% CI of the RMSEA. You may install the developmental version by:

install.packages("devtools")

devtools::install_github("mikewlcheung/metasem")

Some of the other errors may also be improved by using diag.constraints = FALSE rather than diag.constraints = TRUE. Please note that diag.constraints = TRUE was required in fitting mediation models when I wrote my book. I have recently fixed this issue so that diag.constraints = FALSE also works fine for mediation models.

Moreover, I would use intervals.type="z" rather than intervals.type="LB" since the sample sizes are huge.

Hope it helps.

Mike

Hi Mike,

thanks a lot for your help. I followed your advices and then, the models worked.

I'm a bit disappointed about the results as the model fits are very (!) bad. It is notable, that the degrees of freedom are very small. When I try to increase model fit during correlated residuals, I get saturated models.

Do you know a function for figuring out, which of the residuals correlate especially high? Then I could maybe limit the correlating residuals to these. Or do you know other possibilities to increase model fits or a solution why my degrees of freedom are that low? It is possible that these are the reason for bad model fit?

Thank you!

Greta

Hi Greta,

I don't have good suggestions. What you are asking is basically the modification indices. I am afraid that it's not available for the wls() function.

Actually, I am not surprised by the large test statistics. Your sample sizes are exceptionally large (several hundred thousands). With such large sample sizes, your test is very powerful. Nearly all proposed models will be rejected.

By the way, the use of asyCov() may not be necessary here. Since you already have the correlation matrices (M1 to M12), you may use ML estimation by assuming that the data are multivariate normal. As your sample sizes are huge, results based on WLS and ML estimation should be very similar.

Mike