How to extract bootstrapped values ?

32 views
Skip to first unread message

Keon-Woong Moon

unread,
Jul 4, 2019, 9:59:53 AM7/4/19
to lavaan
Hi,

I have one question.

I’d like to extract bootstrapped values for indirect effect. 

For example,


X <- rnorm(100)
M <- 0.5*X + rnorm(100)
Y <- 0.7*M + rnorm(100)
Data <- data.frame(X = X, Y = Y, M = M)
model <-'Y~c*X
M~a*X
Y~b*M
#indirect effect
ab:=a*b
total:=c+(a*b)
'
RNGkind("L'Ecuyer-CMRG")
fit=sem(model=model,data=Data,se="boot",iseed=123)
parameterEstimates(fit,ci=TRUE,boot.ci.type="bca.simple")

    lhs op     rhs label   est    se     z pvalue ci.lower ci.upper
1     Y  ~       X     c 0.054 0.109 0.496  0.620   -0.153    0.275
2     M  ~       X     a 0.477 0.104 4.604  0.000    0.259    0.672
3     Y  ~       M     b 0.430 0.092 4.678  0.000    0.253    0.616
4     Y ~~       Y       0.875 0.111 7.893  0.000    0.690    1.142
5     M ~~       M       0.928 0.133 7.001  0.000    0.697    1.230
6     X ~~       X       0.821 0.000    NA     NA    0.821    0.821
7    ab :=     a*b    ab 0.205 0.067 3.061  0.002    0.095    0.367
8 total := c+(a*b) total 0.259 0.114 2.277  0.023    0.051    0.496


I have an estimate of indirect effect (ab) 0.205 and it’s 95% confidence interval is -0.095-0.367.

But how can I get the 1000 bootstrapped values for the indirect effect ab?  


Keon-Woong Moon

Yves Rosseel

unread,
Jul 4, 2019, 4:29:53 PM7/4/19
to lav...@googlegroups.com
I am afraid they are currently hidden in an internal slot.

But I have just added a "coef.boot" option for lavInspect/lavTech, which
will extract these values. It is available in lavaan 0.6-5.1453, which
you can install by typing in R:

install.packages("lavaan", repos = "http://www.da.ugent.be", type =
"source")

This should then work:

library(lavaan)

X <- rnorm(100)
M <- 0.5*X + rnorm(100)
Y <- 0.7*M + rnorm(100)
Data <- data.frame(X = X, Y = Y, M = M)
model <-'Y~c*X
M~a*X
Y~b*M
#indirect effect
ab:=a*b
total:=c+(a*b)
'
RNGkind("L'Ecuyer-CMRG")
fit=sem(model=model,data=Data,se="boot",iseed=123)

lavTech(fit, "coef.boot", add.labels = TRUE)

Yves.


Reply all
Reply to author
Forward
0 new messages