I need to test a model and analysis the path relationships in R, I use the lavaan package. the model is a non-recursive mediation model. but I keep failing. I am very new to the R programming so please can anyone tell me what is going on?
#I create a new project
#Open packages - 1.haven 2.foreign 3.Lavaan
#I import the Dataset
WFCmodel <- '
#I assign all the categories that represented by more than one variable first
#Work Environment Antecedents
WE =~ SuperS_Total + CowS_Total + FlexW_Total
#Work Time-Based Factors
WT =~ Whour_H + Commute_M
#Work Strain-Based Factors
WS =~ DisatisW_Total + FWG_Total
#Family Environment Antecedents
FE =~ SpouseS_Total + SiblingS_Total + ParentS_Total
#Family Time-Based Factors
FT =~ Childcare_H + Housework_M + TCparents_H
#Family Strain_Based Factors
FS =~ DisatisF_Total + WFG_Total
#Now I define all the regressions in the model from top to bottom and left to right
InterWC_Total ~ cWE + xWFC_FIW
WT ~ bWE + wWFC_FIW
WS ~ aWE + hWT + v*WFC_FIW
InterFC_Total ~ dFE + rWFC_WIF
FT ~ eFE + sWFC_WIF
FS ~ fFE + nFT + t*WFC_WIF
WFC_WIF ~ jInterWC_Total + iWT + l*WS
WFC_FIW ~ mInterFC_Total + uFT + p*FS
PerforF_Total ~ gWS + zWFC_WIF
SatisL_Total ~ yWFC_WIF + kWS +y1WFC_FIW + oFS
PerforW_Total ~ z1WFC_FIW + qFS'
fit <- lavaan(WFCmodel, data = deletedMV0)
#i don’t know why when I run the analysis, R told me there are two errors:
#Error in Sigma.inv * sample.cov : non-conformable arrays
#In addition: Warning messages:
#1: In lav_data_full(data = data, group = group, cluster = cluster, :
#lavaan WARNING: some observed variances are (at least) a factor 1000 times larger than others; use varTable(fit) to investigate
#2: In lavaan(WFCmodel, data = deletedMV0) : lavaan WARNING:
#Model estimation FAILED! Returning starting values.
#For the first warning message, I thought maybe is because the different measurement I used,
#for example, commute time per mins per day will have something like 240, but other 5-Likert scale won’t have a value that huge.
#So I tried to scale the time related variable separately
deletedMV0$Whour_H <- scale(deletedMV0$Whour_H)
#but I got an Error said: Error in deletedMV0$Whour_H : $ operator is invalid for atomic vectors.
#Then I tried to scale the whole data frame
deletedMV0 <- apply(deletedMV0, 2, scale.default)
#and run the analysis, but after I run the analysis, R said:
#Error in Sigma.inv * sample.cov : non-conformable arrays
#In addition: Warning message:
#In lavaan(WFCmodel, data = deletedMV0) : lavaan WARNING:
#Model estimation FAILED! Returning starting values.