This package provides tools to easily identify the identifying variation in a regression, specifically in applied economics analyses.
This package is built as part of a research project. As such, the associated paper provides a detailed scientific description of its content and of its underpinnings.
Installation
You can install the development version of ididvar from GitHub with:
# install.packages("devtools")
devtools::install_github("vincentbagilet/ididvar")Usage
Most of the functions of the package take as input the output of a regression and the name of the variable of interest. ididvar supports a breadth of estimation packages (lm, plm, fixest for instance).
First, the package provides a straightforward function to compute identifying variation weights.
library(ididvar)
library(ggplot2)
reg_ex_fixest <- ggplot2::txhousing |>
dplyr::mutate(l_sales = log(sales)) |>
fixest::feols(fml = l_sales ~ median + listings | year + city, vcov = "twoway")
idid_weights(reg_ex_fixest, "median") |>
head()
#> [1] 1.417497e-05 5.163932e-05 5.908480e-05 1.918702e-06 7.089139e-08
#> [6] 7.372159e-09The package also allows for an effortless exploration of these weights through visualizations.
idid_viz_weights(reg_ex_fixest, "median", year, city, order = "y") +
ggplot2::labs(x = NULL, y = NULL) 
In this particular (somehow silly) regression, most of the identifying variation comes from a few cities: Houston, Dallas, Austin and San Antonio.
idid_viz_cumul(reg_ex_fixest, "median")
It also provide functions to identify observations that actually contribute to identification (in the sense that dropping the other observations does not significantly affect the estimate obtained).
idid_viz_contrib(reg_ex_fixest, "median", var_y = city, order = "y") +
ggplot2::labs(y = NULL)
#> Warning: The VCOV matrix is not positive semi-definite and was 'fixed' (see
#> ?vcov).
#> Warning: The VCOV matrix is not positive semi-definite and was 'fixed' (see
#> ?vcov).
#> Warning: The VCOV matrix is not positive semi-definite and was 'fixed' (see
#> ?vcov).
#> Warning: The VCOV matrix is not positive semi-definite and was 'fixed' (see
#> ?vcov).
#> Warning: The VCOV matrix is not positive semi-definite and was 'fixed' (see
#> ?vcov).
#> Warning: The VCOV matrix is not positive semi-definite and was 'fixed' (see
#> ?vcov).
The package provides a larger set of functions. The Get started vignette introduces them in a concise manner, while also describing a typical workflow for analysis.
Online appendices of the associated paper complements this vignette by providing an example of a practical implementation of an analysis using the ididvar package.