sim () function produces warning about negative ov variances

49 views
Skip to first unread message

Elisabeth Zureck

unread,
Nov 7, 2017, 10:19:24 AM11/7/17
to lavaan
Dear all,
I'm trying to run a power analysis for a latent mediation model using the simsem package.

I defined my population (based on lavaan output on piolot data indicating good overall fit) and my analysis models as follows:

population.model <- "WB  =~ 1*gs.ind1  + 1.004*gs.ind2
                      EXT =~ 1*ext.ind1 + 0.757*ext.ind2
                      AUF =~ 1*auf.ind1 + 1.103*auf.ind2

                      WB ~ 0.051*EXT + 0.580*AUF
                      AUF ~ 0.302*EXT

                      gs.ind1  ~ 3.911*1
                      gs.ind2  ~ 3.860*1
                      ext.ind1 ~ 3.918*1
                      ext.ind2 ~ 3.660*1
                      auf.ind1 ~ 3.236*1
                      auf.ind2 ~ 3.099*1
                      WB  ~ 0*1
                      EXT ~ 0*1
                      AUF ~ 0*1
                     
                      gs.ind1  ~~ 0.061*gs.ind1
                      gs.ind2  ~~ 0.123*gs.ind2
                      ext.ind1 ~~ 0.096*ext.ind1
                      ext.ind2 ~~ 0.420*ext.ind2
                      auf.ind1 ~~ 0.155*auf.ind1
                      auf.ind2 ~~ 0.050*auf.ind2
                      WB  ~~ 0.323*WB
                      EXT ~~ 0.603*EXT
                      AUF ~~ 0.285*AUF"



analysis.model  <- "WB =~ gs.ind1 + gs.ind2
                    EXT =~ ext.ind1 + ext.ind2
                    AUF =~ auf.ind1 + auf.ind2

                    WB ~ c*EXT + b*AUF
                    AUF ~ a*EXT
                    indirekt := a*b
                    total := a*b + c"

Afterwards I tried to simulate data and model the analysis data with varying sample sizes to estimate the power:
med.n <- sim(model=analysis.model, n = rep(seq(50,200,10),10), generate = population.model,
             lavaanfun = "sem", std.lv=FALSE)

This analysis resulted in 50 warnings:
50: In lav_object_post_check(object) :
  lavaan WARNING: some estimated ov variances are negative


Do you have any ideas what might be wrong about my models?
Thank you in advance for your help!

Terrence Jorgensen

unread,
Nov 8, 2017, 5:47:50 AM11/8/17
to lavaan
Do you have any ideas what might be wrong about my models?

Probably nothing.  You have specified some residual variances that are very close to zero (e.g., auf.ind2 ~~ 0.050*auf.ind2), and you have some very small sample sizes (as low as N = 50).  So estimates of near-zero variances are quite likely to be negative in several samples just due to sampling error.  Try looking at the M and SD of the sampling distribution of that estimate across replications -- you can probably guess that sometimes it is going negative.

Because you know the cause is just sampling error, you don't need to worry about it.  If it were a single real data set, you would want to test whether the negative variance is consistent with sampling error (if not, then model misspecification is the other alternative explanation).


Terrence D. Jorgensen
Postdoctoral Researcher, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam

Elisabeth Zureck

unread,
Nov 8, 2017, 7:59:52 AM11/8/17
to lavaan

Dear Terrence,
Thank you very much for your explanation. I will look at the sampling distribution of my ov residual variances.
Best Elisabeth
Reply all
Reply to author
Forward
0 new messages