You are here

Two errors at Stage 1

5 posts / 0 new
Last post
Anonymous's picture
Anonymous (not verified)
Two errors at Stage 1

Hi all,

Thank you for this wonderful software and very useful forum for running metaSEM. I'm new to both R and metaSEM, but I've generally found it to be relatively straightforward with all the great resources available.

There are a pair of metaSEM models I'm running that have been giving me two separate error messages that I can't wrap my head around. These occur when running the Stage 1 portion of the script:

  1. Error: The observed covariance matrix is not a symmetric matrix
    (This seems akin to problems described here [https://openmx.ssri.psu.edu/thread/1039] where values estimated at, say, the 16th decimal point end up being slightly different above/below the diagonal. The fix seems to simply be to round numbers, but I'm not sure how to access the guts of the metaSEM package to do this).

  2. Error in lambda[length(lambda)]/lambda[1] > tol :
    invalid comparison with complex values
    (I'm not sure what this means).

Also, just to be clear, I don't receive both of these messages at the same input matrices but rather on separate metaSEMs I'm running. Any ideas? Thanks!

--B

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Hi, Brian. 1. For the first

Hi, Brian.

  1. For the first issue, how about the following code?

library(metaSEM)
A <- matrix(c(1, 0.5, 0.499999,1), ncol=2)
isSymmetric(A)

FALSE

B <- (A+t(A))/2
isSymmetric(B)

TRUE

  1. For the second issue, it seems that it is from the is.pd() function. Suppose my.df is your list of matrices, what is the error message by calling is.pd(my.df)?

If it still does not work, would you mind posting the data and syntax here?

Mike

Anonymous's picture
Brian S Connelly (not verified)
Hi Mike, Thanks very much for

Hi Mike,

Thanks very much for the reply and for troubleshooting this with me!

  1. Running the code you provided generates this output:
    > library(metaSEM)
    > A <- matrix(c(1, 0.5, 0.499999,1), ncol=2)
    > isSymmetric(A)
    [1] FALSE
    > # FALSE
    >
    > B <- (A+t(A))/2
    > isSymmetric(B)
    [1] TRUE
    > # TRUE

  2. Running the code you provided generates the same error message:
    > is.pd(input)
    Error in lambda[length(lambda)]/lambda[1] > tol :
    invalid comparison with complex values

I've posted the code I used below for analysis (1) and for analysis (2), along with accompanying data sets as attachments (o_ojp.dat is for analysis 1, and a_ojp.dat is for analysis 2). Thanks!

--B

*****Analysis 1, using o_ojp.dat:

library(ellipse)
library(MASS)
library(metaSEM)

Read data in

library(plyr)
input<-readFullMat("o_ojp.dat")
rename(input,c("1"="connelly","2"="borkenau","3"="ostendorf","4"="muck","5"="hulsheger","6" = "riemann"))

n <- c(97, 308, 730, 89, 86, 824)

Stage 1 analysis

fixed1 <- tssem1(input, n, method="FEM", model.name="Fixed effects model Stage 1 analysis")
summary(fixed1)

*****Analysis 2, using a_ojp.dat

library(ellipse)
library(MASS)
library(metaSEM)

Read data in

library(plyr)
input<-readFullMat("a_ojp.dat")
rename(input,c("1"="connelly","2"="borkenau","3"="ostendorf","4"="muck","5"="hulsheger","6" = "riemann"))

n <- c(97, 308, 730, 89, 86, 824)

Stage 1 analysis

fixed1 <- tssem1(input, n, method="FEM", model.name="Fixed effects model Stage 1 analysis")
summary(fixed1)

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Hi, Brian.Both errors are

Hi, Brian.

Both errors are related to the 6th study in the dataset. They are not symmetric. Attached is the syntax to "fix" them. Please note that I don't know the content. Therefore, I don't know whether or not the "fix" makes sense. For example, if the asymmetry is due to reading the wrong data, it is not appropriate to fix them this way.

Regards,
Mike

Anonymous's picture
Brian S Connelly (not verified)
Thank you!

Hi Mike,

Thanks very much for your help; I'm embarrassed to say that this looks like a simple copy and paste error. Argh! I'm sorry for the trouble, but I really appreciate your taking the time to help sort through it!

Cheers,
--B