Convert individual-level distance matrix to average distance matrix at cohort level

avg_dist_func(dist_mat, cohortid.vec)

Arguments

dist_mat

distance matrix

cohortid.vec

a vector of cohort/group id for all observations e.g., rep(1:4,each=100)