# 12 observations in clusters of size 3, 5, 4
id <- c(rep(2,3),rep(4,5),rep(6,4))
# each observation is in one of two classes
k <- 2
cvec <- c(1,1,2,1,1,2,2,2,1,1,2,2)
# alpha1 is LPWOR for outcomes in the same cluster
# when both are in class 1
# alpha1+alpha2 = LPWOR for pairs with
# one element from class 1 and one from class 2
# alpha1+alpha3 = LPWOR for pairs with both elements
# from class 2
dmat <- rbind(c(1,0,0),c(1,1,0),c(1,0,1))
out <- class2z(cvec,id,k,dmat)
# Data:
# id 2 2 2 4 4 4 4 4 6 6 6 6
#class 1 1 2 1 1 2 2 2 1 1 2 2
out$z[1:6,]
# [,1] [,2] [,3]
#[1,] 1 0 0
#[2,] 1 1 0
#[3,] 1 0 0
#[4,] 1 1 0
#[5,] 1 1 0
#[6,] 1 1 0
out$zid[1:6]
# 21 22 23 24 25 26
# 2 2 2 2 2 2
out$dmat
# a1 a2 a3
#(1,1) 1 0 0
#(1,2) 1 1 0
#(2,2) 1 0 1
#
Run the code above in your browser using DataLab