get an incidence matrix Z to reorder uID to yID by yID = Z*uID
function mkmat_incidence_factor(yID,uID)
Z = spzeros(length(yID),length(uID))
uIDdict = Dict()
for (index,id) in enumerate(uID)
uIDdict[id]=index
end
rowi = 1
for id in yID
if haskey(uIDdict,id)
index = uIDdict[id]
else
error(id, " is not found!")
end
Z[rowi,index]=1
rowi = rowi+1
end
return Z
old:
get an incidence matrix Z to reorder uID to yID by yID = Z*uID
function mkmat_incidence_factor(yID,uID) Z = spzeros(length(yID),length(uID))
end