MyNixOS website logo
Description

Tests for Weak Instruments in R.

Implements Cragg-Donald (1993) <doi:10.1017/S0266466600007519> and Stock and Yogo (2005) <doi:10.1017/CBO9780511614491.006> tests for weak instruments in R.

Cragg

An R package to implement the Cragg-Donald test for weak instruments.

BuildStatus Codecov License: GPLv3

Overview

The Cragg-Donald (1993) test is a common way to test for weak instruments in an IV regression but has never been implemented in R. The cragg package provides an implementation of the Cragg-Donald test in R and provides access to the critical values for the Cragg-Donald statistic developed in Stock and Yogo (Stock 2005). These tests quantify the degree to which weak instruments can undermine regression estimates for models with multiple endogenous variables / treatments.

Main Features

  • Calculates Cragg-Donald statistics for weak instruments.

  • Recommends critical values for the Cragg-Donald Statistic based on the largest allowable bias relative to regular OLS or the maximum allowable size distortion of the Wald test statistic.

Installation

#install.packages("devtools")
devtools::install_github("beniaminogreen/cragg")

Usage

The cragg package has two main functions cragg_donald(), and stock_yogo_test().

cragg_donald() implements the Cragg-Donald test for weak instruments in R. It can be thought of as the matrix-equivalent of the first-stage F-test for weak instruments, and is used to evaluate models with multiple endogenous variables. This function has been tested against the results from STATA’s ivreg2 package (Baum, Mark, Stillman 2002) to ensure accuracy.

The syntax is show below:

library(cragg)
#Cragg-Donald Test
cragg_donald(
    ~X1+X2+X3,  #Controls
    ~D1 + D2,           #Treatments
    ~Z1 + Z2 + Z3,  #Instruments
    data =example_data
)
#> Cragg-Donald test for weak instruments:
#> 
#>      Data:                        example_data 
#>      Controls:                    ~X1 + X2 + X3 
#>      Treatments:                  ~D1 + D2 
#>      Instruments:                 ~Z1 + Z2 + Z3 
#> 
#>      Cragg-Donald Statistic:        186.1346 
#>      Df:                                 993

stock_yogo_test() implements the Stock and Yogo test for weak instruments. The test developed by Stock and Yogo (2005) is a decision rule meant to ensure that weak instruments do not pose a problem. Stock and Yogo suggest two methods to select the critical values: one based on maximum allowable bias relative to normal OLS and another based on the maximum size of a Wald test on all of the instruments. Both of these decision rules are implemented.

stock_yogo_test(
    ~X1+X2+X3,  #Controls
    ~D1,            #Treatments
    ~Z1 + Z2,   #Instruments
    B=.1,       #Maximum Allowable Size Distortion
    size_bias="size", #Calculate critical value for size distortions
    data =example_data
)
#> Results of Stock and Yogo test for weak instruments:
#> 
#>      Null Hypothesis:             Instruments are weak 
#>      Alternative Hypothesis:      Instruments are not weak 
#> 
#>      Data:                        example_data 
#>      Controls:                    ~X1 + X2 + X3 
#>      Treatments:                  ~D1 
#>      Instruments:                 ~Z1 + Z2 
#> 
#>      Alpha:                             0.05 
#>      Acceptable level of bias:    10% Wald test distortion.
#>      Critical Value:                   19.93 
#> 
#>      Cragg-Donald Statistic:        360.5978 
#>      Df:                                 994

References

Baum, Christopher F, Mark E Schaffer, and Steven Stillman. 2002. “<span class="nocase">IVREG2: Stata module for extended instrumental variables/2SLS and GMM estimation.” Statistical Software Components, Boston College Department of Economics.

Cragg, John G., and Stephen G. Donald. 1993. “Testing Identifiability and Specification in Instrumental Variable Models.” Econometric Theory 9 (2): 222–40. https://doi.org/10.1017/s0266466600007519.

Stock, James H., and Motohiro Yogo. 2005. “Testing for Weak Instruments in Linear IV Regression.” In Identification and Inference for Econometric Models, 80–108. Cambridge University Press. https://doi.org/10.1017/cbo9780511614491.006.

Metadata

Version

0.0.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • 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-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
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • 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-windows