Getting this error
Error: The observed correlation matrix is not 1's along the diagonal
from the statement
mxData(cor, type="cor", numObs=1656)
but looking at the data matrix indicates that its diagonal consists of 1's
> diag(cor)
SOF IWF PWF FSC FSF EF GPA
1 1 1 1 1 1 1
cor
SOF IWF PWF FSC FSF EF GPA
SOF 1.00000000 -0.310734680 0.02337843 -0.01050081 0.324939442 -0.49945847 0.83664278
IWF -0.31073468 1.000000000 0.09947420 -0.03052640 0.001136279 0.49532944 -0.10899843
PWF 0.02337843 0.099474205 1.00000000 -0.61560751 -0.628812462 0.11562605 -0.21215413
FSC -0.01050081 -0.030526399 -0.61560751 1.00000000 0.048027377 -0.41138615 -0.12042060
FSF 0.32493944 0.001136279 -0.62881246 0.04802738 1.000000000 -0.13170374 0.52886839
EF -0.49945847 0.495329442 0.11562605 -0.41138615 -0.131703740 1.00000000 -0.04665071
GPA 0.83664278 -0.108998427 -0.21215413 -0.12042060 0.528868389 -0.04665071 1.00000000
Full code to make model copied below
install.packages("ggm")
require(ggm)
cor = rcorr(7)
manifests = c("SOF", "IWF", "PWF", "FSC", "FSF", "EF", "GPA")
dimnames(cor)<-list(manifests,manifests)
fit1<- mxModel("model", type="RAM",
manifestVars = manifests,
mxPath(from = manifests, arrows=2),
mxPath(from = "PWF", to=c("FSF","FSC"), arrows=1),
mxPath(from = "PWF", to="IWF" , arrows=1),
mxPath(from = "PWF", to="SOF" , arrows=1),
mxPath(from = "SOF", to="IWF" , arrows=1),
mxPath(from = "SOF", to=c("FSF","FSC") , arrows=1),
mxPath(from= "IWF", to=c("FSF","FSC") , arrows=1),
mxPath(from= "FSC", to="EF" , arrows=1),
mxPath(from= "FSF", to="EF" , arrows=1),
mxPath(from= "EF" , to="GPA" , arrows=1),
mxData(cor, type="cor", numObs=1656)
)