You are here

This forum is about the metaSEM package for meta-analysis

11 posts / 0 new
Last post
tbates's picture
Offline
Joined: 07/31/2009 - 14:25
This forum is about the metaSEM package for meta-analysis

Mike Cheung's metaSEM package is introduced here

Post questions to this forum

pascofearon's picture
Offline
Joined: 05/07/2013 - 10:57
bootstrapping of indirect effects

Hi Mike,
Hope you're well. I was just wondering whether there's a simple way to bootstrap the indirect effect in metasem (tssem2 or osmasem).

Thanks,

Best wishes,

Pasco

sharmel's picture
Offline
Joined: 07/31/2023 - 13:19
meta-analytic SEM, why non positive definite message is thrown?

Hello All,

In my reproducible example below, you'll see that Cov_R (sampling covariances for the R matrix) is positive definite.

However, why when I run the following I get an error message saying?:

metaSEM::wls(R, aCov = Cov_R, RAM = RAM3, n = 9201)
> [1] Error: "Cov" is not positive definite.

Thanks,
Simon

--- Full Reproducible R code:

R <- structure(c(1, 0.5846, 0.5476, 0.4127, 0.6029, 0.5104, 0.4724,
0.4289, 0.5846, 1, 0.2701, 0.4449, 0.3114, 0.3607, 0.5946, 0.605,
0.5476, 0.2701, 1, 0.4459, 0.5791, 0.4243, 0.4671, 0.5854, 0.4127,
0.4449, 0.4459, 1, 0.4677, 0.5889, 0.6848, 0.5456, 0.6029, 0.3114,
0.5791, 0.4677, 1, 0.466, 0.578, 0.607, 0.5104, 0.3607, 0.4243,
0.5889, 0.466, 1, 0.6488, 0.5677, 0.4724, 0.5946, 0.4671, 0.6848,
0.578, 0.6488, 1, 0.3737, 0.4289, 0.605, 0.5854, 0.5456, 0.607,
0.5677, 0.3737, 1), dim = c(8L, 8L), dimnames = list(c("L2R",
"L2DA", "L2DF", "L2V", "L2G", "L2P", "L2M", "L2L"), c("L2R", "L2DA", "L2DF", "L2V", "L2G", "L2P", "L2M", "L2L")))

Cov_R <- structure(c(0.0149, 0.0087, 0.0092, 0.0086, 0.0088, 0.0089, 0.0089,
0.0094, 0.009, 0.0094, 0.0093, 0.0088, 0.0087, 0.0087, 0.0088,
0.0096, 0.0085, 0.0089, 0.0093, 0.0085, 0.009, 0.0087, 0.0087,
0.0086, 0.0085, 0.009, 0.0087, 0.0087, 0.0087, 0.018, 0.0086,
0.0087, 0.0087, 0.0089, 0.0087, 0.0087, 0.0087, 0.0087, 0.0087,
0.0088, 0.0092, 0.0095, 0.0087, 0.0087, 0.0085, 0.0088, 0.0087,
0.0088, 0.0087, 0.0087, 0.0087, 0.0086, 0.0088, 0.0087, 0.0087,
0.0087, 0.0092, 0.0086, 0.0143, 0.0087, 0.0086, 0.0088, 0.0088,
0.0093, 0.0088, 0.009, 0.009, 0.0088, 0.0087, 0.0086, 0.0092,
0.0095, 0.0084, 0.0089, 0.0091, 0.0085, 0.0092, 0.0087, 0.0086,
0.0086, 0.0085, 0.009, 0.0087, 0.0085, 0.0086, 0.0087, 0.0087,
0.0132, 0.0087, 0.0087, 0.0086, 0.0086, 0.0088, 0.0087, 0.0086,
0.0085, 0.0089, 0.0087, 0.0089, 0.0086, 0.0088, 0.0087, 0.0086,
0.0084, 0.0086, 0.0089, 0.0086, 0.0084, 0.0084, 0.0086, 0.0088,
0.0087, 0.0088, 0.0087, 0.0086, 0.0087, 0.0122, 0.0088, 0.0086,
0.0087, 0.0087, 0.009, 0.0087, 0.0085, 0.0087, 0.0089, 0.0086,
0.009, 0.0087, 0.0088, 0.0087, 0.0084, 0.0086, 0.0087, 0.0089,
0.0084, 0.0084, 0.0085, 0.0086, 0.0089, 0.0089, 0.0089, 0.0088,
0.0087, 0.0088, 0.0108, 0.0087, 0.0088, 0.0087, 0.0088, 0.0088,
0.0086, 0.0088, 0.0088, 0.0088, 0.0087, 0.0086, 0.0088, 0.0088,
0.0085, 0.0087, 0.0087, 0.0087, 0.0085, 0.0085, 0.0087, 0.0087,
0.0088, 0.0089, 0.0087, 0.0088, 0.0086, 0.0086, 0.0087, 0.0243,
0.0091, 0.0093, 0.0088, 0.0093, 0.0092, 0.0092, 0.0087, 0.0092,
0.0088, 0.0084, 0.0087, 0.0095, 0.009, 0.009, 0.0087, 0.0086,
0.0088, 0.0089, 0.0091, 0.0088, 0.0085, 0.0094, 0.0087, 0.0093,
0.0086, 0.0087, 0.0088, 0.0091, 0.0181, 0.0091, 0.0092, 0.0093,
0.009, 0.009, 0.0087, 0.0091, 0.0099, 0.0084, 0.0089, 0.0092,
0.0086, 0.0092, 0.0087, 0.0087, 0.0087, 0.0086, 0.0092, 0.0087,
0.0086, 0.009, 0.0087, 0.0088, 0.0088, 0.0087, 0.0087, 0.0093,
0.0091, 0.0238, 0.0092, 0.0094, 0.009, 0.0092, 0.0087, 0.0093,
0.0089, 0.0087, 0.0088, 0.0092, 0.0087, 0.0089, 0.0091, 0.0087,
0.0087, 0.0087, 0.009, 0.0091, 0.0087, 0.0094, 0.0087, 0.009,
0.0087, 0.009, 0.0088, 0.0088, 0.0092, 0.0092, 0.0237, 0.0092,
0.0087, 0.0087, 0.0087, 0.0088, 0.0105, 0.0087, 0.0089, 0.0092,
0.0085, 0.0088, 0.0087, 0.0089, 0.0086, 0.0085, 0.0088, 0.0087,
0.0089, 0.0093, 0.0087, 0.009, 0.0086, 0.0087, 0.0088, 0.0093,
0.0093, 0.0094, 0.0092, 0.014, 0.0089, 0.0089, 0.0087, 0.009,
0.009, 0.0085, 0.0088, 0.0093, 0.0087, 0.009, 0.0088, 0.0087,
0.0087, 0.0086, 0.009, 0.0088, 0.0087, 0.0088, 0.0088, 0.0088,
0.0085, 0.0085, 0.0086, 0.0092, 0.009, 0.009, 0.0087, 0.0089,
0.0163, 0.009, 0.0087, 0.0091, 0.0087, 0.0083, 0.0087, 0.0089,
0.0092, 0.0094, 0.0087, 0.0085, 0.0088, 0.0091, 0.0096, 0.0086,
0.0084, 0.0087, 0.0092, 0.0087, 0.0089, 0.0087, 0.0088, 0.0092,
0.009, 0.0092, 0.0087, 0.0089, 0.009, 0.0237, 0.0092, 0.0092,
0.0087, 0.0086, 0.0088, 0.0088, 0.0088, 0.0088, 0.009, 0.0086,
0.0086, 0.0088, 0.0089, 0.009, 0.0087, 0.0087, 0.0095, 0.0086,
0.0087, 0.0089, 0.0088, 0.0087, 0.0087, 0.0087, 0.0087, 0.0087,
0.0087, 0.0092, 0.0309, 0.0087, 0.0087, 0.0087, 0.0088, 0.0087,
0.0087, 0.0086, 0.0087, 0.0089, 0.0086, 0.0087, 0.0087, 0.0087,
0.009, 0.0088, 0.0087, 0.0092, 0.0089, 0.0086, 0.0088, 0.0092,
0.0091, 0.0093, 0.0088, 0.009, 0.0091, 0.0092, 0.0087, 0.0236,
0.0088, 0.0085, 0.0088, 0.0089, 0.0087, 0.0091, 0.009, 0.0086,
0.0087, 0.0087, 0.0092, 0.0091, 0.0086, 0.0096, 0.0087, 0.0095,
0.0086, 0.009, 0.0087, 0.0088, 0.0099, 0.0089, 0.0105, 0.009,
0.0087, 0.0087, 0.0087, 0.0088, 0.0532, 0.0085, 0.009, 0.0093,
0.0085, 0.0091, 0.0086, 0.009, 0.0085, 0.0085, 0.0088, 0.0086,
0.0086, 0.0085, 0.0085, 0.0084, 0.0088, 0.0087, 0.0086, 0.0084,
0.0084, 0.0087, 0.0087, 0.0085, 0.0083, 0.0086, 0.0087, 0.0085,
0.0085, 0.0161, 0.0086, 0.0085, 0.0082, 0.0084, 0.0087, 0.0087,
0.0083, 0.0082, 0.0084, 0.0087, 0.0087, 0.0089, 0.0088, 0.0089,
0.0087, 0.0088, 0.0088, 0.0087, 0.0089, 0.0088, 0.0089, 0.0088,
0.0087, 0.0088, 0.0088, 0.0088, 0.009, 0.0086, 0.0104, 0.0088,
0.0085, 0.0088, 0.0087, 0.0087, 0.0085, 0.0085, 0.0088, 0.0087,
0.0087, 0.0093, 0.0087, 0.0091, 0.0086, 0.0087, 0.0088, 0.0095,
0.0092, 0.0092, 0.0092, 0.0093, 0.0089, 0.0088, 0.0087, 0.0089,
0.0093, 0.0085, 0.0088, 0.0122, 0.0086, 0.0089, 0.0087, 0.0087,
0.0087, 0.0086, 0.0089, 0.0087, 0.0086, 0.0085, 0.0088, 0.0085,
0.0084, 0.0084, 0.0085, 0.009, 0.0086, 0.0087, 0.0085, 0.0087,
0.0092, 0.0088, 0.0087, 0.0087, 0.0085, 0.0082, 0.0085, 0.0086,
0.011, 0.0088, 0.0085, 0.0084, 0.0086, 0.009, 0.0089, 0.0084,
0.0083, 0.009, 0.0087, 0.0092, 0.0086, 0.0086, 0.0087, 0.009,
0.0092, 0.0089, 0.0088, 0.009, 0.0094, 0.0088, 0.0086, 0.0091,
0.0091, 0.0084, 0.0088, 0.0089, 0.0088, 0.0118, 0.0087, 0.0086,
0.0087, 0.0087, 0.0093, 0.0087, 0.0085, 0.0087, 0.0087, 0.0087,
0.0089, 0.0087, 0.0087, 0.0087, 0.0087, 0.0091, 0.0087, 0.0088,
0.0087, 0.009, 0.0087, 0.009, 0.0086, 0.0087, 0.0087, 0.0087,
0.0085, 0.0087, 0.0124, 0.0086, 0.0085, 0.0085, 0.0087, 0.0089,
0.0086, 0.0087, 0.0087, 0.0086, 0.0086, 0.0089, 0.0087, 0.0086,
0.0087, 0.0087, 0.0089, 0.0087, 0.0085, 0.0086, 0.0089, 0.0086,
0.009, 0.0087, 0.0087, 0.0087, 0.0084, 0.0086, 0.0086, 0.0116,
0.0085, 0.0084, 0.0086, 0.0086, 0.0088, 0.0086, 0.0086, 0.0086,
0.0084, 0.0084, 0.0085, 0.0088, 0.0087, 0.0087, 0.0086, 0.0087,
0.0088, 0.0086, 0.0086, 0.0087, 0.0085, 0.0083, 0.0085, 0.0087,
0.0086, 0.0087, 0.0085, 0.0085, 0.0095, 0.0086, 0.0088, 0.0085,
0.0084, 0.0085, 0.0088, 0.0085, 0.0084, 0.0084, 0.0085, 0.0089,
0.0086, 0.0087, 0.0085, 0.0086, 0.0091, 0.0088, 0.0087, 0.0087,
0.0085, 0.0082, 0.0085, 0.0086, 0.009, 0.0087, 0.0085, 0.0084,
0.0086, 0.011, 0.0089, 0.0084, 0.0083, 0.009, 0.0087, 0.009,
0.0086, 0.0085, 0.0087, 0.0091, 0.0092, 0.009, 0.0088, 0.009,
0.0096, 0.0089, 0.0087, 0.0092, 0.0088, 0.0084, 0.0088, 0.0089,
0.0089, 0.0093, 0.0087, 0.0086, 0.0088, 0.0089, 0.0127, 0.0087,
0.0085, 0.0087, 0.0087, 0.0087, 0.0088, 0.0086, 0.0087, 0.0088,
0.0087, 0.0091, 0.0087, 0.0088, 0.0086, 0.009, 0.0087, 0.0091,
0.0086, 0.0087, 0.0087, 0.0087, 0.0084, 0.0087, 0.0089, 0.0086,
0.0085, 0.0084, 0.0087, 0.013, 0.0086, 0.0087, 0.0087, 0.0085,
0.0087, 0.0089, 0.0088, 0.0085, 0.0086, 0.0087, 0.0089, 0.0087,
0.0084, 0.0087, 0.009, 0.0086, 0.0086, 0.0087, 0.0087, 0.0086,
0.0083, 0.0085, 0.0086, 0.0088, 0.0084, 0.0083, 0.0085, 0.0086,
0.0131), dim = c(28L, 28L))

library(metaSEM)

Positive definite checks OK:

is.pd(Cov_R, cor.analysis=FALSE)
> [1] TRUE

ModelC <-
'Comprehension =~ L2L + L2V + L2G
Decoding =~ L2DA + L2DF
Meta =~ L2P + L2M
L2R ~ Comprehension + Decoding
Comprehension ~~ 0 * Meta
Decoding ~ 0 * Meta
Comprehension ~~ Decoding'

RAM3 <- lavaan2RAM(ModelC, obs.variables = varnames,
A.notation = "on", S.notation = "with")

wls(R, aCov = Cov_R, RAM = RAM3, n = 9201)
[1] > "Cov" is not positive definite.

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Dear Simon,

Dear Simon,

The problem is due to the R, not Cov_R.

> is.pd(R)
[1] FALSE

By the way, please use a new subject next time, as unrelated follow-ups may confuse readers.

Mike

sharmel's picture
Offline
Joined: 07/31/2023 - 13:19
Dear Mike,

Dear Mike,

Many thanks for your response. Do you have any suggestion to resolve the problem?

I can think of using nearest PD of R like: is.pd(Matrix::as.matrix(nearPD(R, corr = TRUE)$mat))

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
There is an issue with your

There is an issue with your data. I recommend investigating the cause, such as whether it is due to using pairwise deletion.

While adjusting the data with near PD may help, the more critical question is whether the results obtained from this modified data can be considered trustworthy.

sharmel's picture
Offline
Joined: 07/31/2023 - 13:19
Thanks, Mike. Do you mean

Thanks, Mike. Do you mean investigating whether the primary studies had used pairwise deletion when calculating their correlations OR investigating whether I, as the meta-analyst, have used some kind of deletion, such as na.omit(data), when preparing my data for meta-analysis??

In my case, several of the primary studies have NOT reported on correlations between some pairs of variables. Therefore, the data prepared for meta-analysis contains many NAs for those pairs of variables which I deleted using listwise deletion.

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
It is the latter, as it is a

It is the latter, as it is a meta-analysis.

sharmel's picture
Offline
Joined: 07/31/2023 - 13:19
Thank you, Mike. As I

Thank you, Mike. As I mentioned, several of the primary studies have NOT reported on correlations between some pairs of variables. Therefore, the data prepared for meta-analysis contains many NAs for those pairs of variables which I deleted using listwise deletion i.e., na.omit(data).

Are you suggesting that I don't remove the rows where r values are missing?

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
There is no need to remove

There is no need to remove studies with NA. The tssem1() function uses FIML in OpneMx to handle missing data.

Please refer to the relevant literature and examples.

sharmel's picture
Offline
Joined: 07/31/2023 - 13:19
Thank you, Mike. I'm not

Thank you, Mike. I'm not using tssem1() for the first stage of meta-analysis. Instead, I'm using metafor::rma.mv().