Error in varEst[targetcol, targetcol] : subscript out of bounds[1] "per~mlc" "per~hyb" "per~m_mlc_hyb"May the problem arise because hyb is no latent variable but an exogenous one?
dat2wayRC <- orthogonalize(dat2way, 1:3, 4, match = FALSE)head(dat2way)head(dat2wayRC)
## Try it as a single-indicator latent variablemodel1 <- '## measurement modelf1 =~ x1 + x2 + x3f2 =~ x4f12 =~ x1.x4 + x2.x4 + x3.x4f3 =~ x7 + x8 + x9## structural model (latent interaction is orthogonal to factors)f3 ~ f1 + f2 + f12f12 ~~ 0*f1f12 ~~ 0*f2## fix intercepts to identify latent locationsx1 ~ 0*1x4 ~ 0*1x1.x4 ~ 0*1x7 ~ 0*1## estimate latent meansf1 ~ NA*1f2 ~ NA*1f12 ~ NA*1f3 ~ NA*1'fitRC2way <- sem(model1, data = dat2wayRC)probe2WayRC(fitRC2way, c("f1", "f2", "f12"), "f3", "f2", c(-1, 0, 1))
## Try it as a fixed exogenous predictormodel2 <- '## measurement modelf1 =~ x1 + x2 + x3f12 =~ x1.x4 + x2.x4 + x3.x4f3 =~ x7 + x8 + x9## structural model (latent interaction is orthogonal to factor)f3 ~ f1 + x4 + f12f12 ~~ 0*f1## fix intercepts to identify latent locationsx1 ~ 0*1x1.x4 ~ 0*1x7 ~ 0*1## estimate latent meansf1 ~ NA*1f12 ~ NA*1f3 ~ NA*1'fitRCex <- sem(model2, data = dat2wayRC, fixed.x=TRUE)probe2WayRC(fitRCex, c("f1", "x4", "f12"), "f3", "x4", c(-1, 0, 1))
## Try it as a single-indicator latent variablemodel1 <- '## measurement modelf1 =~ x1 + x2 + x3f2 =~ x4f12 =~ x1.x4 + x2.x4 + x3.x4
f3 =~ x7 + x8 + x9
f4 =~ x5+x6+x7
## structural model (latent interaction is orthogonal to factors)
f3 ~ f1 + f2 + f12 + f4
f12 ~~ 0*f1f12 ~~ 0*f2## fix intercepts to identify latent locationsx1 ~ 0*1x4 ~ 0*1x1.x4 ~ 0*1
x7 ~ 0*1
x5 ~ 0*1
## estimate latent meansf1 ~ NA*1f2 ~ NA*1f12 ~ NA*1
f3 ~ NA*1
f4 ~ NA*1
'fitRC2way <- sem(model1, data = dat2wayRC)probe2WayRC(fitRC2way, c("f1", "f2", "f12"), "f3", "f2", c(-1, 0, 1))
Warning messages:
1: In sqrt(varIntcept) : NaNs produced
2: In sqrt(varIntcept) : NaNs producedThe problem occurs when I add another latent variable.
Furthermore, I added another interaction term to the example model. Then the following Warning appears:Warning messages:
1: In sqrt(varIntcept) : NaNs produced
2: In sqrt(varIntcept) : NaNs produced
The problem occurs when I add another latent variable.Could you be more specific? Adding another latent variable (f4) in the syntax you posted, which only had a main effect (no interactions) did not yield an error for me, although the results differed (probably because x7 now has cross-loadings on f3 and f4, changing the nature of the factors).
Furthermore, I added another interaction term to the example model. Then the following Warning appears:Warning messages:
1: In sqrt(varIntcept) : NaNs produced
2: In sqrt(varIntcept) : NaNs producedPerhaps if you are probing a moderated effect of a variable that interacts with 2 moderators, you would need to choose levels for both moderators, and the function might not yet be equipped to handle that. Please post the R syntax necessary to reproduce the problem, so we can figure it out.
dat<-indProd(dat, var1=c("pbkf1", "pbkf2"), var2=c("hybr"), match=FALSE, meanC=TRUE, residualC=TRUE, doubleMC=FALSE)
dat<-indProd(dat, var1=c("pmlc1", "pmlc2"), var2=c("hybr"), match=FALSE, meanC=TRUE, residualC=TRUE, doubleMC=FALSE)
dat<-indProd(dat, var1=c("pckf1", "pckf2"), var2=c("hybr"), match=FALSE, meanC=TRUE, residualC=TRUE, doubleMC=FALSE)
#mean centring before orthogonalization to improve model fit, problem does still occur
modell <- '
#Structural Model
perf ~ mlc + bkf + ckf + erf_ber + hyb + a*m_mlc_hyb + c*m_ckf_hyb + b*m_bkf_hyb + d*adpt + e*per + g*vbs
mlc ~ k*adpt + l*per + m*vbs + erf_ber
bkf ~ n*adpt + o*per + p*vbs + erf_ber
ckf ~ q*adpt + r*per + s*vbs + erf_ber
erf_ber ~ hyb
#i=indirect effect & t = total effects
i_mlchyb_adpt := a*k
i_mlchyb_per := a*l
i_mlchyb_vbs := a*m
i_bkfhyb_adpt := b*k
i_bkfhyb_per := b*l
i_bkfhyb_vbs := b*m
i_ckfhyb_adpt := c*k
i_ckfhyb_per := c*l
i_ckfhyb_vbs := c*m
#Measurement Model
perf =~ p4 + p1 + p3
mlc =~ pmlc1 + pmlc2
bkf =~ pbkf2 + pbkf1
ckf =~ pckf2 + pckf1
adpt =~ as4+as1+as2+as3
vbs =~ vbs1+vbs3+vbs5+vbs4+vbs7
per =~ per4+per2+per5
hyb =~ hybr
m_bkf_hyb =~ pbkf2.hybr+pbkf1.hybr
m_mlc_hyb =~ pmlc1.hybr+pmlc2.hybr
m_ckf_hyb =~ pckf2.hybr+pckf1.hybr
#Correlations
ckf ~~ hyb
bkf ~~ hyb
mlc ~~ hyb
mlc ~~ 0*m_mlc_hyb
ckf ~~ 0*m_ckf_hyb
bkf ~~ 0*m_bkf_hyb
hyb ~~ 0*m_mlc_hyb
hyb ~~ 0*m_ckf_hyb
hyb ~~ 0*m_bkf_hyb
## fix intercepts to identify latent locations
p4 ~ 0*1
pmlc1 ~ 0*1
pbkf2 ~ 0*1
pckf2 ~ 0*1
as4 ~ 0*1
vbs1 ~ 0*1
per4 ~ 0*1
hybr ~ 0*1
pbkf2.hybr ~ 0*1
pmlc1.hybr ~ 0*1
pckf2.hybr ~ 0*1
## estimate latent means
perf ~ NA*1
mlc ~ NA*1
bkf ~ NA*1
ckf ~ NA*1
adpt ~ NA*1
vbs ~ NA*1
per ~ NA*1
hyb ~ NA*1
m_bkf_hyb ~ NA*1
m_mlc_hyb ~ NA*1
m_ckf_hyb ~ NA*1
'
fit <- sem(model=sor.modell, data=sor.dat2, missing = "fiml", se = "robust")
probe2WayRC(fit, c("mlc", "hybr", "m_mlc_hyb"), "perf", "hybr", c(-1,0,1))
result2wayRC
Şule
what do values of -1, 0, and 1 (i.e., c(-1, 0, 1)) stand for? Do they represent 1 sd below and the mean, mean of latent moderating factor?result2wayRC <- probe2WayRC(fitRC2way, c("f1", "f2", "f12"), "f3", "f2", c(-1, 0, 1)).
do I get it right