TSSEM 2

Posted on
No user picture. janekim Joined: 04/21/2024
Forums
Hi, Dr. Cheung,

My name is Jane Kim and I'm working on the TSSEM using https://sjak.shinyapps.io/webMASEM/.

#1.
I attempted to generate the unrestricted average correlation and summary output of fitting a multivariate meta-analysis with the tssem() function of metaSEM. However, an error has occurred. Please help me solve this error.

#2.
I am not sure how to deal with the missing values. Another dataset using 10 studies has some duplicates in correlations. Do I need to average each correlation?

Thank you so much,

Further, I would like to use the following lavaan syntaxes to see overall mediation model and the indirect effects:

Lavaan Syntax (Overall)

# Regression coefficients
BPN ~ b31*SFM + b32*POM
SWB ~ b43*BPN + b41*SFM + b42*POM

# Covariances
SFM ~~ p21*POM

# Variances
SFM ~~ 1*SFM
POM ~~ 1*POM
BPN ~~ p33*BPN
SWB ~~ p44*SWB

Lavaan Syntax (Indirect effects)
INDIRECT EFFECT: POM -> BPN -> SWB

BPN ~ b31*SFM + beta1*POM
SWB ~ beta2*BPN + b41*SFM + b42*POM

INDIRECT EFFECT: SFM -> BPN -> SWB

BPN ~ beta1*SFM + b32*POM
SWB ~ beta2*BPN + b41*SFM + b42*POM

Replied on Sat, 05/18/2024 - 06:51
Picture of user. Mike Cheung Joined: 10/08/2009

Since it's a Shiny App, please contact the app's author. If you have the R code to reproduce the errors, we may be able to help. Please post the R code and errors.
Replied on Tue, 05/21/2024 - 14:43
No user picture. janekim Joined: 04/21/2024

I will provide the R code and errors soon.

I have one more question on how to code correlation values.

I attempted to aggregate all the subcategories in one variable into one. For example, I put each correlation value of autonomy, belongingness, and competence into one variable, BPN. This led me to duplicate some values in other correlations even in one study. Thus, one study is having several rows with some duplicated values.

In this case, do I need to average the values and have only one row for each study?

Replied on Wed, 05/22/2024 - 04:35
Picture of user. Mike Cheung Joined: 10/08/2009

In reply to by janekim

It seems that the error is related to the extra NA data.


> rd3=read.delim("./SFMPOMBPNSWB(133)_averaged copy.txt")
> tail(rd3)
ID N SFM_POM SFM_BPN SFM_SWB POM_BPN POM_SWB BPN_SWB X X.1 X.2 X.3 X.4 X.5
509 NA NA NA NA NA NA NA NA NA NA NA NA NA
510 NA NA NA NA NA NA NA NA NA NA NA NA NA
511 NA NA NA NA NA NA NA NA NA NA NA NA NA
512 NA NA NA NA NA NA NA NA NA NA NA NA NA
513 NA NA NA NA NA NA NA NA NA NA NA NA NA
514 NA NA NA NA NA NA NA NA NA NA NA NA NA
> rd3$N
[1] 330 87 142 103 376 316 5634 332 476 231 390 292 207 303 184 265 158 93 550
[20] 207 181 119 179 78 223 151 120 500 400 74 3020 384 409 111 206 255 481 125
[39] 2432 179 57 347 110 137 532 532 849 341 341 321 128 105 134 335 750 605 252
[58] 326 579 585 162 189 216 164 437 229 110 430 254 339 731 355 467 129 307 393
[77] 269 231 151 70 82 275 556 982 96 122 151 130 312 84 326 30 304 205 280
[96] 320 131 128 119 130 1258 1987 1950 315 1047 3978 482 1063 322 165 103 55 360 1063
[115] 501 345 250 591 591 322 355 389 737 444 355 1063 174 73 785 250 121 737 1026
[134] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[153] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[172] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[191] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[210] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[229] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[248] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[267] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[286] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[305] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[324] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[343] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[362] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[381] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[400] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[419] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[438] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[457] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[476] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[495] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA
[514] NA

Replied on Tue, 05/28/2024 - 15:44
No user picture. janekim Joined: 04/21/2024

Thank you so much! I could solve the problem and ended up having 104 data for TSSEM.

However, I faced another problem while producing lavaan syntax for indirect effects for my model.
The model is a sequential mediation model with two mediators. (X: SFM, Y: SWL, M1: BPN, M2, POM)

I could write the syntax for overall analysis:
# Regression coefficients
BPN ~ b21*SFM
POM ~ b32*BPN + b31*SFM
SWB ~ b43*POM + b42*BPN + b41*SFM

# Variances
SFM ~~ 1*SFM
BPN ~~ p22*BPN
POM ~~ p33*POM
SWB ~~ p44*SWB

I would appreciate if you could help me generate syntaxes for three kinds of indirect effects:
1. X->M1->Y
2. X->M2->Y
3. X->M1->M2->Y

Replied on Tue, 05/28/2024 - 22:14
Picture of user. Mike Cheung Joined: 10/08/2009

In reply to by janekim

The metaSEM package uses a subset of lavaan syntax and RAM specifications. You may refer to the lavaan syntax on how to specify models and functions of parameters, e.g., indirect effects. https://lavaan.ugent.be/tutorial/

Materials for a three-day workshop on MASEM are available at https://github.com/mikewlcheung/masemWorkshop2023. They include many examples. Moreover, examples of published articles are available at https://github.com/mikewlcheung/code-in-articles.

Replied on Tue, 05/28/2024 - 19:41
No user picture. janekim Joined: 04/21/2024

Plus,
Should I include Egger's test (with funnel plot) to provide evidence for publication bias in MASEM?
Replied on Tue, 05/28/2024 - 22:16
Picture of user. Mike Cheung Joined: 10/08/2009

Yes, you can do it if you want, but please note that tests on publication bias are based on correlation coefficients, whereas MASEM is based on correlation matrices. Results on testing individual correlations may be different from those for correlation matrices.
Replied on Fri, 05/31/2024 - 17:44
No user picture. janekim Joined: 04/21/2024

Thank you so much!
I could solve the initial problem I had with your help.

However, I put the r codes for step 1 and 2, but step 1 analysis is not working. Can you look at the errors and help me solve this error?

ERROR

> ## Stage 1 analysis: find an average correlation matrix
> stage1 <- tssem1(cormatrices, n, method="REM")
> summary(stage1)
Error in update.default(x, warn = FALSE, warn.deprecated = FALSE) :
need an object with call component

File attachments
Replied on Fri, 05/31/2024 - 20:39
Picture of user. Mike Cheung Joined: 10/08/2009

It works for me without any errors.


library(metaSEM)

## Read in data
data <- read.delim("./yein99.txt", header = TRUE)
head(data)
View(data)

nvar <- 4
varnames <- c("SFM","BPN","POM","SWB")
labels <- list(varnames,varnames)

## Create list of cormatrices from columns 3 to 8
rd3.splt <- split(data, 1:nrow(data))
cormatrices <- lapply(rd3.splt, function(x) {vec2symMat(unlist(c(x[10:15])), diag=FALSE)})
cormatrices <- lapply(cormatrices, function(x) {dimnames(x) <- labels; x})

## I don't know where the function readstack() comes from.
## cormatrices <- readstack(data[,10:15], no.var = nvar, var.names = varnames, diag = FALSE)

## Stage 1 analysis: find an average correlation matrix
stage1 <- tssem1(cormatrices, data$N, method="REM")
summary(stage1)

Here are the outputs:


> summary(stage1)

Call:
meta(y = ES, v = acovR, RE.constraints = Diag(paste0(RE.startvalues,
"*Tau2_", 1:no.es, "_", 1:no.es)), RE.lbound = RE.lbound,
I2 = I2, model.name = model.name, suppressWarnings = TRUE,
silent = silent, run = run)

95% confidence intervals: z statistic approximation (robust=FALSE)
Coefficients:
Estimate Std.Error lbound ubound z value Pr(>|z|)
Intercept1 -0.1174030 0.0533116 -0.2218919 -0.0129141 -2.2022 0.0276511 *
Intercept2 -0.0980337 0.0254740 -0.1479618 -0.0481056 -3.8484 0.0001189 ***
Intercept3 -0.1246167 0.0155386 -0.1550719 -0.0941616 -8.0198 1.110e-15 ***
Intercept4 0.4170815 0.0311100 0.3561070 0.4780561 13.4067 < 2.2e-16 ***
Intercept5 0.4346259 0.0323767 0.3711687 0.4980830 13.4240 < 2.2e-16 ***
Intercept6 0.4318331 0.0131188 0.4061207 0.4575456 32.9170 < 2.2e-16 ***
Tau2_1_1 0.0112474 0.0091617 -0.0067093 0.0292040 1.2276 0.2195810
Tau2_2_2 0.0442093 0.0077922 0.0289369 0.0594817 5.6735 1.399e-08 ***
Tau2_3_3 0.0143913 0.0028950 0.0087172 0.0200654 4.9711 6.657e-07 ***
Tau2_4_4 0.0111990 0.0049330 0.0015305 0.0208675 2.2702 0.0231946 *
Tau2_5_5 0.0170450 0.0062142 0.0048654 0.0292247 2.7429 0.0060899 **
Tau2_6_6 0.0113937 0.0021589 0.0071623 0.0156250 5.2776 1.309e-07 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Q statistic on the homogeneity of effect sizes: 3442.909
Degrees of freedom of the Q statistic: 267
P value of the Q statistic: 0

Heterogeneity indices (based on the estimated Tau2):
Estimate
Intercept1: I2 (Q statistic) 0.8981
Intercept2: I2 (Q statistic) 0.9716
Intercept3: I2 (Q statistic) 0.9183
Intercept4: I2 (Q statistic) 0.9254
Intercept5: I2 (Q statistic) 0.9464
Intercept6: I2 (Q statistic) 0.9297

Number of studies (or clusters): 99
Number of observed statistics: 273
Number of estimated parameters: 12
Degrees of freedom: 261
-2 log likelihood: -261.233
OpenMx status1: 0 ("0" or "1": The optimization is considered fine.
Other values may indicate problems.)

Replied on Fri, 05/31/2024 - 23:51
No user picture. janekim Joined: 04/21/2024

Thank you so much, Dr. Cheung.

I came up with two kinds of lavaan syntax for my serial mediation model, and I am still not sure which one would be accurate. Can you go over my syntax?
X: SFM
M1: BPN
M2: POM
Y: SWB

##Proposed model
model1 <- "
SWB ~ c*SFM + b1*BPN + b2*POM
BPN ~ a1*SFM
POM ~ a2*SFM + d*BPN
SFM ~~ 1*SFM
## Define direct and indirect effects
Direct := c
Indirect1 := a1*b1
Indirect2 := a2*b2
Indirect3 := a1*d*b2

Total := c + Indirect1 + Indirect2 + Indirect3

"
model3 <- "
SWB ~ e*SFM + f*BPN + c*POM
BPN ~ a*SFM
POM ~ b*BPN
POM ~ d*SFM

# Define indirect and direct effects
Ind_BPNPOM := a*b*c
Ind_BPN := a*f
Ind_POM := d*c
Direct := e"

Replied on Tue, 06/04/2024 - 11:30
Picture of user. Mike Cheung Joined: 10/08/2009

Please note that

abc
is different from

a*b*c

Another example is:

SWB ~ cSFM + b1BPN + b2POM

I suppose you want:
SWB ~ c*SFM + b1*BPN + b2*POM

As suggested, you may refer to https://lavaan.ugent.be/tutorial/syntax2.html for the syntax.

Replied on Fri, 06/07/2024 - 17:29
No user picture. janekim Joined: 04/21/2024

In reply to by Mike Cheung

Thank you Dr. Cheung,
While copying and pasting the codes, the *s were omitted.

One of the direct paths (a2, IV->M2) and the related indirect path (indirect2, IV->M2->DV) were insignificant in stage 2. However, when I put a categorical moderator (dummy coded, 1=individualism, 0=collectivism), two paths became significant (a1[IV->M1], a2 [IV->M2])

Should the paths be significant in order to proceed with subgroup analysis?

File attachments