R/pairwiseProb.R

pairwiseProb <-
function(prefres=NULL,burn=0){
  pref<-prefres$PopPref
  mcmc<-dim(pref)[2]
  ## remove burnin and collect prefernce data
  pref<-pref[,(burn + 1):mcmc]
  nCat<-dim(pref)[1]
  pairP<-array(dim=c(nCat,nCat))
  for (i in 1:nCat){
    for (j in 1:nCat){
      if (i == j){ ## diagonal of matrix
        pairP[i,j]<-0
      }
      else {
        pairP[i,j]<-sum(pref[i,] > pref[j,]) / length(pref[i,])
      }
    }
  }
  return(pairP)
}

Try the bayespref package in your browser

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

bayespref documentation built on May 2, 2019, 11:28 a.m.