impute.NN_HD(DATA = NULL, distance = "man", weights = "range", attributes = "sim",
comp = "rw_dist", donor_limit = Inf, optimal_donor = "no",
list_donors_recipients = NULL)DATA.distance can be defined as:
weights can be defined as:
comp can be defined as:
donor_limit is a single number interpreted by its range:
optimal_donor is a single string interpreted by its value:
impute.mean, match.d_r_vam, reweight.data#Set the random seed to an arbitrary number
set.seed(421)
#Generate random integer matrix size 10x4
Y<-matrix(sample(x=1:100,size=10*4),nrow=10)
#remove 5 values, ensuring one complete covariate and 5 donors
Y[-c(1:5),-1][sample(1:15,size=5)]<-NA
#Impute using various different (arbitrarily chosen) settings
impute.NN_HD(DATA=Y,distance="man",weights="var")
impute.NN_HD(DATA=Y,distance=2,weights=rep(.5,4),donor_limit=2,optimal_donor="mmin")
impute.NN_HD(DATA=Y,distance="eukl",weights=.25,comp="mean",donor_limit=.2,
optimal_donor="vam")
impute.NN_HD(DATA=Y,distance="eukl",weights=.25,comp="mean",donor_limit=1,
optimal_donor="odd")Run the code above in your browser using DataLab