R/Miscellanea.R

#'@importFrom Rcpp evalCpp sourceCpp
#'@importFrom mvtnorm rmvnorm
#'@useDynLib PhDPack

# Full conditionals for alpha: cluster parameter
alpha_update <-  function(V,H,priors) {
  max(rgamma(1,priors$a+H-1,priors$a - sum(log(1 - V[-H]))),1e-15)
}

# Global error in case of regression
sigma_update <- function(y,theta,cluster,a,b){
  residuals <- y - theta[cluster,]
  sqrt(1/rgamma(1, a + length(residuals)/2, b + sum(residuals^2)/2))  
} 
tommasorigon/PhDPack documentation built on May 31, 2019, 6:19 p.m.