R/compute.CompleteLikelihood.R

Defines functions compute.CompleteLikelihood

compute.CompleteLikelihood <-
function(X,alpha,beta,mu,a,b,d,Q,Z,W,Wmat){
  K = length(alpha); L=length(beta); p = dim(X)[2]
  lik = sum(Z %*% t(t(log(alpha)))) + sum(W %*% t(t(log(beta))))
  for (l in 1:L){
    for (k in 1:K){
      if (sum(W[,l])==1 | sum(Z[,k])==1) Xkl = X[Z[,k]==1,W[,l]==1,]
      else Xkl = apply(X[Z[,k]==1,W[,l]==1,],3,cbind)
      if (is.vector(Xkl)) Xkl = t(Xkl)
      lik = lik - 1/2 *sum(estep.lik.cost(Xkl,alpha,beta,mu,a,b,d,Q,k,l,Wmat))
    }
  }
  lik
}

Try the funLBM package in your browser

Any scripts or data that you put into this service are public.

funLBM documentation built on April 11, 2022, 5:06 p.m.