R/logLik_t_mixture.r

Defines functions logLik.t.mixture

Documented in logLik.t.mixture

logLik.t.mixture<-function(n, j, pi, mu, s, df)
{
  K=length(pi)
  uppers_log = pt((rep(j,each=K)+1/2-mu)/s, df, log.p=TRUE)
  lowers_log = pt((rep(j,each=K)-1/2-mu)/s, df, log.p=TRUE)

  numerators_log <- log(pi) + matrix(uppers_log + VGAM::log1mexp(uppers_log-lowers_log), nrow=K)
  denominators_log = matrixStats::colLogSumExps(numerators_log)

  return(sum(denominators_log*n))
}
sp2019-antibiotics/Team-Student documentation built on Nov. 5, 2019, 9:13 a.m.