| Title: | Tests for Weak Instruments in R |
| Version: | 0.0.1 |
| Description: | Implements Cragg-Donald (1993) <doi:10.1017/S0266466600007519> and Stock and Yogo (2005) <doi:10.1017/CBO9780511614491.006> tests for weak instruments in R. |
| License: | GPL (≥ 3) |
| Encoding: | UTF-8 |
| LazyData: | true |
| RoxygenNote: | 7.1.1 |
| Imports: | expm (≥ 0.999) |
| Suggests: | testthat (≥ 3.0.0), knitr, MASS, rmarkdown |
| Config/testthat/edition: | 3 |
| Depends: | R (≥ 2.10) |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2021-01-05 20:31:53 UTC; beniamino |
| Author: | Beniamino Green [aut, cre] |
| Maintainer: | Beniamino Green <ben@greendalba.com> |
| Repository: | CRAN |
| Date/Publication: | 2021-01-08 08:40:03 UTC |
Calculate the Cragg-Donald statistic for a given model.
Description
Calculate the Cragg-Donald statistic for a given model.
Usage
cragg_donald(X, D, Z, data = data.frame())Arguments
X | (formula). A one-sided formula of control variables. |
D | (formula). A one-sided formula of endogenous variables (treatments) |
Z | (formula). A one-sided formula of instruments |
data | (dataframe). An optional dataframe, list, or environmentcontaining the variables used in the model. As with many of the base Rfunctions, if the variables are not found here, they may be searched for inthe environment cragg_donald() was called. |
Value
(cd_test) results object of class "cd_test"
Examples
#Obtain the Cragg-Donald statistic for a model that instruments#Sepal Width on Petal Length, Petal Width, and Species, while controlling#for Sepal.Length (a toy example).cragg_donald(X=~Sepal.Length, D=~Sepal.Width,Z=~Petal.Length + Petal.Width + Species, data = iris)Recommend a critical value for the Cragg-Donald test given a maximum allowable bias/size distortion
Description
Recommend a critical value for the Cragg-Donald test given a maximum allowable bias/size distortion
Usage
stock_yogo_reccomender(K, N, B, size_bias)Arguments
K | (int). The number of instruments. |
N | (int). The number of endogenous variables (treatments) |
B | One of [.05, .1, .15, .2, .25, .3]. The maximum size of allowable bias relativeto the normal OLS or the maximum Wald test size distortion. |
size_bias | Either "bias" or "size". Whether to use a criticalvalue based on the maximum allowable bias relative to regular OLS (bias), or maximumWald test size distortion. |
Value
(float) the recommended critical value.
Examples
#To reccomend a critical value for a test with 2 endogenous variables#and four instruments based on a 5% maximum allowable bias relative to OLSstock_yogo_reccomender(4,2,.05,"bias")Perform the Stock and Yogo test for weak instruments
Description
Perform the Stock and Yogo test for weak instruments
Usage
stock_yogo_test(X, D, Z, data, B = 0.05, size_bias = "bias")Arguments
X | (formula). A one-sided formula of control variables. |
D | (formula). A one-sided formula of endogenous variables (treatments) |
Z | (formula). A one-sided formula of instruments |
data | (dataframe). An optional dataframe, list, or environmentcontaining the variables used in the model. As with many of the base Rfunctions, if the variables are not found here, they may be searched for inthe environment cragg_donald() was called. |
B | One of [.05, .1, .15, .2, .25, .3]. The maximum size of allowable bias relative |
size_bias | Either "bias" or "size". Whether to use a criticalvalue based on the maximum allowable bias relative to regular OLS (bias), or maximumWald test size distortion (size). |
Value
(sy_test) the results of the stock and yogo test.
Examples
#Perform the Stock and Yogo test on a model that instruments#Sepal Width on Petal Length, Petal Width, and Species, while controlling#for Sepal.Length (a toy example).stock_yogo_test(X=~Sepal.Length, D=~Sepal.Width,Z=~Petal.Length + Petal.Width + Species,size_bias="bias",data = iris)