Maximum likelihood objective function

22 views
Skip to first unread message

Mark Seeto

unread,
May 9, 2019, 4:51:19 PM5/9/19
to lavaan
Dear lavaan group,

At https://github.com/yrosseel/lavaan/blob/master/R/lav_objective.R the function estimator.ML contains the following code:

if(!meanstructure) {
  fx
<- (Sigma.hat.log.det + sum(data.cov * Sigma.hat.inv) -
         data
.cov.log.det - nvar)
}


In Bollen's book "Structural Equations With Latent Variables" (equation 8.29 on p. 334), he has the trace of (data.cov * Sigma.hat.inv) instead of the sum of all elements.

What's the reason for using sum(data.cov * Sigma.hat.inv) instead of sum(diag(data.cov * Sigma.hat.inv))?

Thanks,
Mark

Mark Seeto

unread,
May 9, 2019, 5:01:26 PM5/9/19
to lavaan
Sorry, I just realised the answer to my question.

data.cov * Sigma.hat.inv is an elementwise product, not a matrix multiplication. Because these matrices are symmetric,

sum(data.cov * Sigma.hat.inv)

is the same as

sum(diag(data.cov %*% Sigma.hat.inv)).

Reply all
Reply to author
Forward
0 new messages