R/likelihood_orig_phi.R

Defines functions likelihood_orig_phi

Documented in likelihood_orig_phi

likelihood_orig_phi <- function(params, phi, data) {
  lam2 <- params[1, ]; theta1 <- params[2, ]; theta2 <- params[3, ]
  z1 <- data[1]; z2 <- data[2]; m01 <- data[3]; m02 <- data[4]
  y01 <- data[5]; y02 <- data[6]; N0 <- data[7]; N <- data[8]

  log_lik <-
    m01 * log(phi) + (m01 + m02 + z1 + z2) * log(lam2) -
    lam2 * (phi + 1) * (N0 + N) +
    z1 * log(phi * (1 - theta1) + theta2) +
    z2 * log((1 - theta2) + phi * theta1) +
    y01 * log(theta1) + (m01 - y01) * log(1 - theta1) +
    y02 * log(theta2) + (m02 - y02) * log(1 - theta2) +
    0.001 * log(0.001) - lgamma(0.001) +
    (0.001 - 1) * log(lam2) - 0.001 * lam2

  matrix(exp(log_lik), ncol = ncol(params))
}
BriceonWiley/IntegratedLikelihood.R documentation built on Aug. 21, 2020, 11 p.m.