match_weight | R Documentation |
Different weightings and some additional details I find useful in connection with a fullmatch (or similar matching)
match_weight(tr, cl, id, data = NULL, trv = 1)
tr |
the binary treatment variable, as character |
cl |
the clustering variable, as character |
id |
the id variable, as character. |
data |
the data |
trv |
the value of the treatment (of variable |
data frame with new parameters n
, number of individuals in
each cluster, 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.
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)
)
str(match_weight(data = df, tr = "foo", cl = "bar", id = "id"))
df$foo <- ifelse(df$foo == 1, "Treated", "Control")
str(match_weight(tr = df$foo, cl = df$bar, id = df$id, trv = "Treated"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.