You are here

Use MASEM to explore several potential mediators

8 posts / 0 new
Last post
Xie's picture
Xie
Offline
Joined: 12/23/2015 - 08:36
Use MASEM to explore several potential mediators

Hi Mike,

I have reviewed several MASEM articles as well as the R code. I am excited that it could examine mediation model. However, I found the R code of meta-analytic structural equation modeling which examined only one mediator. Now I want to exam a structural model with three mediators by using MASEM. So, I am just wondering is that possible to use MASEM to explore several potential mediators. If so, please let me how to find the R code.

Thanks a lot,

Yu Xie

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Hi Xie,

Hi Xie,

The answer is yes.

Since it is your data, it is better for you to try it first. You may either use the RAM specification or the lavaan syntax. Many users find it easier to you the lavaan syntax to specify the models. https://www.rdocumentation.org/packages/metaSEM/versions/0.9.10/topics/lavaan2RAM

If you have further questions, please post your questions with your data and R code.

Best,
Mike

Xie's picture
Xie
Offline
Joined: 12/23/2015 - 08:36
Hi Mike,

Hi Mike,

Thank you for your response. I tried to figure out the lavaan syntax by using the example of data(Becker92). It is true that the lavaan syntax is much easier. However, when I inputted the code, it reported an error.

Here is the R code:

> library(metaSEM)
Loading required package: OpenMx
Loading required package: digest
Loading required package: MASS
Loading required package: parallel
OpenMx is not compiled to take advantage of computers with multiple cores.
mxOption(NULL, "Gradient algorithm") is set at "central".
mxOption(NULL, "Optimality tolerance") is set at "6.3e-14".
mxOption(NULL, "Gradient iterations") is set at "2".
"SLSQP" is set as the default optimizer in OpenMx.
> data(Becker09)
> fixed1 <- tssem1(Becker09$data, Becker09$n, method="FEM")
> summary(fixed1)

Call:
tssem1FEM(my.df = my.df, n = n, cor.analysis = cor.analysis,
model.name = model.name, cluster = cluster, suppressWarnings = suppressWarnings,
silent = silent, run = run)

Coefficients:
Estimate Std.Error z value Pr(>|z|)
S[1,2] -0.068497 0.042323 -1.6184 0.1055674
S[1,3] -0.158146 0.041270 -3.8320 0.0001271 ***
S[1,4] 0.371528 0.037348 9.9478 < 2.2e-16 ***
S[2,3] 0.526242 0.030213 17.4179 < 2.2e-16 ***
S[2,4] -0.413506 0.035155 -11.7623 < 2.2e-16 ***

S[3,4] -0.416417 0.035025 -11.8890 < 2.2e-16 ***

Signif. codes: 0 ‘’ 0.001 ‘’ 0.01 ‘’ 0.05 ‘.’ 0.1 ‘ ’ 1

Goodness-of-fit indices:
Value
Sample size 633.0000
Chi-square of target model 208.9383
DF of target model 46.0000
p value of target model 0.0000
Chi-square of independence model 628.7646
DF of independence model 52.0000
RMSEA 0.2367
SRMR 0.2049
TLI 0.6806
CFI 0.7175
AIC 116.9383
BIC -87.7833
OpenMx status1: 0 ("0" or "1": The optimization is considered fine.
Other values may indicate problems.)
> model <- "## Regression paths
+ Per~Cog2PerCog
+ Per~SO2Per
SO
+ Per~SC2PerSC
+ SC~Cog2SC
Cog
+ SC~SO2SCSO
+ Cog~~1
Cog
+ SO~~1SO
+ Cog~~cor
SO
+ Per~~var_PerPer
+ SC~~var_SC
SC"
> RAM <- lavaan2RAM(model, obs.variables=c("Per","Cog","SO","SC"))

Error: could not find function "lavaan2RAM"

So please could you tell me how to fix it?

Many thanks,
Yu Xie

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Hi Xie,

Hi Xie,

The lavaan2RAM() function was added since version 0.9.8. see https://cran.r-project.org/web/packages/metaSEM/NEWS
Can you check your version of the metaSEM package by using sessionInfo()?

Best,
Mike

Xie's picture
Xie
Offline
Joined: 12/23/2015 - 08:36
Hi Mike,

Hi Mike,

The version of metaSEM has been updated and I can use the lavaan syntax. I tried to use samples of metaSEM to build a new model and it worked out. So I will try my data in a couple of days. Thank you for your help.

Best wishes,
Yu Xie

HAMED's picture
Offline
Joined: 06/15/2012 - 02:29
"NA" in random effects tssem2 outputs

Hello Mike;

I am testing a mediation model using random-effects TSSEM. My model has 5 independent variables, two mediators, and one dependent variable. Following the discussions in your book, I am using diag.constraints=TRUE and intervals.type="LB" in my tssem2 function. However, the output of lower and upper bounds for path coefficients (i.e., lbound and ubound) are full of "NA" (see below), making it impossible to realize the significance of the coefficients.

I have also tried the "bootstrapping" approach by removing intervals.type="LB" from tssem2(), but the lbound and ubound values and some of the p-values are out of bound (larger than 1).

Any help to resolve this issue is much appreciated.

Thank you
Hamed

p.s., output sample:

95% confidence intervals: Likelihood-based statistic
Coefficients:
Estimate Std.Error lbound ubound z value Pr(>|z|)
e34 0.3876813 NA NA 0.4495170 NA NA
e35 0.4453518 NA 0.3374589 NA NA NA
e41 0.5160371 NA NA NA NA NA
e42 -0.7434581 NA NA NA NA NA
e46 0.5690236 NA NA NA NA NA
e47 0.1968012 NA NA NA NA NA
e48 0.0236211 NA NA 0.4594243 NA NA
e51 0.3091117 NA NA NA NA NA
e52 0.2292891 NA -8.9579312 NA NA NA
e56 0.1303781 NA NA NA NA NA
e57 0.1407204 NA NA NA NA NA
e58 0.3815477 NA NA NA NA NA
cor21 0.5422623 NA 0.3569298 0.7329471 NA NA
var33 0.4880908 NA 0.4199470 0.5499943 NA NA
var44 0.1379798 NA -4.4750635 NA NA NA
var55 0.2895631 NA NA 0.3977295 NA NA
cor61 0.3459487 NA 0.2309600 0.4612305 NA NA
cor62 0.3219729 NA 0.0928367 0.5583770 NA NA
cor71 0.3176263 NA 0.2371808 0.3981122 NA NA
cor72 0.1137301 NA -0.1421941 0.3679461 NA NA
cor76 0.4614360 NA 0.3471186 0.5758775 NA NA
cor81 0.3883343 NA 0.2789999 0.4978509 NA NA
cor82 -0.0051518 NA -0.2450242 0.2250716 NA NA
cor86 0.6136154 NA 0.5711306 0.6561093 NA NA
cor87 0.4868597 NA 0.3821994 0.5915209 NA NA

Goodness-of-fit indices:
Value
Sample size 17108.0000
Chi-square of target model 5.8345
DF of target model 6.0000
p value of target model 0.4420
Number of constraints imposed on "Smatrix" 3.0000
DF manually adjusted 0.0000
Chi-square of independence model 3469.2835
DF of independence model 28.0000
RMSEA 0.0000
RMSEA lower 95% CI 0.0000
RMSEA upper 95% CI 0.0098
SRMR 0.0742
TLI 1.0002
CFI 1.0000
AIC -6.1655
BIC -52.6493
OpenMx status1: 0 ("0" or "1": The optimization is considered fine.
Other values indicate problems.)

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
Hi Hamed,

Hi Hamed,

Can you post the R code and data? Thanks.

Best,
Mike

HAMED's picture
Offline
Joined: 06/15/2012 - 02:29
RE: "NA" in random effects tssem2 outputs

Hi Mike;

Thank you for your response. I could not find out how I can post attachments here, so I just emailed you the R code and the data files.

Best,
Hamed