get_treatment: Main function to compute untreated group.

Description Usage Arguments Value Examples

View source: R/get_treatment.R

Description

The get_treatment function allows you to get the treated individuals and your controls according to k nearest neighbor method when treatment is a multi-categorical variable. The distance used to get the control group is based on the minimum distance between the propensity score of a specific treated individual and all untreated individuals.

Usage

1
  get_treatment(data, k, group, formula, var_multi)

Arguments

data

The original data frame with the multi-categorical variable and independent variables.

k

The number of nearest neighbors chosen by the user to calculate the distance between treated and untreated.

group

One category of the multi-categorical variable. The parameter group needs to be a numeric value and the categorical variable needs to be in a numerical format.

formula

Formula of the multinomial logit model.

var_multi

The position number of the multi-categorical variable in the data frame.

Value

IDENT

An identification code created to each observation.

distance

The distance between the propensity score of a treated observation and your control observation.

treatment

1 if the observation is treated in the group and 0 otherwise.

Examples

1
2
3
4
5
6
7
8
# In this example, x1 is the multi-categorical treatment variable
# x2 and x3 are variables that determines the treatment.
# Note that x1 is the first column in the data frame, that is, var_multi = 1.
# We are using two nearest neighbor, that is, k = 2.
# We are interested in the group of treatment number one, that is, group=1
#
# dt <- data.frame(x1 =rep(c(1,2,3), 4), x2 = rnorm(12, 0, .5), x3 = rnorm(12, 1, .5))
# get_treatment(data = dt, k = 2, group = 1, formula = x1 ~ x2 + x3, var_multi = 1)

Helson-Gomes/psmMULTI documentation built on Aug. 30, 2020, 10:50 p.m.