Attachment | Size |
---|---|
practise 1.R [6] | 1.93 KB |
practise2.csv [7] | 10.79 KB |
Dear Mike,
My name is Jing Niu and I am working on a metaSEM research.When I apply the tssem1 function on my dataset, I got the error message saying:
> stage1fixed <- tssem1(Cov=my.vec, n=samplesize, method="FEM")
Error: The observed covariance matrix is not a positive-definite matrix:
1 or more elements of eigen(covMatrix)$values <= 0
In addition: Warning message:
In tssem1FEM(Cov = Cov, n = n, cor.analysis = cor.analysis, model.name = model.name,
My dataset looks like the following:
> my.vec[c(133,135,136,137,139)]
[[1]]
participation indiriver commdriver instrumentdriver indiout hostout
participation 1.00 NA NA NA NA -7.13
indiriver NA NA NA NA NA NA
commdriver NA NA NA NA NA NA
instrumentdriver NA NA NA NA NA NA
indiout NA NA NA NA NA NA
hostout -7.13 NA NA NA NA 1.00
[[2]]
participation indiriver commdriver instrumentdriver indiout hostout
participation 1.00 NA NA NA NA -1.04
indiriver NA NA NA NA NA NA
commdriver NA NA NA NA NA NA
instrumentdriver NA NA NA NA NA NA
indiout NA NA NA NA NA NA
hostout -1.04 NA NA NA NA 1.00
[[3]]
participation indiriver commdriver instrumentdriver indiout hostout
participation 1.000 NA NA NA NA -13.145
indiriver NA NA NA NA NA NA
commdriver NA NA NA NA NA NA
instrumentdriver NA NA NA NA NA NA
indiout NA NA NA NA NA NA
hostout -13.145 NA NA NA NA 1.000
[[4]]
participation indiriver commdriver instrumentdriver indiout hostout
participation 1.00 NA NA NA NA -2.55
indiriver NA NA NA NA NA NA
commdriver NA NA NA NA NA NA
instrumentdriver NA NA NA NA NA NA
indiout NA NA NA NA NA NA
hostout -2.55 NA NA NA NA 1.00
[[5]]
participation indiriver commdriver instrumentdriver indiout hostout
participation NA NA NA NA NA NA
indiriver NA NA NA NA NA NA
commdriver NA NA 1.00 NA NA 2.15
instrumentdriver NA NA NA NA NA NA
indiout NA NA NA NA NA NA
hostout NA NA 2.15 NA NA 1.00
I tried to use the nearPD function to fix the non-positive definition, but got another error term saying:
> nearPD(my.vec[133])
Error in UseMethod("isSymmetric") :
no applicable method for 'isSymmetric' applied to an object of class "list"
Could you please offer some help for my next step? I appreciate a lot for the kind help! ( I attached my data and code following).