| match.2x | R Documentation |
This function implements the Pairwise Interchange Heuristic for the multidimensional assignment problem with decomposable costs (MDADC).
match.2x(x, sigma = NULL, unit = NULL, w = NULL, control = list())
x |
data: matrix of dimensions (mn,p) or 3D array of dimensions (p,m,n) with m = number of labels/classes, n = number of sample units, and p = number of variables) |
sigma |
permutations: matrix of dimensions (m,n) |
unit |
integer (=number of units) or vector mapping rows of |
w |
weights for loss function: single positive number, p-vector of length, or (p,p) positive definite matrix |
control |
tuning parameters |
Use of this function requires to have the GUROBI software and its R interface package installed. Both can be downloaded from https://www.gurobi.com after obtaining a free academic license.
A list of class matchFeat with components
sigmabest assignment as set of permutations ((m,n) matrix)
clusterbest assignment as a cluster membership vector
objectiveminimum objective value
mumean vector for each class/label ((p,m) matrix)
Vcovariance matrix for each class/label ((p,p,m) array)
callfunction call
Degras (2022) "Scalable feature matching across large data collections." doi: 10.1080/10618600.2022.2074429
match.bca, match.bca.gen,
match.gaussmix, match.kmeans,
match.rec, match.template
if (require(gurobi)) {
## Generate small example
m <- 3 # number of classes
n <- 10 # number of statistical units
p <- 5 # number of variables
mu <- matrix(rnorm(p*m),p,m) # mean vectors
sigma <- 0.1
x <- array(as.vector(mu) + rnorm(p*m*n,sigma), c(p,m,n))
## Match all feature vectors
result <- match.2x(x)
## Display results
result$cost # objective value = assignment cost
result$sigma # solution permutations
xmatched <- array(dim=dim(x))
## Matched feature vectors
for (i in 1:n)
xmatched[,,i] <- x[,result$sigma[,i],i]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.