#--- SET UP
N=1000
p=5
X=array(rnorm(N*p),c(N,p))
EPS= 1e-9
n1=100
n2=200
s1=sampling::srswor(n1,N)
s2=sampling::srswor(n2,N)
id1=(1:N)[s1==1]
id2=(1:N)[s2==1]
d1=rep(N/n1,n1)
d2=rep(N/n2,n2)
X1=X[s1==1,]
X2=X[s2==1,]
#--- HARMONIZATION
re=harmonize(X1,d1,id1,X2,d2,id2)
w1=re$w1
w2=re$w2
#--- STATISTICAL MATCHING WITH OT
object = otmatch(X1,id1,X2,id2,w1,w2)
#--- BALANCED SAMPLING
out <- bsmatch(object)
Run the code above in your browser using DataLab