dimw: Difference in Means and Difference in Weighted Means

View source: R/functions.R

dimwR Documentation

Difference in Means and Difference in Weighted Means

Description

Calculates the simple difference in means or weighted difference in means between the control or sample population and the treated or target population.

Usage

dimw(X, w, target)

Arguments

X

matrix of data where rows are observations and columns are covariates.

w

numeric vector of weights for each observation.

target

numeric vector of length equal to the total number of units where population/treated units take a value of 1 and sample/control units take a value of 0.

Value

dim

the simple, unweighted difference in means.

dimw

the weighted difference in means.

Examples


#let's say we want to get the unweighted DIM and the weighted DIM using weights from the kbal
#function with the lalonde data:
#load and clean data a bit
data(lalonde)
xvars=c("age","black","educ","hisp","married","re74","re75","nodegr","u74","u75")

#get the kbal weights
kbalout= kbal(allx=lalonde[,xvars],
               sampledinpop=FALSE,
               treatment=lalonde$nsw)
 #now use dimw to get the DIMs
 dimw(X = lalonde[,xvars], w = kbalout$w, target = lalonde$nsw)

chadhazlett/KBAL documentation built on Jan. 3, 2024, 9:57 p.m.