MyNixOS website logo
Description

Sensitivity of Formula Instrument to Shock Design.

Functions to implement the formula instrument method in Borusyak and Hull (2023) <doi:10.3982/ECTA19367> and examine its sensitivity to the assumed distributional of counterfactual shocks.

formulaiv

The formulaiv package implements a method for assessing the sensitivity of formula instrument estimators to the assumed distribution of the counterfactual shocks. Given a formula instrument and a baseline shock distribution, the method computes the range of estimates consistent with shock distributions in a neighborhood of that baseline. Each bound is the optimal value of a linear-fractional program solved as a linear program via the Charnes–Cooper transform using lpSolve.

Installation

formulaiv can be installed from its GitHub repository via

devtools::install_github("peizansheng/formulaiv")

Load the Package

library(formulaiv)

Main Functions

The generic engine is formulaiv():

formulaiv(y, x, z, f, eps, cons, controls = NULL)

where:

  • y: outcome ($N \times 1$ vector)
  • x: endogenous regressor / treatment ($N \times 1$ vector)
  • z: formula instrument ($N \times 1$ vector)
  • f: counterfactual shock realizations, one scenario per column ($N \times S$ data frame or matrix)
  • eps: size(s) of the sensitivity neighborhood to evaluate (scalar or $M \times 1$ vector)
  • cons: the sensitivity-set (constraint) specification
  • controls: optional controls ($N \times J$ data frame or matrix, or NULL)

The sensitivity set is a neighborhood of either the joint shock distribution or its marginals: There are two supported constraint types:

  • joint constraints: reweight the baseline joint distribution pbar
cons <- list(name = "joint", pbar = pbar)

where pbar is the baseline $S \times 1$ weight vector

  • marginal constraints: bound the implied per-shock marginals. Supply the shock realization matrix g, and the baseline marginals either directly as qbar or via a baseline joint distribution pbar (from which qbar = g %*% pbar):
cons <- list(name = "marginal", g = g, qbar = qbar)   # baseline marginals directly
cons <- list(name = "marginal", g = g, pbar = pbar)   # baseline joint -> qbar = g %*% pbar

where

  • g is the $L \times S$ shock realization matrix (data frame or matrix),
  • qbar is the baseline $L \times 1$ vector of marginal shock probabilities, or
  • pbar is the baseline $S \times 1$ joint weight vector

Which inputs to supply

f (the instrument's recentering matrix) is always required. For a joint neighborhood you also give the baseline weights pbar. For a marginal neighborhood you also give g --- the matrix of shock realizations whose marginals are constrained --- plus the baseline marginals, either directly as qbar or computed from a baseline joint pbar. Note that the instrument is a function of the shocks (f = f(g)), so g generally cannot be recovered from f, which is why a marginal analysis needs it explicitly.

Examples

For a detailed empirical application, see the China application vignette.

Note on numerical conditioning

formulaiv() solves its linear programs with lpSolve, which is sensitive to the scale of the input coefficients. If y, x, z, or f are on a very large scale (for example population- or weight-aggregated sums), lpSolve may report a numerical failure instead of returning a bound. The estimate is invariant to dividing y and x by a common constant, so rescaling both to within a few orders of magnitude of 1 resolves this without changing any bound.

Metadata

Version

0.1.0

License

Unknown

Platforms (79)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    wasip1
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasip1
  • wasm64-wasip1
  • x86_64-cygwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows