get_log_ML {perms} | R Documentation |
get_log_ML
Description
Computes the log marginal likelihood of the data from the log permanents. Given the computed log permanents log_perms, this function computes the log marginal likelihood using the formula (2.3) in [1]. It is assumed that there are no repeated trials. If the data contain repeated trials, then the appropriate log binomial factor must be added to the output of this function.
Usage
get_log_ML(log_perms, n, debug = FALSE)
Arguments
log_perms |
A vector length n containing the computed log permanents, where a zero permanent is indicated by a NA value. |
n |
Sample size. |
debug |
If |
Value
The estimated log marginal likelihood. A NA value is returned if there are no non-zero numbers.
References
[1] Christensen, D (2023). Inference for Bayesian nonparametric models with binary response data via permutation counting. Bayesian Analysis, Advance online publication, DOI: 10.1214/22-BA1353.
Examples
library(perms)
set.seed(1996)
n = 100
t = seq(0, 1, length.out=n)
y = c(rep(0, n/2), rep(1, n/2))
S = 200
X = matrix(runif(n*S),nrow = S, ncol = n)
log_perms = get_log_perms(X, t, y, debug = FALSE, parallel = FALSE, num_cores = NULL)
num_nonzero_perms = sum(!is.na(log_perms))
num_nonzero_perms
log_ML = get_log_ML(log_perms, n, FALSE)
log_ML