Research Article

Community-Based Decision Making and Priority Setting Using the R Software: The Community Priority Index

Algorithm 3

CI95.CPI = function(data, likert = 3, boot = 10000)
n.question = length(unique(data[,2]))
CI95 = matrix(0, n.question, 2)
Colnames(CI95) = c(LL, UL)
data = likertCheck(data, likert)
### Boostrapping
### Create the matrix for storing the CPIs of each simulation
B.CPI = matrix(0, boot, n.question)
For (i in 1:boot)
 {
  set.seed(i)
  B.index = sample(1:nrow(data), nrow(data), replace = TRUE)
  B.Data = data[B.index,]
  if (length(CPICal(data = B.Data)[,3])  ==  n.question)
   B.CPI[i,] = CPICal(data = B.Data)[,3]
  else B.CPI[i,] = NA
 }
for (i in 1:n.question)
  CI95[i,] = quantile(B.CPI[,i], c(.025, .975), na.rm = TRUE)
CI95