[R-meta] Non-positive definite variance-covariance matrix
James Pustejovsky
jepu@to @end|ng |rom gm@||@com
Mon Aug 19 03:39:34 CEST 2019
Erik,
A few possibilities occur to me:
1) Is the data frame sorted by ID? If not, then the split-calculate-bldiag
calculations will return a matrix that is not in the same order as the
original data frame.
2) Why do you use sapply rather than lapply in creating the remove_zero_mat
object? Perhaps it makes no difference.
3) To further isolate the problem, it might be useful to check for
positive-definiteness of the component covariance matrices. The matrixcalc
package provides a handy function for doing so:
library(matrixcalc)
lapply(remove_zero_mat, is.positive.definite)
James
On Sun, Aug 18, 2019 at 12:42 PM E. van der Meulen <E.vdrMeulen_1 using uvt.nl>
wrote:
> Dear all,
>
> I am trying to run a multivariate meta-analysis for a review. For this
> review I included multiple effect sizes from single studies into my
> analysis. The number of effect sizes from a single study range from 1 to
> 36. To account for covariance between effect sizes extracted from the same
> sample, I created a variance-covariance matrix for each study with multiple
> effect sizes (which is the majority). I am using a syntax I have used
> before, in the previous attempt it worked perfectly. However, in this new
> study I am continuously ending up with the same error message:
>
> Error in .ll.rma.mv(opt.res$par, reml = reml, Y = Y, M = V, A = A, X.fit
> = X, :
> Final variance-covariance matrix not positive definite.
> In addition: Warning message:
> In rma.mv(dat$ESP, V, mods = ~1, random = list(~1 | id/nummer), :
> 'V' appears to be not positive definite.
>
> In which V is the variance-covariance matrix I made. As far as I know an
> error due to 'non-positive definite matrices' can occur in cases in which
> negative or exactly zero eigenvalues appear anywhere in any of the
> matrices. As far as I can determine this is not the case. What could be the
> problem? If it helps this is full the syntax:
>
>
> library(metafor) # For meta-analysis
> library(clubSandwich) # For cluster-robust variance-covariance matrix
> library(foreign)
>
> dat<- read.spss("TEST.sav", to.data.frame= TRUE)
>
> list_mat<- split(dat[ ,c("v1p", "v2p", "v3p", "v4p", "v5p", "v6p")],
> dat$id)
>
> remove_zero<- lapply(list_mat, function(x) x[ ,colSums(x) != 0])
>
> remove_zero_mat<- sapply(remove_zero, as.matrix)
>
> V<- bldiag(remove_zero_mat)
>
> PTSD<- rma.mv(dat$ESP, V, mods= ~ 1, random= list(~ 1| id/nummer),
> data=dat)
>
> summary (PTSD,digits=3)
>
> In which:
> V = the covariance-variance matrices
> ESP = the effect size
> v1p to v6p = dimensions of the variance-covariance matrices
>
> Thanks in advance.
>
> Kind regards,
>
> Erik van der Meulen
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-meta-analysis mailing list
> R-sig-meta-analysis using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-meta-analysis
>
[[alternative HTML version deleted]]
More information about the R-sig-meta-analysis
mailing list