# Not positive definite variance-covariance matrix in meta-regression using 'metafor'

I'm having a strange problem running a meta-regression using the function rma.mv() in the 'metafor' package in R.

Since some of my data are from multiple-endpoint studies, I have calculated the variance-covariance matrix so that correlations between outcomes are taken into account. I'm also using random effects at study and treatment level. As far as I'm aware, I have now covered all issues with regard to dependent effect sizes.

The model looks like this:

cov_mod <- rma.mv(Hedges_g, cov, mods = ~ days, random = ~ treatment | study, data = rev)


When running the code, it gives this error message:

Error in rma.mv(Hedges_g, cov9, mods = ~days, random = ~1 | treatment/study,  :
Error during optimization.
In rma.mv(Hedges_g, cov9, mods = ~days, random = ~1 | treatment/study,  :
V appears to be not positive definite.


I have discovered that the problem lies with one particular study (9 effect sizes in total, coming from 3 treatment groups that were each tested at 3 moments in time). When I remove this study from the data set, the code runs without problem.

Thus, apparently this particular study causes the matrix to be 'not positive definite'. I have read that this likely means that "at least one of [the] variables can be expressed as a linear combination of the others" (source).

However, here comes the strange thing: I have replaced all values in the variance-covariance matrix relating to this particular study with random numbers between 0-1 (maintaining the symmetry), and the error message remains unchanged. I am puzzled, because the matrix can no longer be linearly predictable if it contains random numbers.

What could be the issue?

• A random covariance matrix is unlikely to be positive definite! – whuber Aug 4 '16 at 13:33
• Could you post the 9x9 var-cov matrix for that study? (ideally so that it can be directly read into R, so using dput()). – Wolfgang Aug 4 '16 at 15:59
• @Wolfgang Here you go: structure(c(0.029, 0.0421, 0.0363, 0, 0, 0, 0, 0, 0, 0.0421, 0.0297, 0.037, 0, 0, 0, 0, 0, 0, 0.0363, 0.037, 0.0418, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0342, 0.0472, 0.0383, 0, 0, 0, 0, 0, 0, 0.0472, 0.0345, 0.0431, 0, 0, 0, 0, 0, 0, 0.0383, 0.0431, 0.0465, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0231, 0.0368, 0.0208, 0, 0, 0, 0, 0, 0, 0.0368, 0.0231, 0.023, 0, 0, 0, 0, 0, 0, 0.0208, 0.023, 0.0337), .Dim = c(9L, 9L), .Dimnames = list(NULL, c("V40", "V41", "V42", "V43", "V44", "V45", "V46", "V47", "V48"))) – Johanna Aug 5 '16 at 8:04
• That's not a valid var-cov matrix. For example, the first two variances are 0.0290 and 0.0297. The covariance is 0.0421. This would imply a correlation of 1.434514, which is not possible. – Wolfgang Aug 5 '16 at 8:13
• Thank you for the insight - I will work on it and then get back to this thread. – Johanna Aug 5 '16 at 11:58