bsmatch: Title

Description Usage Arguments Value Examples

View source: R/bsmatch.R

Description

Title

Usage

1
bsmatch(object, Z2)

Arguments

object

A data.frame, output from the function otmatch.

Z2

A optional matrix, if we want to add some variables for the stratified balanced sampling step.

Value

A data.frame that contains the matching. The first two columns contain the unit identities of the two samples. The third column is the final weight. All remaining columns are the matching variables.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#--- SET UP
N=1000
p=5
X=array(rnorm(N*p),c(N,p))
EPS= 1e-9

n1=100
n2=200

s1=srswor(n1,N)
s2=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)

#--- 

out <- bsmatch(object)




round(colSums(object$conc$weight*object$conc),3)
round(colSums(cbind(w1*X1,w2*X2)),3)
round(colSums((out$conc$weight/out$q)*out$conc),3)

RJauslin/transportMatching documentation built on Dec. 18, 2021, 8:49 a.m.