match_info: individual level information

Description Usage Arguments Details Value Author(s) Examples

View source: R/match_info.R

Description

Extra fullmatch info

Usage

1
match_info(data, tr, cl, id = NULL, trv = 1, keep = NULL, warn = TRUE)

Arguments

data

the data

tr

the binary treatment variable, as character

cl

the clustering variable, as character

id

the id variable (optional), as character. If this is used then only the relevant variables (+ those specified by 'keep') will be returned (in the same order as data).

trv

the value of the treatment (of variable tr), '1' by default

keep

character vector of the names of variables you'd like to keep (if id is not NULL)

warn

warn in case of emergency?

Details

Some additional details I find useful in connection with a fullmatch (or similar matching)

Value

data frame (tbl_df) with new parameters tr_n the number of treated within the cluster, ctrl_n the number of controls within the cluster, ate.weight the weight for calculating the average treatment effect, att.weight the weight for calculating the average treatment effect for the treated, atc.weight the weight for calculating the average treatment effect for the controls, cid for describing the match it is useful to have a 'cluster id', use this with e.g. dplyr::group_by(tr, cid) and summarise with functions using weight = cl.weight to get stats for weighted treated and control statistics.

Author(s)

Henrik Renlund

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
df <- data.frame(
   id = 1:13,
   foo = c(0,0,1, 0,1, 1,1,0, 1,1,0,0, 0),
   bar = c(rep(c(letters[1:4]), c(3,2,3,4)), NA),
   x = round(runif(13),2)
)
mi <- match_info(data = df, tr = "foo", cl = "bar")
attributes(mi)
match_info(data = df, tr = "foo", cl = "bar", id = "id")
df$foo <- ifelse(df$foo == 1, "Treated", "Control")
match_info(data = df, tr = "foo", cl = "bar", trv = "Treated")

renlund/miscmatch documentation built on May 27, 2019, 5:52 a.m.