pens2: Sensitivity analysis with Matching, MatchIt and designmatch...

Description Usage Arguments Value Examples

Description

Sensitivity analysis with Matching, MatchIt and designmatch objects for a continous outcome.

Usage

1
2
pens2(x, y = NULL, est = NULL, Gamma = 2, GammaInc = 0.1, data = NULL,
  treat)

Arguments

x

Treatment group outcomes or an objects from a Match,MatchIt or designmatch.

y

Control group outcomes in same order as treatment group outcomes such that members of a pair occupy the same row in both x and y. Should not be specified x is a Matching, MatchIt and designmatch objects.

est

Treatment effect. Must be specified if x is not a MatchIt object.

Gamma

Upper bound of sensitivity parameter

GammaInc

interval width for increasing gamma from 1 until the specified upper bound of sensitivity parameter is reached.

data

Dataframe used to during matching. You do not have to specify this parameter if x is a MatchIt object

treat

Treatmetn/Exposure variable name.

Value

a table of Rosenbaum bounds

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
43
44
45
46
47
48
49
50
51
52
53
54
55
## Loading lalonde data
library(Matching);library(MatchIt)
data("lalonde",package = "Matching")

## Sensitivity analysis with a matchit object
m.out = matchit(treat ~ age  + educ +  black + hisp +married + nodegr + re74  + re75  +
u74 + u75, family=binomial, data = lalonde, method = "nearest")

## Estimating treatment effect. Ideally, balance assessement should be done prior to estimating treatment effect
mod = lm(re78~age  + educ +  black + hisp +married + nodegr + re74  + re75  +u74 + u75,data = match.data(m.out))
pens2(x = m.out, y="re78",Gamma = 2, GammaInc = 0.1,est = 629.7)

## using match object
## Estimate Propensity Score
data("lalonde",package = "Matching")
DWglm <- glm(treat ~ age + I(age^2) + educ + I(educ^2) + black + hisp +married + nodegr + re74 + I(re74^2) + re75 + I(re75^2) +u74 + u75, family=binomial, data=lalonde)
## Specifying outcome and treatment(Exposure)
Y  <- lalonde$re78
Tr <- lalonde$treat
## Matching using Match object.
mDW  <- Match(Y=Y, Tr=Tr, X=DWglm$fitted, replace=FALSE)
## Sensitivity analysis
pens2(mDW, Gamma = 2, GammaInc = 0.1)

## Sensitivity analysis with a matchit object
data("lalonde",package = "designmatch")
library(designmatch)
attach(lalonde)
## Treatment indicator
t_ind = treatment
## Distance matrix
dist_mat = NULL
## Subset matching weight
subset_weight = 1
## Moment balance: constrain differences in means to be at most .05 standard deviations apart
mom_covs = cbind(age, education, black, hispanic, married, nodegree, re74, re75)
mom_tols = round(absstddif(mom_covs, t_ind, .05), 2)
mom = list(covs = mom_covs, tols = mom_tols)
## Fine balance
fine_covs = cbind(black, hispanic, married, nodegree)
fine = list(covs = fine_covs)
## Exact matching
exact_covs = cbind(black)
exact = list(covs = exact_covs)
## Solver options
t_max = 60*5
solver = "glpk"
approximate = 1
solver = list(name = solver, t_max = t_max, approximate = approximate,round_cplex = 0, trace = 0)
## Match
out = bmatch(t_ind = t_ind, dist_mat = dist_mat, subset_weight = subset_weight,mom = mom, fine = fine, exact = exact, solver = solver)

## Sensitivity analysis with designmatch Object
pens2(x = out, y="re78",Gamma = 2, GammaInc = 0.1,est = 234,treat = "treatment",data = lalonde)
detach(lalonde)

Ngendahimana/sensitivityR5 documentation built on June 24, 2020, 4:09 a.m.