match.2x {matchFeat}R Documentation

Pairwise Interchange Heuristic (2-Assignment-Exchange)

Description

This function implements the Pairwise Interchange Heuristic for the multidimensional assignment problem with decomposable costs (MDADC).

Usage

match.2x(x, sigma = NULL, unit = NULL, w = NULL, control = list())

Arguments

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 x to sample units (length mn). Must be specified only if x is a matrix.

w

weights for loss function: single positive number, p-vector of length, or (p,p) positive definite matrix

control

tuning parameters

Details

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.

Value

A list of class matchFeat with components

sigma

best assignment as set of permutations ((m,n) matrix)

cluster

best assignment as a cluster membership vector

objective

minimum objective value

mu

mean vector for each class/label ((p,m) matrix)

V

covariance matrix for each class/label ((p,p,m) array)

call

function call

References

Degras (2022) "Scalable feature matching across large data collections." doi:10.1080/10618600.2022.2074429

See Also

match.bca, match.bca.gen, match.gaussmix, match.kmeans, match.rec, match.template

Examples

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]
	
}

[Package matchFeat version 1.0 Index]