2

I don't understand how a variance-covariance matrix may not be symmetric. Is it due to the way the numbers are rounded?

If we take the example presented on the merDeriv package to get the full variance-covariance matrix (fixed and random parameters):

lme4fit <- glmer(corr ~ jmeth + (1 | item), data = finance,
                  family = binomial, nAGQ = 20)
 # variance covariance matrix for all parameters
 nnn=vcov(lme4fit, full = TRUE, ranpar = "var")
 isSymmetric(nnn)
[1] FALSE

The problem is that I use the variance-covariance matrix obtained in glmer and merDeriv in rtmvnorm (function to generate numbers from a multivariate normal distribution) for Monte-Carlo simulations. However, I have errors in the following, because the variance-covariance matrix never passes the test of

checkSymmetricPositiveDefinite(H, name = "H")

included in the rtmvnorm function for the sigma (Covariance matrix used for the random numbers generation).

What should I do?

Flora Grappelli
  • 659
  • 9
  • 26
  • 1
    Try `isSymmetric(unname(nnn))`. From the help page `?isSymmetric`, section Details: *"Note that a matrix m is only symmetric if its rownames and colnames are identical. Consider using unname(m)."* – Rui Barradas May 26 '21 at 16:33
  • In fact, this causes me error in my code. The `isSymmetric` is included in a package function. I solved this problem by forcing the symmetry of the matrix. – Flora Grappelli May 26 '21 at 16:38

0 Answers0