GithubHelp home page GithubHelp logo

beniaminogreen / cragg Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 1.0 1016 KB

Test for weak IV instruments in R.

License: GNU General Public License v3.0

R 100.00%
weak-instruments ivreg2 iv regression instrumental-variable r

cragg's Introduction

  • Hi, I'm Beniamino (Ben) Green
  • I'm a predoctoral fellow at the Yale School of Public Heath
  • I am interested in computational social science, record linkage, and semiparametric statistics

Please checkout my blog here!

cragg's People

Contributors

beniaminogreen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

allisterh

cragg's Issues

Error in stock_yogo_reccomender

Hi,
I am having trouble running a toy example. How can I fix this problem?

> library(cragg)
> library(AER) # for dataaset
> data("WeakInstrument")
> stock_yogo_test(
+     # control variables
+     X = ~ 1, 
+     # endogeneous variables
+     D = ~ x, 
+     # instrument variables 
+     Z = ~ z, 
+     data = WeakInstrument
+ )
Error in stock_yogo_reccomender(K = cd$K2, N = cd$N, B, size_bias) : 
  Error: K must be greater than N+1 for this operation

Error: cannot allocate vector of size 741.2 Gb

Hello,
I ran into the error above when trying to implement the Stock-Yogo test using your cragg package. I'm working with a data set of about 1.4 million observations, 28 IVs, and one endogenous variable (I'm assuming that for size distortion results it's ok to have one endogenous variable but let me know if this is a problem for the package). The offending code is below:

stock_yogo_test(
  ~factor(region) + factor(yob) + Race + SMSA + Married + Age + Age2,  #Controls
  ~educ,            #Treatments
  ~factor(birthqtr):factor(yob),   #Instruments
  B=.1,       #Maximum Allowable Size Distortion
  size_bias="size", #Calculate critical value for size distortions
  data = df
)

I'm happy to provide the data. They are the Angrist and Krueger "quarter of birth-returns to education" data, which I'm using to create a problem set. Thanks in advance.

intercept handling

I have issues with the functions in the package when an intercept is included explicitly and when the model should not contain an intercept.

The following code models the intercept explicitly but throws an error. The reason is that it leads to two intercept columns in X_m that are of course perfectly collinear.

df <- iris
df$CONS <- 1
cragg_donald(X=~CONS+Sepal.Length, D=~Sepal.Width, Z=~Petal.Length + Petal.Width + Species, data = df)

Similarly, the code internally always adds an intercept column to X_m but some models might not have an intercept.

It would be good to simply have a consistent handling of an intercept. It is possibly easiest if users need to specify an intercept explicitly by creating a variable and add it to the ~X formula. Alternatively, a function argument could ask the user whether an intercept should be added or not.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.