CalcDAPSWeightBalance: DAPSm with extensive search for optimal w.

Description Usage Arguments Value Examples

View source: R/Weight_balance_functions.R

Description

Calculates the balance of covariates as a function of weight when fitting DAPS for multiple values of w.

Usage

1
2
3
4
5
CalcDAPSWeightBalance(dataset, weights, cov.cols, trt.col = NULL,
  out.col = NULL, coords.columns, caliper, caliper_type = c("DAPS",
  "PS"), coord_dist = FALSE, distance = StandDist,
  matching_algorithm = c("optimal", "greedy"),
  remove.unmatchables = FALSE)

Arguments

dataset

Data frame including treatment, outcome, coordinates, propensity score estimates (named prop.scores) and observed confounders.

weights

The weights on which we want to fit DAPS. Vector.

cov.cols

The indices of the columns we want to balance.

trt.col

The index of the binary treatment column. If treatment is named 'X' this can be NULL.

out.col

Can be NULL if the outcome column is named 'Y'. Otherwise, it should the index of the outcome column.

coords.columns

If the columns of coordinates are not named 'Longitude' and 'Latitude', coords.columns are the column indices corresponding to longitude and latitude accordingly.

caliper

The value of the caliper that will be used.

caliper_type

Whether we want the caliper to be on DAPS or on the PS. caliper_type must be either '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.

distance

Function that takes in the distance matrix and returns the standardized distance matrix. Defaults to the funcion that subtracks the minimum and divides by the range.

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.

Value

A list including: a 3-dimensional array. Dimensions correspond to weights, before/after matching and covariates. Balance can be plotted using PlotWeightBalance function. A list of the pairs for the different weights.

Examples

1
2
3
4
5
6
7
data(toyData)
toyData$prop.scores <- glm(Z ~ X1 + X2 + X3 + X4, family = binomial,
                           data = toyData)$fitted.values
bal <- CalcDAPSWeightBalance(toyData, weights = seq(0, 1, length.out = 30),
                             cov.cols = 6:9, trt.col = 1,
                             coords.columns = c(4, 5), caliper = 0.1,
                             matching_algorithm = 'greedy')

gpapadog/DAPSm documentation built on May 17, 2019, 8 a.m.