norm_fact <- sum(gam)
sumLogLLH <- sumLogLLH + log(norm_fact) - log((2 * base::pi)^(m/2))
}
- llhLambda <- c(sumLogLLH/n, (dimension + m + 1) * k - 1)
+ llhLambda <- c(-sumLogLLH/n, (dimension + m + 1) * k - 1)
- # densite <- vector("double", n)
- # for (r in 1:k)
- # {
- # if (length(col.sel) == 1)
- # {
- # delta <- (Y %*% rhoLambda[, , r] - (X[, col.sel] %*% t(phiLambda[col.sel, , r])))
- # } else delta <- (Y %*% rhoLambda[, , r] - (X[, col.sel] %*% phiLambda[col.sel, , r]))
- # densite <- densite + piLambda[r] * det(rhoLambda[, , r])/(sqrt(2 * base::pi))^m *
- # exp(-rowSums(delta^2)/2)
- # }
- # llhLambda <- c(mean(log(densite)), (dimension + m + 1) * k - 1)
list(phi = phiLambda, rho = rhoLambda, pi = piLambda, llh = llhLambda)
}