#get required library
library(readxl)
library(MatchIt)
library(Matching)
## Loading required package: MASS
## ## 
## ##  Matching (Version 4.9-7, Build Date: 2020-02-05)
## ##  See http://sekhon.berkeley.edu/matching for additional documentation.
## ##  Please cite software as:
## ##   Jasjeet S. Sekhon. 2011. ``Multivariate and Propensity Score Matching
## ##   Software with Automated Balance Optimization: The Matching package for R.''
## ##   Journal of Statistical Software, 42(7): 1-52. 
## ##
library(rbounds)
library(MASS)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:MASS':
## 
##     select
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(janitor)
## 
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(cobalt)
##  cobalt (Version 4.2.4, Build Date: 2020-11-05 17:30:21 UTC)
## 
## Attaching package: 'cobalt'
## The following object is masked from 'package:MatchIt':
## 
##     lalonde
library(Zelig)
## Loading required package: survival
library(ggplot2)
## 
## Attaching package: 'ggplot2'
## The following object is masked from 'package:Zelig':
## 
##     stat
library(devtools)
## Loading required package: usethis
#devtools::install_github("Ngendahimana/sensitivityR5", force=TRUE)
library(SensitivityR5)

set.seed(123)
#load dataframe
df <- read_excel("02.SeedSectorData.xlsx") %>% clean_names() %>% remove_empty()
## value for "which" not specified, defaulting to c("rows", "cols")
#change treatment variable to boolean
df$treatment = ifelse(df$affiliation == "Af", 1, 0)
head(df)
## # A tibble: 6 x 27
##    hhid seed_collection fgroup affiliation    ky    ka    ak av_age under6
##   <dbl>           <dbl> <chr>  <chr>       <dbl> <dbl> <dbl>  <dbl>  <dbl>
## 1     1               0 Ky     Af              1     0     0   56.7  0    
## 2     2               1 Ky     Af              1     0     0   19.6  0    
## 3     3               1 Ky     Af              1     0     0   31.6  0    
## 4     4               1 Ky     Af              1     0     0   22.2  0.333
## 5     5               0 Ky     Af              1     0     0   18.9  0    
## 6     6               0 Ky     Af              1     0     0   18.3  0.333
## # … with 18 more variables: over60 <dbl>, hh_size <dbl>, prop_eat <dbl>,
## #   prop_all <dbl>, too_weak <dbl>, too_alone <dbl>, paid_people <dbl>,
## #   volunteers <dbl>, i1 <dbl>, i2 <dbl>, i3 <dbl>, i4 <dbl>, i5 <dbl>,
## #   u1 <dbl>, u2 <dbl>, u3 <dbl>, u4 <dbl>, treatment <dbl>
#Replication of Table 4
#Unmatched difference 
MatchBalance(treatment ~ av_age + under6 + over60 + hh_size + prop_eat + prop_all + too_weak + too_alone + paid_people + volunteers, data = df)
## 
## ***** (V1) av_age *****
## before matching:
## mean treatment........ 24.572 
## mean control.......... 26.082 
## std mean diff......... -13.953 
## 
## mean raw eQQ diff..... 1.7103 
## med  raw eQQ diff..... 1.5 
## max  raw eQQ diff..... 7.3333 
## 
## mean eCDF diff........ 0.063621 
## med  eCDF diff........ 0.05754 
## max  eCDF diff........ 0.18849 
## 
## var ratio (Tr/Co)..... 0.94869 
## T-test p-value........ 0.35111 
## KS Bootstrap p-value.. 0.068 
## KS Naive p-value...... 0.077098 
## KS Statistic.......... 0.18849 
## 
## 
## ***** (V2) under6 *****
## before matching:
## mean treatment........ 0.10729 
## mean control.......... 0.11033 
## std mean diff......... -2.3419 
## 
## mean raw eQQ diff..... 0.021744 
## med  raw eQQ diff..... 0 
## max  raw eQQ diff..... 0.25 
## 
## mean eCDF diff........ 0.039265 
## med  eCDF diff........ 0.029762 
## max  eCDF diff........ 0.095238 
## 
## var ratio (Tr/Co)..... 0.74449 
## T-test p-value........ 0.88137 
## KS Bootstrap p-value.. 0.448 
## KS Naive p-value...... 0.80024 
## KS Statistic.......... 0.095238 
## 
## 
## ***** (V3) over60 *****
## before matching:
## mean treatment........ 0.051576 
## mean control.......... 0.067999 
## std mean diff......... -10.672 
## 
## mean raw eQQ diff..... 0.015454 
## med  raw eQQ diff..... 0 
## max  raw eQQ diff..... 0.25 
## 
## mean eCDF diff........ 0.028439 
## med  eCDF diff........ 0.027778 
## max  eCDF diff........ 0.053571 
## 
## var ratio (Tr/Co)..... 0.77676 
## T-test p-value........ 0.49282 
## KS Bootstrap p-value.. 0.622 
## KS Naive p-value...... 0.99942 
## KS Statistic.......... 0.053571 
## 
## 
## ***** (V4) hh_size *****
## before matching:
## mean treatment........ 5.7083 
## mean control.......... 5.8651 
## std mean diff......... -7.1747 
## 
## mean raw eQQ diff..... 0.20833 
## med  raw eQQ diff..... 0 
## max  raw eQQ diff..... 2 
## 
## mean eCDF diff........ 0.019015 
## med  eCDF diff........ 0.014881 
## max  eCDF diff........ 0.047619 
## 
## var ratio (Tr/Co)..... 0.85144 
## T-test p-value........ 0.63833 
## KS Bootstrap p-value.. 0.92 
## KS Naive p-value...... 0.99995 
## KS Statistic.......... 0.047619 
## 
## 
## ***** (V5) prop_eat *****
## before matching:
## mean treatment........ 0.22969 
## mean control.......... 0.18328 
## std mean diff......... 19.859 
## 
## mean raw eQQ diff..... 0.052583 
## med  raw eQQ diff..... 0.028571 
## max  raw eQQ diff..... 0.16667 
## 
## mean eCDF diff........ 0.067378 
## med  eCDF diff........ 0.056548 
## max  eCDF diff........ 0.19444 
## 
## var ratio (Tr/Co)..... 1.4552 
## T-test p-value........ 0.15579 
## KS Bootstrap p-value.. 0.034 
## KS Naive p-value...... 0.062566 
## KS Statistic.......... 0.19444 
## 
## 
## ***** (V6) prop_all *****
## before matching:
## mean treatment........ 0.37364 
## mean control.......... 0.35169 
## std mean diff......... 10.301 
## 
## mean raw eQQ diff..... 0.036733 
## med  raw eQQ diff..... 0.03869 
## max  raw eQQ diff..... 0.125 
## 
## mean eCDF diff........ 0.050725 
## med  eCDF diff........ 0.03373 
## max  eCDF diff........ 0.16468 
## 
## var ratio (Tr/Co)..... 0.84093 
## T-test p-value........ 0.50099 
## KS Bootstrap p-value.. 0.068 
## KS Naive p-value...... 0.16652 
## KS Statistic.......... 0.16468 
## 
## 
## ***** (V7) too_weak *****
## before matching:
## mean treatment........ 0.54167 
## mean control.......... 0.34921 
## std mean diff......... 38.357 
## 
## mean raw eQQ diff..... 0.19444 
## med  raw eQQ diff..... 0 
## max  raw eQQ diff..... 1 
## 
## mean eCDF diff........ 0.09623 
## med  eCDF diff........ 0.09623 
## max  eCDF diff........ 0.19246 
## 
## var ratio (Tr/Co)..... 1.099 
## T-test p-value........ 0.0092172 
## 
## 
## ***** (V8) too_alone *****
## before matching:
## mean treatment........ 0.58333 
## mean control.......... 0.30159 
## std mean diff......... 56.75 
## 
## mean raw eQQ diff..... 0.27778 
## med  raw eQQ diff..... 0 
## max  raw eQQ diff..... 1 
## 
## mean eCDF diff........ 0.14087 
## med  eCDF diff........ 0.14087 
## max  eCDF diff........ 0.28175 
## 
## var ratio (Tr/Co)..... 1.1609 
## T-test p-value........ 0.00012753 
## 
## 
## ***** (V9) paid_people *****
## before matching:
## mean treatment........ 0.27778 
## mean control.......... 0.57143 
## std mean diff......... -65.104 
## 
## mean raw eQQ diff..... 0.29167 
## med  raw eQQ diff..... 0 
## max  raw eQQ diff..... 1 
## 
## mean eCDF diff........ 0.14683 
## med  eCDF diff........ 0.14683 
## max  eCDF diff........ 0.29365 
## 
## var ratio (Tr/Co)..... 0.82413 
## T-test p-value........ 3.6911e-05 
## 
## 
## ***** (V10) volunteers *****
## before matching:
## mean treatment........ 0.5 
## mean control.......... 0.56349 
## std mean diff......... -12.61 
## 
## mean raw eQQ diff..... 0.055556 
## med  raw eQQ diff..... 0 
## max  raw eQQ diff..... 1 
## 
## mean eCDF diff........ 0.031746 
## med  eCDF diff........ 0.031746 
## max  eCDF diff........ 0.063492 
## 
## var ratio (Tr/Co)..... 1.0225 
## T-test p-value........ 0.39285 
## 
## 
## Before Matching Minimum p.value: 3.6911e-05 
## Variable Name(s): paid_people  Number(s): 9
#using nearest neighbor matching 
nn.mout <- matchit(treatment ~ av_age + under6 + over60 + hh_size + prop_eat + prop_all + too_weak + too_alone + paid_people + volunteers, data = df, estimand = "ATT", method = "nearest")

#print matching improvement
summary(nn.mout)
## 
## Call:
## matchit(formula = treatment ~ av_age + under6 + over60 + hh_size + 
##     prop_eat + prop_all + too_weak + too_alone + paid_people + 
##     volunteers, data = df, method = "nearest", estimand = "ATT")
## 
## Summary of balance for all data:
##             Means Treated Means Control SD Control Mean Diff eQQ Med eQQ Mean
## distance           0.5010        0.2851     0.1996    0.2158  0.2195   0.2177
## av_age            24.5721       26.0823    11.1122   -1.5102  1.5000   1.7103
## under6             0.1073        0.1103     0.1504   -0.0030  0.0000   0.0217
## over60             0.0516        0.0680     0.1746   -0.0164  0.0000   0.0155
## hh_size            5.7083        5.8651     2.3676   -0.1567  0.0000   0.2083
## prop_eat           0.2297        0.1833     0.1937    0.0464  0.0286   0.0526
## prop_all           0.3736        0.3517     0.2324    0.0220  0.0387   0.0367
## too_weak           0.5417        0.3492     0.4786    0.1925  0.0000   0.1944
## too_alone          0.5833        0.3016     0.4608    0.2817  0.0000   0.2778
## paid_people        0.2778        0.5714     0.4968   -0.2937  0.0000   0.2917
## volunteers         0.5000        0.5635     0.4979   -0.0635  0.0000   0.0556
##             eQQ Max
## distance     0.3094
## av_age       7.3333
## under6       0.2500
## over60       0.2500
## hh_size      2.0000
## prop_eat     0.1667
## prop_all     0.1250
## too_weak     1.0000
## too_alone    1.0000
## paid_people  1.0000
## volunteers   1.0000
## 
## 
## Summary of balance for matched data:
##             Means Treated Means Control SD Control Mean Diff eQQ Med eQQ Mean
## distance           0.5010        0.4117     0.1732    0.0893  0.1085   0.0895
## av_age            24.5721       25.9644    11.2775   -1.3923  1.3859   1.7806
## under6             0.1073        0.1066     0.1418    0.0007  0.0000   0.0204
## over60             0.0516        0.0801     0.2008   -0.0285  0.0000   0.0285
## hh_size            5.7083        5.6944     2.3052    0.0139  0.0000   0.2361
## prop_eat           0.2297        0.2241     0.2095    0.0056  0.0244   0.0388
## prop_all           0.3736        0.3742     0.2451   -0.0005  0.0357   0.0402
## too_weak           0.5417        0.4583     0.5018    0.0833  0.0000   0.0833
## too_alone          0.5833        0.4722     0.5027    0.1111  0.0000   0.1111
## paid_people        0.2778        0.3750     0.4875   -0.0972  0.0000   0.0972
## volunteers         0.5000        0.5417     0.5018   -0.0417  0.0000   0.0417
##             eQQ Max
## distance     0.1462
## av_age       7.3333
## under6       0.1250
## over60       0.3333
## hh_size      2.0000
## prop_eat     0.1667
## prop_all     0.2500
## too_weak     1.0000
## too_alone    1.0000
## paid_people  1.0000
## volunteers   1.0000
## 
## Percent Balance Improvement:
##             Mean Diff. eQQ Med eQQ Mean   eQQ Max
## distance       58.6414 50.5820  58.9043   52.7421
## av_age          7.8060  7.6058  -4.1146    0.0000
## under6         75.7211  0.0000   6.2699   50.0000
## over60        -73.6408  0.0000 -84.5221  -33.3333
## hh_size        91.1392  0.0000 -13.3333    0.0000
## prop_eat       87.8630 14.5833  26.1692    0.0000
## prop_all       97.6103  7.6923  -9.3026 -100.0000
## too_weak       56.7010  0.0000  57.1429    0.0000
## too_alone      60.5634  0.0000  60.0000    0.0000
## paid_people    66.8919  0.0000  66.6667    0.0000
## volunteers     34.3750  0.0000  25.0000    0.0000
## 
## Sample sizes:
##           Control Treated
## All           126      72
## Matched        72      72
## Unmatched      54       0
## Discarded       0       0
bal.tab(nn.mout)
## Call
##  matchit(formula = treatment ~ av_age + under6 + over60 + hh_size + 
##     prop_eat + prop_all + too_weak + too_alone + paid_people + 
##     volunteers, data = df, method = "nearest", estimand = "ATT")
## 
## Balance Measures
##                 Type Diff.Adj
## distance    Distance   0.4283
## av_age       Contin.  -0.1286
## under6       Contin.   0.0057
## over60       Contin.  -0.1853
## hh_size      Contin.   0.0064
## prop_eat     Contin.   0.0241
## prop_all     Contin.  -0.0025
## too_weak      Binary   0.0833
## too_alone     Binary   0.1111
## paid_people   Binary  -0.0972
## volunteers    Binary  -0.0417
## 
## Sample sizes
##           Control Treated
## All           126      72
## Matched        72      72
## Unmatched      54       0
#plot balance between covariates before and after matching
love.plot(nn.mout, abs=TRUE, var.order = "adjusted", line = TRUE, stats= c("ks.statistics", "abs difference"))

#calculate treatment effect using simulation
z.out <- zelig(i1 ~ treatment + av_age + under6 + over60 + hh_size + prop_eat + prop_all + too_weak + too_alone + paid_people + volunteers, data = match.data(nn.mout), model = "ls")
## Warning: `tbl_df()` is deprecated as of dplyr 1.0.0.
## Please use `tibble::as_tibble()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
## Warning: `group_by_()` is deprecated as of dplyr 0.7.0.
## Please use `group_by()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
## How to cite this model in Zelig:
##   R Core Team. 2007.
##   ls: Least Squares Regression for Continuous Dependent Variables
##   in Christine Choirat, Christopher Gandrud, James Honaker, Kosuke Imai, Gary King, and Olivia Lau,
##   "Zelig: Everyone's Statistical Software," https://zeligproject.org/
x.out <- setx(z.out, data = match.data(nn.out, "treat"), cond = TRUE)
s.out <- sim(z.out, x = x.out)

summary(s.out)
## 
##  sim x :
##  -----
## ev
##        mean         sd       50%      2.5%     97.5%
## 1 0.5063324 0.03262313 0.5071452 0.4419819 0.5688817
## pv
##           mean        sd       50%       2.5%    97.5%
## [1,] 0.5046454 0.3854788 0.5127219 -0.2549563 1.291935
#using genetic matching
gen.mout <- matchit(treatment ~ av_age + under6 + over60 + hh_size + prop_eat + prop_all + too_weak + too_alone + paid_people + volunteers, data = df, estimand = "ATT", method = "genetic", print.level = 0, pop.size = 1000, unif.seed=112,  int.seed=112)
## Loading required namespace: rgenoud
#print matching improvement
summary(gen.mout)
## 
## Call:
## matchit(formula = treatment ~ av_age + under6 + over60 + hh_size + 
##     prop_eat + prop_all + too_weak + too_alone + paid_people + 
##     volunteers, data = df, method = "genetic", estimand = "ATT", 
##     print.level = 0, pop.size = 1000, unif.seed = 112, int.seed = 112)
## 
## Summary of balance for all data:
##             Means Treated Means Control SD Control Mean Diff eQQ Med eQQ Mean
## distance           0.5010        0.2851     0.1996    0.2158  0.2195   0.2177
## av_age            24.5721       26.0823    11.1122   -1.5102  1.5000   1.7103
## under6             0.1073        0.1103     0.1504   -0.0030  0.0000   0.0217
## over60             0.0516        0.0680     0.1746   -0.0164  0.0000   0.0155
## hh_size            5.7083        5.8651     2.3676   -0.1567  0.0000   0.2083
## prop_eat           0.2297        0.1833     0.1937    0.0464  0.0286   0.0526
## prop_all           0.3736        0.3517     0.2324    0.0220  0.0387   0.0367
## too_weak           0.5417        0.3492     0.4786    0.1925  0.0000   0.1944
## too_alone          0.5833        0.3016     0.4608    0.2817  0.0000   0.2778
## paid_people        0.2778        0.5714     0.4968   -0.2937  0.0000   0.2917
## volunteers         0.5000        0.5635     0.4979   -0.0635  0.0000   0.0556
##             eQQ Max
## distance     0.3094
## av_age       7.3333
## under6       0.2500
## over60       0.2500
## hh_size      2.0000
## prop_eat     0.1667
## prop_all     0.1250
## too_weak     1.0000
## too_alone    1.0000
## paid_people  1.0000
## volunteers   1.0000
## 
## 
## Summary of balance for matched data:
##             Means Treated Means Control SD Control Mean Diff eQQ Med eQQ Mean
## distance           0.5010        0.4819     0.2013    0.0191  0.0642   0.0638
## av_age            24.5721       23.7111     7.8980    0.8610  1.0250   2.2937
## under6             0.1073        0.1027     0.1311    0.0046  0.0000   0.0211
## over60             0.0516        0.0294     0.0921    0.0222  0.0000   0.0265
## hh_size            5.7083        5.6667     1.8335    0.0417  0.0000   0.3750
## prop_eat           0.2297        0.2103     0.1965    0.0194  0.0542   0.0551
## prop_all           0.3736        0.3426     0.1947    0.0310  0.0264   0.0430
## too_weak           0.5417        0.5278     0.5056    0.0139  0.0000   0.0250
## too_alone          0.5833        0.5833     0.4993    0.0000  0.0000   0.0750
## paid_people        0.2778        0.2778     0.4536    0.0000  0.0000   0.1000
## volunteers         0.5000        0.5972     0.4967   -0.0972  0.0000   0.1000
##             eQQ Max
## distance     0.1345
## av_age      28.0000
## under6       0.1250
## over60       0.6667
## hh_size      2.0000
## prop_eat     0.1429
## prop_all     0.3333
## too_weak     1.0000
## too_alone    1.0000
## paid_people  1.0000
## volunteers   1.0000
## 
## Percent Balance Improvement:
##             Mean Diff.  eQQ Med eQQ Mean   eQQ Max
## distance       91.1630  70.7565  70.7145   56.5246
## av_age         42.9863  31.6667 -34.1105 -281.8182
## under6        -51.2115   0.0000   3.0029   50.0000
## over60        -35.0465   0.0000 -71.3980 -166.6667
## hh_size        73.4177   0.0000 -80.0000    0.0000
## prop_eat       58.2213 -89.5833  -4.8222   14.2857
## prop_all      -41.2275  31.7949 -17.0505 -166.6667
## too_weak       92.7835   0.0000  87.1429    0.0000
## too_alone     100.0000   0.0000  73.0000    0.0000
## paid_people   100.0000   0.0000  65.7143    0.0000
## volunteers    -53.1250   0.0000 -80.0000    0.0000
## 
## Sample sizes:
##           Control Treated
## All           126      72
## Matched        40      72
## Unmatched      86       0
## Discarded       0       0
print(bal.tab(gen.mout))
## Call
##  matchit(formula = treatment ~ av_age + under6 + over60 + hh_size + 
##     prop_eat + prop_all + too_weak + too_alone + paid_people + 
##     volunteers, data = df, method = "genetic", estimand = "ATT", 
##     print.level = 0, pop.size = 1000, unif.seed = 112, int.seed = 112)
## 
## Balance Measures
##                 Type Diff.Adj
## distance    Distance   0.0915
## av_age       Contin.   0.0796
## under6       Contin.   0.0354
## over60       Contin.   0.1441
## hh_size      Contin.   0.0191
## prop_eat     Contin.   0.0830
## prop_all     Contin.   0.1455
## too_weak      Binary   0.0139
## too_alone     Binary   0.0000
## paid_people   Binary   0.0000
## volunteers    Binary  -0.0972
## 
## Sample sizes
##                      Control Treated
## All                   126.        72
## Matched (ESS)          25.66      72
## Matched (Unweighted)   40.        72
## Unmatched              86.         0
#plot balance between covariates before and after matching
love.plot(gen.mout, abs=TRUE, var.order = "adjusted", line = TRUE, stats = "ks.statistics")

#calculate treatment effect using simulation
gen.z.out <- zelig(i1 ~ treatment + av_age + under6 + over60 + hh_size + prop_eat + prop_all + too_weak + too_alone + paid_people + volunteers, data = match.data(gen.mout), model = "ls")
## How to cite this model in Zelig:
##   R Core Team. 2007.
##   ls: Least Squares Regression for Continuous Dependent Variables
##   in Christine Choirat, Christopher Gandrud, James Honaker, Kosuke Imai, Gary King, and Olivia Lau,
##   "Zelig: Everyone's Statistical Software," https://zeligproject.org/
gen.x.out <- setx(gen.z.out, data = match.data(gen.mout, "treat"), cond = TRUE)
gen.s.out <- sim(gen.z.out, x = gen.x.out)

summary(gen.s.out)
## 
##  sim x :
##  -----
## ev
##       mean        sd       50%      2.5%     97.5%
## 1 0.595964 0.0377861 0.5963168 0.5181893 0.6712928
## pv
##           mean        sd       50%       2.5%    97.5%
## [1,] 0.5660769 0.4077106 0.5815421 -0.2683721 1.350448
#sensitivity analysis for genetic matching
pens2(x = gen.mout, y="i1",Gamma = 5, GammaInc = 0.1, est = 0.5987271)
## 
##  Rosenbaum Sensitivity Test for Wilcoxon Signed Rank P-Value 
##  
## Unconfounded estimate ....  0 
## 
##  Gamma Lower bound Upper bound
##    1.0           0      0.0000
##    1.1           0      0.0000
##    1.2           0      0.0000
##    1.3           0      0.0000
##    1.4           0      0.0000
##    1.5           0      0.0000
##    1.6           0      0.0000
##    1.7           0      0.0001
##    1.8           0      0.0001
##    1.9           0      0.0002
##    2.0           0      0.0003
##    2.1           0      0.0005
##    2.2           0      0.0008
##    2.3           0      0.0011
##    2.4           0      0.0015
##    2.5           0      0.0021
##    2.6           0      0.0028
##    2.7           0      0.0037
##    2.8           0      0.0047
##    2.9           0      0.0060
##    3.0           0      0.0074
##    3.1           0      0.0091
##    3.2           0      0.0109
##    3.3           0      0.0131
##    3.4           0      0.0154
##    3.5           0      0.0181
##    3.6           0      0.0210
##    3.7           0      0.0241
##    3.8           0      0.0276
##    3.9           0      0.0313
##    4.0           0      0.0352
##    4.1           0      0.0395
##    4.2           0      0.0439
##    4.3           0      0.0487
##    4.4           0      0.0537
##    4.5           0      0.0590
##    4.6           0      0.0645
##    4.7           0      0.0702
##    4.8           0      0.0762
##    4.9           0      0.0824
##    5.0           0      0.0888
## 
##  Note: Gamma is Odds of Differential Assignment To
##  Treatment Due to Unobserved Factors 
## 
#sensitivity analysis for nearest neighbor matching
pens2(x = nn.mout, y="i1",Gamma = 7, GammaInc = 0.1, est = 0.5057401)
## 
##  Rosenbaum Sensitivity Test for Wilcoxon Signed Rank P-Value 
##  
## Unconfounded estimate ....  0 
## 
##  Gamma Lower bound Upper bound
##    1.0           0      0.0000
##    1.1           0      0.0000
##    1.2           0      0.0000
##    1.3           0      0.0000
##    1.4           0      0.0000
##    1.5           0      0.0000
##    1.6           0      0.0000
##    1.7           0      0.0000
##    1.8           0      0.0000
##    1.9           0      0.0000
##    2.0           0      0.0000
##    2.1           0      0.0001
##    2.2           0      0.0001
##    2.3           0      0.0001
##    2.4           0      0.0002
##    2.5           0      0.0003
##    2.6           0      0.0004
##    2.7           0      0.0005
##    2.8           0      0.0006
##    2.9           0      0.0008
##    3.0           0      0.0010
##    3.1           0      0.0013
##    3.2           0      0.0016
##    3.3           0      0.0019
##    3.4           0      0.0023
##    3.5           0      0.0028
##    3.6           0      0.0033
##    3.7           0      0.0039
##    3.8           0      0.0045
##    3.9           0      0.0052
##    4.0           0      0.0059
##    4.1           0      0.0068
##    4.2           0      0.0076
##    4.3           0      0.0086
##    4.4           0      0.0096
##    4.5           0      0.0107
##    4.6           0      0.0119
##    4.7           0      0.0131
##    4.8           0      0.0144
##    4.9           0      0.0158
##    5.0           0      0.0172
##    5.1           0      0.0188
##    5.2           0      0.0204
##    5.3           0      0.0220
##    5.4           0      0.0237
##    5.5           0      0.0255
##    5.6           0      0.0274
##    5.7           0      0.0293
##    5.8           0      0.0313
##    5.9           0      0.0334
##    6.0           0      0.0355
##    6.1           0      0.0377
##    6.2           0      0.0399
##    6.3           0      0.0422
##    6.4           0      0.0446
##    6.5           0      0.0470
##    6.6           0      0.0495
##    6.7           0      0.0520
##    6.8           0      0.0545
##    6.9           0      0.0572
##    7.0           0      0.0598
## 
##  Note: Gamma is Odds of Differential Assignment To
##  Treatment Due to Unobserved Factors 
##