love_plot: Love plots with 'designmatch','matchIt','Matching' Object

Description Usage Arguments Value Examples

Description

## Love plot with 'designmatch' package object

Usage

1
love_plot(X, data, covList, legend_position = "topright", treat = NULL)

Arguments

data

dataset before its preprocessed.

covList

a vector of covariates to be balanced.

treat

Exposure variable name

x

A 'designmatch','matchIt','Matching' Object

Value

a plot of standardized difference.

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
56
57
58
59
60
data("lalonde",package = "cobalt")
attach(lalonde)

## Treatment indicator
t_ind =lalonde$treat

## 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, educ, black, hispan, 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, hispan, 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)

## Cardinality matching
out = bmatch(t_ind = t_ind, dist_mat = dist_mat, subset_weight = subset_weight, mom = mom, fine = fine, exact = exact, solver = solver)

# Indices of the treated units and matched controls
t_id = out$t_id
c_id = out$c_id
detach(lalonde)

# Example of cardinality Matching
love_plot(X =out, data = lalonde , covList=c("age", "educ", "black", "hispan", "married", "nodegree", "re74", "re75"))

# Example with  MatchIt package
# data("lalonde") if not yet loaded
covs0 <- subset(lalonde, select = -c(treat, re78, nodegree, married))
# Nearest neighbor 1:1 matching with replacement
library("MatchIt") #if not yet loaded
m.out <- matchit(f.build("treat", covs0), data = lalonde, method = "nearest", replace = TRUE)
love_plot(X =m.out, data = lalonde , covList=c("age", "educ", "black", "hispan", "married", "nodegree", "re74", "re75"))

# Example with Matching package

library("Matching")
#data("lalonde") #If not yet loaded
covs0 <- subset(lalonde, select = -c(treat, re78, nodegree, married))
fit <- glm(f.build("treat", covs0), data = lalonde, family = "binomial")
p.score <- fit$fitted.values
match.out <- Match(Tr = lalonde$treat, X = p.score, estimand = "ATT")
std_dif_data =bal.tab(match.out, formula = f.build("treat", covs0), data = lalonde)
love_plot(X, data = lalonde , covList=c("age", "educ", "black", "hispan", "re74", "re75"),treat = "treat")

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