log_marginal: R Function to compute the cluster-specific marginal...

Description Usage Arguments Value Examples

View source: R/RcppExports.R

Description

This R function computes the marginal likelihood by integrating over the distribution of component specific parameter (e.g., machine usage profiles). This function conditions upon a few model parameters: the true and false positive rates (theta and psi), the Q matrix and p-the prevalence parameter for each machines.

Usage

1
log_marginal(Y, eta_star_enumerate, Q, p, theta, psi)

Arguments

Y

the data for the current cluster (a subset of observations.)

eta_star_enumerate

fixed binary matrix of 2^M rows and M columns. Need to be prespecified.

Q

Q-matrix

p

prevalence parameter for each machine; should be a vector of dimension M.

theta

true positive rates

psi

true positive rates

Value

log of marginal likelihood given other model parameters.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# simulate data:
L0 <- 100
options_sim0  <- list(N = 200,  # sample size.
                      M = 3,   # true number of machines.
                      L = L0,   # number of antibody landmarks.
                      K = 8,    # number of true components.,
                     theta = rep(0.8,L0), # true positive rates
                     psi   = rep(0.01,L0), # false positive rates
                     alpha1 = 1, # half of the people have the first machine.
                     frac = 0.2, # fraction of positive dimensions (L-2M) in Q.
                     #pop_frac = rep(1/K0,K0) # population prevalences.
                     #pop_frac = (1:K0)/sum(1:K0) # population prevalences.
                     pop_frac = c(rep(2,4),rep(1,4)) # population prevalences.
)

 simu     <- simulate_data(options_sim0, SETSEED=TRUE)
 simu_dat <- simu$datmat
 Y <- simu_dat
 Q <- simu$Q
 p <- c(0.5,0.25,0.1,0.02,0.05)
 theta <- options_sim0$theta
 psi   <- options_sim0$psi
 H_enumerate <- as.matrix(expand.grid(rep(list(0:1), options_sim0$M)),ncol=options_sim0$M)

#log_marginal0(Y, Q, p, theta, psi)
log_marginal(Y,H_enumerate, Q, p, theta, psi) # <-- this is the Rcpp implementation.

zhenkewu/rewind documentation built on Sept. 9, 2020, 3:40 p.m.