Learn R Programming

HotDeckImputation (version 1.0.0)

match.d_r_odd: Donor-Recipient Matching via Optimal Donor Distribution Method

Description

A function that performs the optimal donor distribution method. GLPK is used to find the optimal solution to the integer program.

Usage

match.d_r_odd(distance = NULL, recipients=NULL, donors=NULL, donor_limit=NULL)

Arguments

distance
A distance matrix of dimensions length(donors) * length(recipients)
recipients
A vector of object (row) numbers from the original data matrix, indicating which objects require imputation.
donors
A vector of object (row) numbers from the original data matrix, indicating which objects may be used for imputation.
donor_limit
A vector of length(donors) detailing how often any one donor may be used.

Value

  • A matrix of dimensions length(recipients) * 2. The first column, named recipients, is equivalent to recipients. The second column, named donors, contains the donor that is matched to any of the recipients.

References

Domschke, W. (1995) Logistik: Transport. Munich: Oldenbourg. [in German]

See Also

impute.NN_HD, match.d_r_vam

Examples

Run this code
#Set the random seed to an arbitrary number
set.seed(421)

#Set up a random distance matrix
   ndonor=20
   nrecip=20
   distance<-matrix(sample(1:100,replace=TRUE,size=ndonor*nrecip),nrow=ndonor,ncol=nrecip)
#Name donors and recipients
   donors<-1:nrow(distance)
   recipients<-(nrow(distance)+1):(nrow(distance)+ncol(distance))
   colnames(distance)<-recipients
   rownames(distance)<-donors
#Set up the donor limit variable
   donor_limit<-rep(1,length(donors))

#perform the matching
match.d_r_odd(distance=distance,recipients=recipients,donors=donors,
   donor_limit=donor_limit)

Run the code above in your browser using DataLab