Custom standard errors for covariance matrix input

78 views
Skip to first unread message

jono.m....@gmail.com

unread,
Feb 10, 2018, 7:28:42 AM2/10/18
to lavaan

Hi everyone,

I'm trying to use lavaan to decompose the additive genetic covariances between variables along a particular path diagram (no latent variables). The additive genetic covariances are estimated externally and input into lavaan as a covariance matrix.

The external model also gives estimated standard errors for the AG covariances, and I would like to input these into lavaan (they are much larger than the standard errors for ordinary covariances with the same sample size). I am hoping that lavaan can use these to calculate standard errors for path coefficients and composite variables.

Is there any way to do this? As far as I can tell, lavaan only takes sample sizes as input, not standard errors. Of course, I could write a script to fudge the sample size input so that lavaan standard errors are approximately correct, but this seems like a very inelegant (and not completely general) solution.*

Grateful for any help anyone can offer.

Cheers,
Jono

*A related question - how does lavaan calculated the standard errors of variances of exogenous variables given a covariance matrix as input? The normal approximation of 2sigma^2/(n-1) seems to differ slightly from what lavaan calculates.

Terrence Jorgensen

unread,
Feb 12, 2018, 11:01:22 AM2/12/18
to lavaan
Is there any way to do this? As far as I can tell, lavaan only takes sample sizes as input, not standard errors.

SEs are the the square-roots of diagonal elements of the asymptotic covariance matrix (ACOV) of the estimated parameters.  If you have access to ACOV from the external software that estimated your (co)variance components, you can supply it to lavaan() using the NACOV= argument.  But I think you would still need sample size, because lavaan expects N times the ACOV.

*A related question - how does lavaan calculated the standard errors of variances of exogenous variables given a covariance matrix as input? The normal approximation of 2sigma^2/(n-1) seems to differ slightly from what lavaan calculates.

From the second derivative of the maximum likelihood fitting function, or some other closed-form solution for least-squares estimators.  You can find some details here:


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

Stas Kolenikov

unread,
Feb 12, 2018, 5:10:25 PM2/12/18
to lav...@googlegroups.com
I'd combine bootstrapping the current sample and simulating a covariance restriction from N( reported estimate, reported std. error). You'd have to combine the results on your own; maybe there is a way to convince lavaan that the resulting set of coefficient estimates can be interpreted as bootstrap estimates -- that would be up to Yves to comment on.



-- Stas Kolenikov, PhD, PStat (ASA, SSC)  @StatStas
-- Senior Scientist, Abt Associates @AbtDataScience
-- Program Chair (2018), Survey Research Methods Section of the American Statistical Association
-- Opinions stated in this email are mine only, and do not reflect the position of my employer
-- http://stas.kolenikov.name
 

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+unsubscribe@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

Jono Henshaw

unread,
Feb 13, 2018, 7:31:31 AM2/13/18
to lav...@googlegroups.com
Thank you very much for your answers, Terrence and Stas.

Terrence, for your strategy I would naively try the following syntax (minimal working example below):

fit <- sem(path.model.structure,
                     sample.cov = cov.matrix,
                     NACOV=sample.size*acov.matrix
                     sample.nobs = sample.size)
summary(fit)

Here acov.matrix is the square of the matrix of estimated standard errors from the external model (I think this makes sense?)

Unfortunately it doesn't seem to matter what the value of acov.matrix is - lavaan's estimates of the standard errors remain the same. Am I making a very basic error? I'm not sure what format the ACOV matrix is meant to be in. I couldn't understand the lavaan documentation on this point.


Minimal working example:

library(lavaan)

lower <-'
1
0.02195847    0.106496
0.02449926    0.05205956    0.151877'

cov.matrix <-
  getCov(lower, names = c("Z","M","R"))

acov.matrix.lower <-'
0.067
0.0036    0.00076
0.0051    0.00063    0.0015'

acov.matrix <-
  getCov(acov.matrix.lower, names = c("Z","M","R"))

pathmodel <- 'Z~~varZ*Z
M~bMZ*Z
R~bRZ*Z+bRM*M'

fit <- sem(pathmodel,
                     sample.cov = cov.matrix,
                     NACOV=100*acov.matrix, #changing this does not change the output
                     sample.nobs = 100)
summary(fit)


--
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/VBhGBiLeTfE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+unsubscribe@googlegroups.com.

Terrence Jorgensen

unread,
Feb 14, 2018, 6:13:29 AM2/14/18
to lavaan
Here acov.matrix is the square of the matrix of estimated standard errors from the external model (I think this makes sense?)

Squared SEs (on the diagonal), yes.

Unfortunately it doesn't seem to matter what the value of acov.matrix is - lavaan's estimates of the standard errors remain the same. Am I making a very basic error? I'm not sure what format the ACOV matrix is meant to be in. I couldn't understand the lavaan documentation on this point.

I haven't used this option before, so maybe Yves can chime in about its use.  Perhaps you need to set the option se="none" so that lavaan() will not calculate SEs in the usual way.

alha...@colorado.edu

unread,
Feb 14, 2018, 3:58:30 PM2/14/18
to lavaan
Hi,

I'm unsure which program you are using to get your measures of additive genetic variance.  My institute has been developing a toolbox for this approach for a little while now that should help. I will echo the DWLS squares approach in general. However, I would caution against using the standard errors to judge the accuracy of your model and (I believe) that you will find using the Chi-square difference test will be more robust when you transition into the simulation stage of your project.  If you like, I can send you the tool kit once its preprint is available?  If you continue using lavaan, try the Chi-square test as an alternative. 

Alex

Yves Rosseel

unread,
Feb 23, 2018, 1:13:41 PM2/23/18
to lav...@googlegroups.com
> Unfortunately it doesn't seem to matter what the value of acov.matrix is
> - lavaan's estimates of the standard errors remain the same. Am I making
> a very basic error? I'm not sure what format the ACOV matrix is meant to
> be in. I couldn't understand the lavaan documentation on this point.

The (N)ACOV argument can not be used for this. The purpose of this
argument is to provide a custom 'Gamma' matrix to be used for the
computation of the satorra-bentler test statistic. The direct need for
this was the lavaan.survey package.

Yves.

Jono Henshaw

unread,
Mar 6, 2018, 1:56:55 PM3/6/18
to lav...@googlegroups.com
Thanks Yves for the clarification. I guess bootstrapping may be the best option for the moment...

Reply all
Reply to author
Forward
0 new messages