You are here

Problem with the new OSMASEM-Function

20 posts / 0 new
Last post
Marius2905's picture
Offline
Joined: 12/03/2018 - 04:15
Problem with the new OSMASEM-Function
AttachmentSize
Binary Data CodeMW7.05 KB
Binary Data DataMW10.33 KB

Dear Mike & colleagues,

I'm currently sitting at a moderator analysis with the new OSMASEM approach (continuous moderators in MASEM - yeah!).

Unfortunately I get an error message, which I can't assign. I want to use HDI (Human Development Index) values as moderator variables for the regression coefficients (A-Matrix).
However, I get the following error message when I try to create the model with the moderator.
Code:

M1 <- create.vechsR(A0=RAM1$A, S0=RAM1$S, Ax=Ax) Error in as.vector(data) :
  no method for coercing this S4 class to a vector 

I'd be happy if you had any idea how to solve this problem. Does it maybe have anything to do with the type of data I have?

I have my code and my data attached.

Best
Marius

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

Hi Marius,

It seems to work fine after correcting some syntax errors.

Hope it helps.

Best,
Mike

File attachments: 
Marius2905's picture
Offline
Joined: 12/03/2018 - 04:15
Thank you so much for your

Thank you so much for your help. Now everything is running smoothly. I only have two more questions for a better understanding:
1) If I remove one of my covariances (k2), then I gain a degree of freedom. Then why is the CFI still not calculated? (I have defined the argument Saturated=TRUE)
2 Although I have defined residuals (p22, p33, p44 and p55), they are not estimated - why is that? In the conventional TSSEM approach they are also estimated.

Thank you very much for your help.

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

Hi Marius,

1) We don't know how to define CFI in this model. So we only provide the chi-square statistic, RMSEA, and SRMR. For the SRMR, you may need to use the osmasemSRMR().
2) The residuals are functions of the other parameters. You may get the residuals by using mxEval(Smatrix, fit0$mx.fit).

Best,
Mike

Marius2905's picture
Offline
Joined: 12/03/2018 - 04:15
Thank you very much for the

Thank you very much for the clarification. Really great work you did with the OSMASEM.
In the TSSEM approach there is the possibility to specify the indirect effects - would you recommend to calculate the Sobel test (or something similar) manually in the OSMASEM?

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

Hi Marius,

You can define an indirect effect and get the Wald SE with the mxSE(). Alternatively, you can also get the likelihood-based CI of the indirect effect. It may take a while to get the CIs as it is computationally intensive. Please see the attached examples.

Mike

File attachments: 
canavati's picture
Offline
Joined: 12/01/2018 - 23:51
Hi Mike,

Hi Mike,
Thanks for this great example. I'm still learning how to use the OSMASEM approach which seems very useful. I am able to successfully run the analyses, but I was wondering if when testing moderating effects, do I have to populate the Ax matrix for all paths in my model, or can I just estimate the moderating effects for only the paths that I'm interested in testing the moderating effect for?
Thanks,
Sergio

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

Hi Sergio,

I think that you can just test the paths that you are interested in. However, the OSMASEM approach is very new. We need to see whether testing a few paths (or all paths) may create some strange models. Your feedback on your data is highly appreciated.

Mike

canavati's picture
Offline
Joined: 12/01/2018 - 23:51
Can't Run Model with Latent Variable in OSMASEM

Hi Mike,
I'm trying to estimate this model in OSMASEM, and I can't. I get this error:

> M0 <- create.vechsR(A0=RAM4$A, S0=RAM4$S, F0=RAM4$F)
> ## Create heterogeneity variances
> T0 <- create.Tau2(RAM=RAM4, RE.type="Symm")
> mx.fit0 <- osmasem(model.name="No moderator", Mmatrix=M0, Tmatrix=T0, data=my.df)

Warning message:
The following error occurred while evaluating the subexpression 'No moderator.Tau2 + No moderator.V' during the evaluation of 'expCov' in model 'No moderator' : non-conformable arrays

model4<- 'out =~ PAT2outPAT + CIT2outCIT
+ out ~ SIZE2OUTSIZ + IO2OUTIO + CON2OUTCON + RD2OutRD
+ RD ~ SIZE2RDSIZ + IO2RDIO + CON2RDCON
+ IO ~~ p10
SIZ
+ IO ~~ p11CON
+ SIZ ~~ 1
SIZ
+ IO ~~ 1IO
+ CON ~~ 1
CON
+ RD ~~ p20RD
+ out ~~ p21
out
+ PAT ~~ p22PAT
+ CIT ~~ p23
CIT'
plot(model4, color="yellow", layout = "tree2")
RAM4 <- lavaan2RAM(model4, obs.variables=c("IO","SIZ","CON","RD","PAT","CIT"), std.lv = FALSE)

I can estimate this same model in TSSEM without any problems:
my.vec <- readStackVec("matrix1.dat")
my.vec <- lapply(my.vec,function(x)
{dimnames(x) <- list(c("IO","SIZ","CON","RD","PAT","CIT"),
c("IO","SIZ","CON","RD","PAT","CIT"))
x})

f<-c(0,0,0,0,"0.2g_E","0.2g_O")
F<-matrix(f,ncol = 1,nrow = 6)
F

A1 <- matrix(c(0,0,0,0,0,0,
0,0,0,0,0,0,
0,0,0,0,0,0,
"0.3IO2RD","0.3IO2SIZ","0.3CON2RD",0,0,0,
0,0,0,0,0,0,
0,0,0,0,0,0),
nrow=6, ncol=6, byrow=TRUE)
A1
A<-rbind(cbind(A1, F), matrix (c("0.2
IO2out","0.2SIZ2out","0.2CON2OUT","0.2RD2OUT",0,0,0), ncol=7, nrow=1))
A
dimnames(A)<-list(c("IO","SIZ","CON","RD","PAT","CIT","out"), c("IO","SIZ","CON","RD","PAT","CIT","out"))
A
phi<-matrix(c("0.3
e5"),nrow = 1,ncol = 1)
psi<-matrix(c(1,"0.3e4","0.3e6",0,0,0,
"0.3e4",1,0,0,0,0,
"0.3
e6",0,1,0,0,0,
0,0,0,"0.3e1",0,0,
0,0,0,0,"0.3
e2",0,
0,0,0,0,0,"0.3*e3"),
nrow=6, ncol=6, byrow=TRUE)
S<-bdiagMat(list(psi,phi))
dimnames(S)<-list(c("IO","SIZ","CON","RD","PAT","CIT","out"), c("IO","SIZ","CON","RD","PAT","CIT","out"))
S
FM<-create.Fmatrix(c(1,1,1,1,1,1,0), as.mxMatrix = FALSE)
dimnames(FM)<-list(c("IO","SIZ","CON","RD","PAT","CIT"), c("IO","SIZ","CON","RD","PAT","CIT","out"))
FM

Random1 <- tssem1(my.vec, my.n, method = "REM")
summary(Random1)
Random2<-tssem2(Random1, Amatrix = A,Smatrix = S,Fmatrix = FM, model.name = "IBTmediator",
diag.constraints = FALSE)
summary(Random2)

Do you know why I can't estimate this model in OSMASEM?

Thanks for the amazing software and approach. I would really appreciate your help with this.

Thanks,
Sergio

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

Hi Sergio,

Could you please post the data and R code so that I can test it?

Best,
Mike

hamedsaremi's picture
Offline
Joined: 11/27/2016 - 22:30
OSMASEM and TSSEM

Hi Mike;

Thank you for adding the new OSMASEM functionality to metaSEM. This can have very helpful implications.
I have been trying to use OSAMASEM for my data. However, there is a significant discrepancy between what TSSEM results and OSMASEM (without moderation) results for my data. While TSSEM results show a much better fit (which make theoretical sense), the OSMASEM without moderation results are very poor and do not make theoretical sense. I have followed your code on GitHub for Nohe15A1 in developing my code. I appreciate any insight you might have to resolve this issue.

My code and data can be downloaded from this link, just in case you need to see them: https://www.dropbox.com/s/h0m90ugnra6v136/OSMASEM.zip?dl=0

Thank you very much
Hamed

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

Hi Hamed,

The results seem comparable between the OSMASEM and TSSEM. The OSMASEM indeed fits slightly better than that in the TSSEM.

Mike

File attachments: 
hamedsaremi's picture
Offline
Joined: 11/27/2016 - 22:30
RE: OSMASEM and TSSEM

Hi Mike;

Thank you for your help. Indeed, I was missing "Saturated = TRUE" command in summary(), which prevented me from comparing OSMASEM results with tssem results. I have some questions regarding OSMASEM with a moderator.

I am testing one moderator on five relations in my model (RAM1$A). The results show df=-1 and consequently TLI=1 and RMSEA=0. Should df and goodness-of-fit indices be interpreted the same way as in tssem? Meaning that should df always be positive in OSMASEM? and can I interpret RMSEA and TLI the same as in tssem? Also, if df should be kept positive, is it ok to remove some of the moderations from Ax matrix?

Thank you
Hamed

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

Hi Hamed,

Could you please post the R code and output?

Mike

hamedsaremi's picture
Offline
Joined: 11/27/2016 - 22:30
Hi Mike;

Hi Mike;

I am sorry I forgot to paste the link. Here are the data and the code: https://www.dropbox.com/s/h0m90ugnra6v136/OSMASEM.zip?dl=0

Thank you
Hamed

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

Hi Hamed,

The Saturated = TRUE argument is only used for models without any moderators.

When there are moderators, the goodness-of-fit indices do not apply here as the df is negative. The only way to test the model is to use the likelihood ratio test to compare the models with and without the moderators. In this example, it tests if all the five coefficients in A1 are zero.

> summary(mx.fit1_ewom)
Summary of Ax as moderator 
 
free parameters:
         name  matrix                 row                 col     Estimate  Std.Error A     z value     Pr(>|z|)
1      INV2PH      A0          ResponsePH ReceiverInvolvement  0.373454537 0.07753874     4.8163605 1.462003e-06
2    PH2Adopt      A0 ResponseAdoptionWOM          ResponsePH  0.812536913 0.04875647    16.6652121 0.000000e+00
3       SC2PH      A0          ResponsePH   SourceCredibility  0.222244486 0.04536917     4.8985791 9.653216e-07
4     SC2Qual      A0         WOMQualCred   SourceCredibility  0.530844072 0.02802296    18.9431815 0.000000e+00
5     Qual2PH      A0          ResponsePH         WOMQualCred  0.448312467 0.04163381    10.7679895 0.000000e+00
6   scWITHinv      S0   SourceCredibility ReceiverInvolvement  0.266492524 0.03968411     6.7153458 1.876210e-11
7    INV2PH_1      A1          ResponsePH ReceiverInvolvement -0.040901829 0.07060380    -0.5793149 5.623767e-01
8  PH2Adopt_1      A1 ResponseAdoptionWOM          ResponsePH -0.004681619 0.03362133    -0.1392455 8.892562e-01
9     SC2PH_1      A1          ResponsePH   SourceCredibility  0.043994991 0.04139017     1.0629334 2.878122e-01
10  SC2Qual_1      A1         WOMQualCred   SourceCredibility  0.028057032 0.02734064     1.0262025 3.047962e-01
11  Qual2PH_1      A1          ResponsePH         WOMQualCred -0.029228190 0.03720641    -0.7855687 4.321202e-01
12     Tau1_1 vecTau1                   1                   1 -1.896191810 0.33141255    -5.7215450 1.055597e-08
13     Tau1_2 vecTau1                   2                   1 -1.865854225 0.34640284    -5.3863711 7.189447e-08
14     Tau1_3 vecTau1                   3                   1 -2.376783963 0.36209209    -6.5640316 5.237211e-11
15     Tau1_4 vecTau1                   4                   1 -1.223904158 0.25157946    -4.8648810 1.145257e-06
16     Tau1_5 vecTau1                   5                   1 -1.227976035 0.20693345    -5.9341591 2.953554e-09
17     Tau1_6 vecTau1                   6                   1 -1.983095689 0.16767840   -11.8267808 0.000000e+00
18     Tau1_7 vecTau1                   7                   1 -2.036263416 0.16435200   -12.3896477 0.000000e+00
19     Tau1_8 vecTau1                   8                   1 -2.122531862 0.16042449   -13.2307226 0.000000e+00
20     Tau1_9 vecTau1                   9                   1 -1.780713889 0.14299080   -12.4533459 0.000000e+00
21    Tau1_10 vecTau1                  10                   1 -1.787391705 0.11639902   -15.3557280 0.000000e+00
 
Model Statistics: 
               |  Parameters  |  Degrees of Freedom  |  Fit (-2lnL units)
       Model:             21                    178             -140.1139
   Saturated:             65                    134                    NA
Independence:             20                    179                    NA
Number of observations/statistics: 28516/199
 
Information Criteria: 
      |  df Penalty  |  Parameters Penalty  |  Sample-Size Adjusted
AIC:      -496.1139              -98.11395                -98.08152
BIC:     -1966.0772               75.30869                  8.57103
To get additional fit indices, see help(mxRefModels)
timestamp: 2019-04-26 09:51:57 
Wall clock time: 4.569965 secs 
optimizer:  SLSQP 
OpenMx version number: 2.12.2 
Need help?  See help(mxSummary) 
> ## Comparing the models with and without the moderator
> anova(mx.fit1_ewom, mx.fit0_ewom)
             base        comparison ep  minus2LL  df       AIC   diffLL diffdf        p
1 Ax as moderator              <NA> 21 -140.1139 178 -496.1139       NA     NA       NA
2 Ax as moderator eWoM No moderator 16 -137.1828 183 -503.1828 2.931109      5 0.710606

Best,
Mike

hamedsaremi's picture
Offline
Joined: 11/27/2016 - 22:30
Hi Mike;

Hi Mike;

Thank you for your response. ANOVA() is very helpful. It clarified the issue for me.

Best
Hamed

xiyuesenlinyu's picture
Offline
Joined: 05/24/2019 - 22:30
Hello,

Hello,
I want to ask if it is okay to get negative minus2LL. I run the moderator models, and get negative minus2LL just like yours.
Model Statistics:
| Parameters | Degrees of Freedom | Fit (-2lnL units)
Model: 21 159517 -417246
Saturated: NA NA NA
Independence: NA NA NA
Number of observations/statistics: 39884/159538

Mike Cheung's picture
Offline
Joined: 10/08/2009 - 22:37
The following thread may be

The following thread may be useful. https://openmx.ssri.psu.edu/thread/1831

xiyuesenlinyu's picture
Offline
Joined: 05/24/2019 - 22:30
Thanks for your help!

Thanks for your help!