This function allows transforming a matching vector to a binary matching matrix. A matching vector is of length N where each element indicates the submatch to which the observation belongs to. Notice that this is not the same as the group allocation vector that is provided by the match.allocate-function. The binary matching matrix is of size N x N where 0 indicates that the observations have been part of a different submatch, and 1 indicates that the observations have been part of the same submatch. Diagonal is always 0 although an observation is always in the same submatch with its self.
A matching vector 'x'
N times N binary matching matrix, where 0 indicates that the observations have been part of a different submatch, and 1 indicates that the observations have been part of the same submatch.
Teemu Daniel Laajala <[email protected]>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
data(vcapwide) # Construct an Euclidean distance example distance matrix using 15 observations from the VCaP study d <- as.matrix(dist(vcapwide[1:15,c("PSAWeek10", "BWWeek10")])) bb3 <- match.bb(d, g=3) str(bb3) solvec <- bb3$solution # matching vector, where each element indicates to which submatch each observation belongs to solvec mat <- match.vec2mat(solvec) mat which(mat[1,] == 1) # E.g. the first, third and thirteenth observation are part of the same submatch which(solvec == solvec) # Similarly
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.