Description Usage Arguments Value Examples
View source: R/dist.ps_function.R
Takes in a two data frames one with treatment and one with control units including the variables: Longitude, Latitude and propensity scores (as prop.scores) and returns a matrix of the matched pairs using DAPS, and information on PS difference, matching difference, distance. Caliper can can be specified on PS difference or DAPS.
1 2 3 4 5 |
treated |
A data frame include the treated units and the variables: 'Longitude', 'Latitude' and propensity scores (named 'prop.scores'). The rownames of treated should be the unit ids. |
control |
Control units. Same variables as in treated. |
caliper |
A caliper of DAPS or PS difference for matching. |
weight |
Number between 0 and 1, percentage of matching weight to be given on propensity score difference. |
coords.columns |
If the columns of coordinates are not named 'Longitude', 'Latitude', coords.cols should be the column indices corresponding to longitude and latitude accordingly. |
distance |
Function that takes in the distance matrix and returns the standardized distance matrix. Defaults to the function that subtracks the minimum and divides by the range |
caliper_type |
Whether we want the caliper to be on DAPS or on the PS. caliper_type must either be 'DAPS', or 'PS'. |
coord_dist |
Set to true when we want to use a distance function that calculates the spherical distance of points instead of euclidean. Defaults to FALSE. |
matching_algorithm |
Argument with options 'optimal', or 'greedy'. The optimal choice uses the optmatch R package to acquire the matches based on propensity score difference and a caliper on distance. The greedy option matches treated and control units sequentially, starting from the ones with the smallest propensity score difference. Defaults to 'optimal'. |
remove.unmatchables |
Logical. Argument of the optmatch function. Defaults to FALSE. If set to FALSE, the matching fails unless all treated units are matched. If set to TRUE, matching might return matches only for some of the treated units. |
A dataframe, where each row corresponds to each treated unit, and includes: the control unit to which it was matched, their propensity score difference, their DAPS difference, their distance, their standardized distance. NAs in the data frame correspond to units that were not matched.
1 2 3 4 5 6 7 8 9 | data('toyData')
toyData$prop.scores <- glm(Z ~ X1 + X2 + X3 + X4, family = binomial,
data = toyData)$fitted.values
daps <- dist.ps(treated = toyData[toyData$Z == 1, ],
control = toyData[toyData$Z == 0, ],
caliper_type = 'DAPS', caliper = 1,
coords.columns = c(4, 5),
matching_algorithm = 'greedy')
head(daps)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.