Skip to contents

A function for simulating data

Usage

matched.data(f, data, dist, order = "data", replace = FALSE)

Arguments

f

a two sided formula containing the treatment variable on the left side and the matching variables on the right

data

a dataframe of the data that is to be used for matching

dist

a matching distance, either "Propensity Score" or "Mahalanobis"

order

a named order of "data", "smallest", "largest", "random" to perform matches and is only relevant if replace = TRUE

  • "data" just uses the order the data is already in

  • "smallest" matches by the smallest propensity score first

  • "largest" matches by the largest propensity score first

  • "random" matches on a random order every time

replace

boolean value of whether to replace matched units or not

Value

A list of items that are generated from the matching process

Details

The output is a list containing the following:

  • paired.data a dataframe of the matched pairs of data (prefix t. for treated group and c. for control group) with the calculated distance and order of matching

  • matched.data a dataframe with the matched data ready for analysis

  • data a dataframe of the original data

  • formula the formula used for matching

  • distance the distance used for matching

  • propensity a numeric vector of propensity scores in the same order as the original data

  • stratification a factored vector which has stratified the propensity score into groups (between 5 and 10)

  • wt.ATE a numeric vector of the average treatment effect based on the propensity score

  • wt.ATT a numeric vector of the average treatment effect on the treated based on the propensity score

  • wt.Matched a vector of weights based on how the matching occurred

  • d.m the 'DenseMatrix' output from the optmatch::match_on() function used for matching

  • pairs a dataframe with the row labels for each treated unit and it's matched control with the calculated distance between them

  • treatment the treatment variable

  • order the order the matches were conducted in

  • replacement was replacement used to match, TRUE or FALSE

Examples

#simulate some data
d <- create.sim.data(1,2)
#matching formula
f <- t~X1+X2
#create matched data object
M <- matched.data(f,d,"Propensity Score")