matching: Single Nearest Neighborhood Matching

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/matching.R

Description

Function for processing matching with propensity score

Usage

1
matching(z, score, replace=FALSE)

Arguments

z

vector of indicators for treatment or control.

score

vector of the propensity scores in the same order as z.

replace

whether the control units could be reused for matching, default is FALSE.

Details

Function for matching each treatment unit in turn the control unit (not previously chosen) with the closest propensity score

Value

The function returns a vector of indices that the corresponding unit is matched to. 0 means matched to nothing.

Author(s)

Jeniffer Hill jh1030@columbia.edu; Yu-Sung Su suyusung@tsinghua.edu.cn

References

Andrew Gelman and Jennifer Hill. (2006). Data Analysis Using Regression and Multilevel/Hierarchical Models. Cambridge University Press.

See Also

balance

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# matching first
data(lalonde)
attach(lalonde)
fit <- glm(treat ~ re74 + re75 + age + factor(educ) + 
            black + hisp + married + nodegr + u74 + u75, 
            family=binomial(link="logit"))
pscores <- predict(fit, type="response")
matches <- matching(z=lalonde$treat, score=pscores)
matched <- matches$cnts

# balance check!
b.stats <- balance(lalonde, treat, matched)
print(b.stats)
plot(b.stats)

Example output

Loading required package: MASS
Loading required package: Matrix
Loading required package: lme4

arm (Version 1.11-2, built: 2020-7-27)

Working directory is /work/tmp

Balance diagnostics assume that the estimand is the ATT 
Balance Statistics for Unmatched Data
--
          treat control unstd.diff abs.std.diff ratio
age       25.82   25.05       0.76         0.11    NA
educ      10.35   10.09       0.26         0.13    NA
black      0.84    0.83       0.02         0.04    NA
hisp       0.06    0.11      -0.05         0.20    NA
married    0.19    0.15       0.04         0.09    NA
nodegr     0.71    0.83      -0.13         0.28    NA
re74    2095.57 2107.03     -11.45         0.00    NA
re75    1532.06 1266.91     265.15         0.08    NA
re78    6349.15 4554.80    1794.34         0.23    NA
u74        0.71    0.75      -0.04         0.09    NA
u75        0.60    0.68      -0.08         0.17    NA
treat      1.00    0.00       1.00          Inf    NA
--

Balance Statistics for Matched Data
--
          treat control unstd.diff abs.std.diff ratio
age       25.82   24.85       0.97         0.14  0.90
educ      10.35   10.29       0.06         0.03  0.80
black      0.84    0.86      -0.02         0.04    --
hisp       0.06    0.06       0.00         0.00    --
married    0.19    0.15       0.04         0.10    --
nodegr     0.71    0.77      -0.06         0.14    --
re74    2095.57 1744.47     351.11         0.07  0.84
re75    1532.06 1410.79     121.27         0.04  1.01
re78    6349.15 4899.66    1449.48         0.18  0.72
u74        0.71    0.72      -0.02         0.04    --
u75        0.60    0.62      -0.02         0.04    --
treat      1.00    0.00       1.00          Inf    --
--

0.1065504 0.1280603 0.04476701 0.2034074 0.08999512 0.2775094 0.002343708 0.08236276 0.2280731 0.09189507 0.172253 Inf 
$raw
      treat         u75         u74        re78        re75        re74 
        Inf 0.172252986 0.091895072 0.228073063 0.082362755 0.002343708 
     nodegr     married        hisp       black        educ         age 
0.277509436 0.089995122 0.203407385 0.044767007 0.128060266 0.106550386 

$matched
     treat        u75        u74       re78       re75       re74     nodegr 
       Inf 0.04401551 0.03557229 0.18423912 0.03766980 0.07185043 0.14228914 
   married       hisp      black       educ        age 
0.09634772 0.00000000 0.04448187 0.02957225 0.13522920 

arm documentation built on Oct. 15, 2021, 3 p.m.

Related to matching in arm...