R/bf.weighted_sum.R

Defines functions bf.weighted_sum

Documented in bf.weighted_sum

#' Bayes Factor Weighted Summation
#'
#'A function calculates the weighted summation of bayes factor.
#'
#' @param w Input weight vector.
#' @param bf Input bayes factor vector
#' @param i Individual index.
#'
#' @return
#' Weighted sum for bayes factor in log scale.
#'
bf.weighted_sum<-function(w,bf,i){
  K<-length(w)
  bf.sum=0
  bf.m<-max(bf[((i-1)*K+1):(i*K)])
  bf.sum=sum(w*exp(bf[((i-1)*K+1):(i*K)]-bf.m))
  return(bf.m+log(bf.sum))
}

Try the INTRIGUE package in your browser

Any scripts or data that you put into this service are public.

INTRIGUE documentation built on Nov. 8, 2020, 4:30 p.m.