bate

bias adjusted treatment effect

https://github.com/dbasu-umass/bate

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 4 DOI reference(s) in README
  • Academic publication links
  • Committers with academic emails
    3 of 3 committers (100.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.9%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

bias adjusted treatment effect

Basic Info
  • Host: GitHub
  • Owner: dbasu-umass
  • License: other
  • Language: R
  • Default Branch: main
  • Size: 597 KB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 4 years ago · Last pushed about 3 years ago
Metadata Files
Readme License

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# Bias-Adjusted Treatment Effect (bate)




The goal of the `bate` package is to present some functions to conduct sensitivity analysis of omitted variable bias in linear econometric models. The functions in this package present functions to implement two approaches: (a) the partial R-squared approach of Cinelli and Hazlett (2020); and (b) the $\delta$-$R_{max}$ approach of Oster (2019) implemented with an algorithm proposed in Basu (2022).

## Cinelli and Hazlett (2020) Approach

The Cinelli and Hazlett (2020) approach is implemented by the `cinhaz` function. To use this function, the user chooses the following parameters:

* kd: this parameter measures the relative strength of the confounder in explaining variation in treatment as compared to benchmark covariate(s), e.g. kd=1
* ky: this parameter measures the relative strength of the confounder in explaining variation in the outcome as compared to benchmark covariate(s), e.g. kd=1
* data: this is the data frame for the regression
* outcome: the name of the outcome variable
* treatment: the name of the treatment variable
* bnch_reg: name(s) of covariates to be used for benchmarking
* other_reg: other covariates in the model (i.e. other than treatment and benchmark covariates)
* alpha: significance level for the test of the null hypothesis that the true effect is zero, e.g. alpha=0.05

### Example

Here is an example:

```{r}
library(sensemakr)

bate::cinhaz(
  kd=1, ky=1, data=darfur,outcome = "peacefactor",
  treatment = "directlyharmed", bnch_reg = "female",
  other_reg = c("village","age","farmer_dar","herder_dar","pastvoted","hhsize_darfur"),
  alpha = 0.05
)

```

## Oster (2019) Approach
In implementing the $\delta$-$R_{max}$ approach of Oster (2019), the `bate` package presents some functions to compute quantiles of the empirical distribution of the bias-adjusted treatment effect (BATE). 

### Four Regressions
To analyze such models, a researcher should consider four regression models: (a) a short regression model where the outcome variable is regressed on the treatment variable, with or without additional controls; (b) an intermediate regression model where additional control variables are added to the short regression; (c) a _hypothetical_ long regression model, where an index of the omitted variable(s) is added to the intermediate regressions; and (d) an auxiliary regression where the treatment variable is regressed on all observed (and included) control variables. 

As an example, suppose a researcher has estimated the following model, $$y = \alpha + \beta_1 x + \gamma_1 w_1 + \gamma_2 w_2 + \varepsilon$$, and is interested in understanding the impact of some omitted variables on the results. In this case:

* outcome variable: $y$
* treatment variable: $x$
* short regression: $y$ regressed on $x$;
* intermediate regression: $y$ regressed on $x, w_1, w_2$;
* auxiliary regression: $x$ regressed on $w_1, w_2$;
* hypothetical long regression: $y$ regressed on $x, w_1,w_2$ and the omitted variables;

The treatment effect is $\beta_1$, but in the presence of omitted variables, this will be estimated with a bias. The functions in this package will allow a researcher to create quantiles of the empirical distribution of the BATE, i.e. the treatment effect once we have adjusted for the effect of omitted variable bias.

The researcher will need to supply the data set (as a data frame), the name of the outcome variable, the name of the treatment variable, and the names of the additional regressors in the intermediate regression. The functions in this package will then compute the quantiles of the empirical distribution of BATE.

### Two Important Parameters
Two parameters capture the effect of the omitted variables in this set up. 

The first parameter is $\delta$. This captures the relative strength of the unobservables, compared to the observable controls, in explaining variation in the _treatement variable_. In the functions below this is denoted as the parameter `delta`.  This parameter is a real number and can take any value on the real line, i.e. it is unbounded. Hence, in any specific analysis, the researcher will have to choose a lower and an upper bound for `delta`. For instance, if in any empirical analysis, the researcher believes, based on knowledge of the specific problem being investigated, that the unobservables are _less_ important than the observed controls in explaining the variation in the _treatment variable_, then she could choose `delta` to lie between 0 and 1. On the other hand, if she believes that the unobservables are _more_ important than the observed controls in explaining the variation in the _treatment variable_, then she should choose `delta` to lie between 1 and 2 or 1 and 5.

The second parameter is $R_{max}$. This captures the relative strength of the unobservables, compared to the observable controls, in explaining variation in the _outcome variable_. In the functions below, this is captured by the parameter `Rmax`. The parameter `Rmax` is the R-squared in the hypothetical long regression. Hence, it lies between the R-squared in the intermediate regression ($\tilde{R}$) and 1. Since the lower bound of `Rmax` is given by $\tilde{R}$, in any specific analysis, the researcher will only have to choose an upper bound for `Rmax`.

In a specific empirical analysis, a researcher will use domain knowledge about the specific issue under investigation to determine a plausible range for `delta` (e.g. $0.01 \leq \delta \leq 0.99$). This will be given by the interval on the real line lying between `deltalow` and `deltahigh` (the researcher will choose `deltalow` and `deltahigh`). Using the example in this paragraph, `deltalow=0.01` and `deltahigh=0.99`.

In a similar manner, a researcher will use domain knowledge about the specific issue under investigation to determine `Rmax`. Here, it will be important to keep in mind that `Rmax` is the R-squared in the hypothetical long regression. Now, it is unlikely that including all omitted variables and thereby estimating the hypothetical long regression will give an R-squared of 1. This is because, even after all the regressors have been included, some variation of the outcome might be plausibly explained by a stochastic element. Hence, `Rmax` will most likely be different from, and less than, 1. This will be denoted by `Rhigh` (e.g. `Rmax=0.61`).

### The Algorithm Proposed by Basu (2022)
How is the omitted variable bias and the BATE computed? The key result that is used to compute the BATE is this: the omitted variable bias is the real root of a _cubic equation_ whose coefficients are functions of the parameters of the short, intermediate and auxiliary regressions and the values of `delta` and `Rmax`. In a specific empirical analysis, the parameters of the short, intermediate and auxiliary regressions are known. Hence, the coefficients of the cubic equation become functions of `delta` and `Rmax`, the two key parameters that the researcher chooses, using domain knowledge.

Once the researchers has chosen `deltalow`, `deltahigh` and `Rhigh`, this defines a bounded box on the (`delta`, `Rmax`) plane defined by the Cartesian product of the interval [`deltalow`, `deltahigh`] and of the interval [`Rlow`, `Rhigh`]. The main functions in this package computes the root of the cubic equation on a sufficiently granular grid (the degree of granularity will be chosen by the user) covering the bounded box.  

To compute the root of the cubic equation, the algorithm first evaluates the discriminant of the cubic equation on each point of the grid and partitions the box into two regions: (a) unique real root (URR) and NURR (no unique real root). There are three cases to consider.

* **Case 1:** If all points of the bounded box are in URR, then the algorithm chooses the unique real root of the cubic at each point as the estimate of the omitted variable bias. 
* **Case 2:** If some non-empty part of the box is in NURR, then the algorithm first computes roots on the URR region, and then, starting from the boundary points of URR/NURR, covers points on the NURR in small steps. At each step, the algorithm chooses the real root at a grid point in the NURR that is closest in absolute value to the real root at a previously selected grid point. Continuity of the roots of a polynomial with respect to its coefficients guarantees that the algorithm selects the correct real root at each point. 
* **Case 3:** If the bounded box is completely contained in NURR, then the algorithm extends the size of the box in small steps in the `delta` direction to generate a nonempty intersection with a URR region. Once that is found, the algorithm implements the steps outlined in step 2. 

The bias is then used to compute the BATE, which is defined as the estimated treatment effect in the intermediate regression _minus_ the bias. This will generate an empirical distribution of the BATE. Asymptotic theory shows that the BATE converges in probability to the true treatment effect. Hence, the interval defined by the 2.5-th and 97.5-th quantiles of the empirical distribution of the BATE will contain the true treatment effect with 95 percent probability.


### The functions
An useful function to collect relevant parameters from the short, intermediate and auxiliary regressions is:

* `collect_par()`: collects parameters from the short, intermediate and auxiliary regressions; (user provides name of the data set, name of outcome variable, name of treatment variable, names of control variables in the short regression, if relevant, and names of additional variables in the intermediate regression); the output of this function is a data frame.

Users can use the output from `collect_par()` to construct an area plot of the bounded box using:

* `urrplot()`: creates a colored area plot of the bounded box chosen by the user demarcating the area where the cubic equation has unique real root (URR) from the area where the cubic equation has three real roots (NURR); the output is a plot object.

The main functions in this package that are available for users to compute empirical distributions of omitted variable bias and BATE are:

* `ovbias()`: computes the empirical distribution of omitted variable bias and BATE (takes the output from `collect_par()` as one of the inputs); the output of this function is a list;
* `ovbias_par()`: computes the empirical distribution of omitted variable bias and BATE (takes the data frame, name of outcome variable, name of treatment variable, names of control variables in the short regression, if relevant, and names of additional variables in the intermediate regression, as inputs); the output of this function is a list;
* `ovbias_lm()`: computes the empirical distribution of omitted variable bias and BATE (takes three `lm` objects corresponding to the short, intermediate and auxiliary regressions as inputs); the output of this function is a list.

Using the output from `ovbias()`, `ovbias_par()` or `ovbias_lm()`, users can construct various plots:

* `cplotbias()`: contour plot of the bias over the bounded box; the output of this function is a plot object;
* `dplotbate()`: histogram and density plot of BATE; the output of this function is a plot object;

The methodology proposed in Oster (2019) is implemented via these functions:

* `osterbds()`: identified sets according to Oster's methodology; the output of this function is a data frame;
* `osterdelstar()`: the value of $\delta^*$ for a chosen value of $R_{max}$; the output of this function is a data frame;
* `delfplot()`: a plot of the graph of the function, $\delta=f(R_{max})$; the output of this function is a plot object.

### Installation

You can install the development version of bate from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("dbasu-umass/bate")
```

## Example: Impact of Maternal Behavior on Child IQ

### Setting Up
Let us load the data set.
```{r}
data("NLSY_IQ")
```
The data set has two `.RData` objects: `NLSY_IQ` (to be used for the analysis of maternal behavior on child IQ) and `NLSY_BW` (to be used for the analysis of maternal behavior on child birthweight). 

Let us see the names of the variables in the `NLSY_IQ` data set.
```{r}
names(NLSY_IQ)
```
Let us set `age` and `race` as factor variables
```{r}
NLSY_IQ$age <- factor(NLSY_IQ$age)
NLSY_IQ$race <- factor(NLSY_IQ$race)
```

### Using ovbias()
Let us work with the following example:

* short regression: `iq_std ~ BF_months + sex + age`
* intermediate regression: `iq_std ~ BF_months + sex + age + income + motherAge + motherEDU + mom_married + race`.

Let us use the `collect_par()` function to collect parameters from the short, intermediate and auxiliary regressions. Note how `other_parameters` is a subset of `control`. The researcher needs to make sure that `control` includes the names of _all_ regressors in the intermediate regression, other than the treatment variable.
```{r}
parameters <- bate::collect_par(data=NLSY_IQ,
            outcome="iq_std",
            treatment="BF_months",
            control=c("age","sex","income","motherAge","motherEDU","mom_married","race"),
            other_regressors = c("sex","age"))
```
Let us see the parameters.
```{r}
(parameters)
```
Let us choose the dimensions of the bounded box over which we want the bias computation to be carried out.
```{r}
# Upper bound of Rmax
Rhigh <- 0.61
# Lower bound of delta
deltalow <- 0.01
# Upper bound of delta
deltahigh <- 0.99
# step size to construct grid
e <- 0.01
```
Now we can use the `ovbias()` function to compute the empirical distribution of omitted variable bias and BATE. Note that this step make take a few minutes, depending on the dimensions of the box and the size of `e`, to complete itself.
```{r, results='hide', message=FALSE}
OVB <- bate::ovbias(
  parameters = parameters,
  deltalow=deltalow, 
  deltahigh=deltahigh,
  Rhigh=Rhigh, 
  e=e)
```
We can now see the quantiles of omitted variable bias 
```{r}
(OVB$bias_Distribution)
```
and quantiles of the BATE (computed over the bounded box we chose above).
```{r}
(OVB$bstar_Distribution)
```
We can create the histogram and density plot of the omitted variable bias.
```{r, out.width="75%"}
bate::dplotbate(OVB$Data)
```

We can also create a contour plot of BATE over the bounded box.
```{r, out.width="75%"}
bate::cplotbias(OVB$Data)
```


## References

* Basu, D. (2022). "Bounds for Bias-Adjusted Treatment Effect in Linear Econometric Models." 

* Cinelli, C. and Hazlett, C. (2020). Making Sense of Sensitivity: Extending Omitted Variable Bias. _Journal of the Royal Statistical Society Series B: Statistical Methodology_, 82(1):39–67. 

* Oster, E. (2019). "Unobservable Selection and Coefficient Stability: Theory and Evidence." _Journal of Business & Economic Statistics_, 37:2, 187-204, 

Owner

  • Login: dbasu-umass
  • Kind: user

GitHub Events

Total
Last Year

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 58
  • Total Committers: 3
  • Avg Commits per committer: 19.333
  • Development Distribution Score (DDS): 0.121
Past Year
  • Commits: 2
  • Committers: 1
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Deepankar Basu d****u@u****u 51
Evan Wasner e****r@u****u 6
dbasu-umass 8****s 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 12 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 332 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 1
  • Total maintainers: 1
cran.r-project.org: bate

Computes Bias-Adjusted Treatment Effect

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 332 Last month
Rankings
Forks count: 28.8%
Dependent packages count: 29.8%
Stargazers count: 35.2%
Dependent repos count: 35.5%
Average: 37.3%
Downloads: 57.3%
Maintainers (1)
Last synced: 12 months ago

Dependencies

DESCRIPTION cran
  • concaveman * imports
  • dplyr * imports
  • ggplot2 * imports
  • latex2exp * imports
  • magrittr * imports
  • purrr * imports
  • stats * imports
  • tidyselect * imports
  • vtable * imports
  • knitr * suggests
  • rmarkdown * suggests