My code for LMS are as follows:
+++++++++++++++++
library("nlsem")
model <- specify_sem(num.x = 20, num.y = 3, num.xi = 7, num.eta = 1,
xi = "x1-x3, x4-x6, x7-x9, x10-x12, x13-x15, x16-x18, x19-x20",
eta = "y1-y3", interaction = "xi1:xi2")
load("part2b.RData")
set.seed(11111)
start <- runif(count_free_parameters(model))
res <- em(model, part2b, start, qml = F, convergence=0.01, verbose=TRUE, max.iter=99999, neg.hessian = TRUE)
summary(res)
coef(res)
logLik(res)
AIC(res)
BIC(res)
++++++++++++++++++
After being run, the results are:
+++++++++++++++++++
......
> res <- em(model, part2b, start, qml = F, convergence=0.01, verbose=TRUE, max.iter=99999, neg.hessian = TRUE)
-----------------------------------
Starting EM-algorithm for singleClass
Convergence: 0.01
-----------------------------------
-----------------------------------
Iteration 1
Doing expectation-step
Doing maximization-step
Results of maximization
Loglikelihood: -Inf
Convergence message: 0
Number of iterations: 1
-----------------------------------
Iteration 2
Doing expectation-step
Doing maximization-step
Results of maximization
Loglikelihood: -Inf
Convergence message: 0
Number of iterations: 1
-----------------------------------
Error in if (abs(ll.old - ll.new) < convergence) run <- FALSE :
missing value where TRUE/FALSE needed
In addition: Warning message:
In value[[3L]](cond) :
Starting parameters for Phi are not positive definite. Identity matrix was used instead.
>
> summary(res)
......
+++++++++++++++++++++++++++++++
How can I do on my codes following the warnings?
When running within Mplus, everything is OK.