You are here

Problem with the new OSMASEM-Function

10 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