R/m_v_m0.R

#'@export
m_v_m0 <- function(dat, m, nsamps=1000){
  samps <-samp_from_grid(m$post, c("q", "gamma", "eta"), nsamps)
  llmat_m <- t(ll_v7_loo(samps$gamma, samps$eta, samps$q,
                         m$rho,
                         m$mix_grid$S1, m$mix_grid$S2, m$mix_grid$pi,
                         dat$beta_hat_1, dat$beta_hat_2, dat$seb1, dat$seb2))


  loo_m <- loo(llmat_m, r_eff = rep(1, nrow(dat)))
  llmat_m0 <- ll_v7_loo(0, 0, 0,
                      m$rho, m$mix_grid$S1, m$mix_grid$S2, m$mix_grid$pi,
                      dat$beta_hat_1, dat$beta_hat_2, dat$seb1, dat$seb2)

  diff <- loo_m$pointwise[,1]-llmat_m0
  est <- sum(diff)
  se <- sd(diff)*sqrt(nrow(dat))
  R <- list(est =est, se=se)
  return(R)

}
jean997/sherlockAsh documentation built on May 18, 2019, 11:45 p.m.