groupCF: groupCF

Description Usage Arguments Details Examples

View source: R/groupCF.R

Description

This is a wrapper for grf::causal_forest() which performs a causal forest estimation, pulls out the individual-level effect estimates (tau), and then returns a factor variable containing the quantiles of tau.

Usage

1
groupCF(formula, data, ngroups = 4L, ...)

Arguments

formula

A formula of the form x ~ z | w1 + w2 where x is an endogenous variable in an instrumental variables model, being predicted here. z is one of the instruments, and w1 and w2, etc., are covariates to be used to predict the effect of the instrument.

data

A data.frame.

ngroups

Number of quantiles to split tau into.

...

Additional arguments to be passed to grf::causal_forest().

Details

This function is called by magnifiedIV. You can also run Magnified IV by yourself (with any estimator) by running groupSearch, then adding the resulting group variable as a control in both IV stages and also interacted with the instrument. Or use grf::causal_forest() directly to estimate tau on the individual level, and use that to construct a sample weight.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Get data
data(CPS1985, package = 'AER')

# See how the effect of education on wage varies over all the variables in the data
# and then split the resulting individual coefficient estimates into 10 quantiles
# (note this example probably does not satisfy the theoretical unconfoundedness
# assumption of causal forest; this is just a code example)
edeffect <- groupCF(wage ~ education |
                      experience + age + ethnicity +
                      region + gender + occupation +
                      sector + union + married,
                    data = CPS1985, ngroups = 10)

table(edeffect)

NickCH-K/MagnifiedIV documentation built on Jan. 21, 2020, 11:38 a.m.