# match.mat2vec: Transform a binary matching matrix to a matching vector In hamlet: Hierarchical Optimal Matching and Machine Learning Toolbox

## Description

This function transforms a binary matching matrix to a matching vector. 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.

## Usage

 `1` ```match.mat2vec(xmat) ```

## Arguments

 `xmat` A binary matching matrix 'xmat'

## Value

A matching vector where each element indicates submatch the observation belongs to

## Note

Notice that the particular index numbers produced by match.mat2vec may be different to that of the branch and bound solution vector, but that the submatches shared by observations are common.

## Author(s)

Teemu Daniel Laajala <teelaa@utu.fi>

`match.allocate` `match.bb` `match.vec2mat` `match.dummy`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17``` ```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) mat <- bb3\$matrix # matching vector, where each element indicates to which submatch each observation belongs to mat solvec <- match.mat2vec(mat) which(mat[1,] == 1) # E.g. the first, third and thirteenth observation are part of the same submatch which(solvec == solvec) # Similarly ```