MakeCompMatrix {dga} | R Documentation |
Calls CompLogML to create a matrix of number of possible components by length(Nmissing) log marginal likelihoods. Calculates the log marginal likehood of each possible marginal table for every value of Nmissing.
MakeCompMatrix(p, delta, Y, Nmissing)
p |
Number of lists |
delta |
Prior hyperparameter of the Dirichlet distribution. |
Y |
The |
Nmissing |
The vector of possible values for the missing cell. |
A matrix of log marginal likelihoods.
James Johndrow james.johndrow@gmail.com and Kristian Lum kl@hrdag.org
## The function is currently defined as function (p, delta, Y) { compLMLs <- matrix(0, nrow = 2^p - 1, ncol = length(Nmissing)) bins <- integer.base.b(1:(2^p - 1), 2) for (i in 1:(2^p - 1)) { inds <- which(bins[i, ] == 1) D <- c(apply(Y, inds, sum)) Dmat <- t(matrix(D, ncol = length(Nmissing), nrow = length(D))) Dmat[, 1] <- Dmat[, 1] + Nmissing alpha <- rep(delta * 2^(p - sum(bins[i, ])), ncol(Dmat)) compLMLs[i, ] <- CompLogML(Dmat, alpha) } return(compLMLs) }