Giter Site home page Giter Site logo

iols_delta's Introduction

iOLS_delta : This repository includes all available STATA programs of iterated Ordinary Least Squares

This repository includes code for iOLS_delta, i2SLS_delta, iOLS_MP as well as iOLS_HDFE and i2SLS_HDFE which allows for high-dimensional fixed effects, as described in Bellego, Benatia and Pape (2021). These programs rely on other programs : you will need to have them installed.

ssc install hdfe

ssc install reghdfe // If an error appears, try downloading the more recent version from http://scorreia.com/software/reghdfe/install.html

ssc install moremata

ssc install ivreg2

ssc install ftools

ssc install ppml

ssc install ppmlhdfe

ssc install ranktest

To install this code into Stata, run the following (requires at least Stata 14) :

cap ado uninstall iOLS_delta

net install iOLS_delta, from("https://raw.githubusercontent.com/ldpape/iOLS_delta/master/")

This installation provides the following estimation programs : iOLS_delta, iOLS_delta_HDFE (iOLS_delta with many fixed effects) , iOLS_MP (Multiplicative Poisson estimated by iOLS), as well as i2SLS_delta, i2SLS_delta_HDFE (i2SLS_delta with many fixed effects), i2SLS_MP (Multiplicative Poisson estimated by iOLS).

These estimation programs are complemented by testing programs : iOLS_delta_test, iOLS_delta_HDFE_test, iOLS_MP_test, i2SLS_delta_test, i2SLS_delta_HDFE_test, i2SLS_MP_test, as well as ppml_test, ppmlhdfe_test, popular_fix_test, and popular_fix_iv_test.

Please feel free to contact me to report a bug or ask a question.

Note, this code is provided as is and may include potential errors. It has been tested for Stata version 16 but has also worked on Stata 14.

iols_delta's People

Contributors

ldpape avatar

Stargazers

Yanggui avatar  avatar

Watchers

 avatar

Forkers

drorsh zjing19

iols_delta's Issues

__000002 not found

Using iOLS_delta_HDFE, I get the following error:
__000002 not found
r(111);

Automatically search for the best hyper-parameter (delta)?

Hi,

Thanks for your work and for sharing this great package.

I would like to use the iOLS_delta_HDFE function in a setting in which the "log of zero" problem arises. I understand I need to specify a value for the hyper-parameter $\delta$ and that the function iOLS_delta_HDFE_test provides a way to select the best $\delta$ given my data.

My understanding is that one should try different $\delta$ values and select the one that maximises the lambda statistics that iOLS_delta_HDFE_test computes (page 23 of your paper). Is this right?

I am currently doing the following. I specify a grid for $\delta$ and loop over each element searching for the value that maximises the lambda statistics. However, this "greedy search" is very expensive and the results obviously depend on the chosen grid. Is there a way to automatically select the best $\delta$?

I provide below a minimal example of my current approach with simulated data.

* Housekeeping
clear   all
eststo  clear
set     seed 123
set     maxvar  32767
set     emptycells drop

* Create (I x T) panel indicators
local   I = 50
local   T = 10
set     obs `I'
gen     i = _n
expand  `T'
bys     i: gen t = _n

* Simulate variables
gen     u = rnormal(0,1) 
gen     x = (runiform() > 0.5)
bys     i (t): gen a_i = rnormal(0,1)
bys     i (t): replace a_i = a_i[1]
gen     y = 1.0 + a_i + 0.5 * x + u
reghdfe y x, abs(i) 

* Introduce zeros
replace y = 0 if y < 0

* Cleaning
keep    i t y x 
order   i t y x 
gsort   i t

* Initialize locals and output
local  deltas 0.1 0.5 1.0 
local  delta_count : word count `deltas'
local  bsrep = 5	
mat    lambdas = J(`delta_count',2,.)

* Loop over values of lambda
local j = 1
foreach d of local deltas {

  * Compute hyper-parameter delta
  bootstrap lambda_stat = e(lambda), reps(`bsrep'): iOLS_delta_HDFE_test y x, delta(`d') absorb(i)
  
  * Store matrix
  matrix lambda = e(b)
  scalar lambda = lambda[1,1]
  mat    lambdas[`j', 1] = `d'
  mat    lambdas[`j', 2] = lambda
  
  * Update counter
  local ++j

} 

* Show matrix of Lambdas
matrix colnames lambdas = delta lambda_stat
matrix list lambdas

/*
	   delta  lambda_stat
r1           .1     1.0192147
r2           .5    1.0208472
r3            1     1.0209707

*/

In this simple example, I would select $\delta = 0.1$. However, I would like to search over a much finer and larger grid. Any help is much appreciated. Thank you.

The convergence process is very slow.

I have nearly 300,000 observations. I use iOLS_delta_HDFE. It seems that the convergence process is very slow. I have not yet obtained an estimate after more than 2000 iterations.

Issue with weights and standard error

Hi,

Thank you so much for the package!

I am trying to run the fixed effects model using the following code:
iOLS_delta_HDFE winsorized_femaleemployment neg* pos* [aweight= MULT] , absorb(year id) vce(cluster state)

But it results in an error that vce is not allowed. If I remove it, then it results in an error that syntax is invalid. The command only runs when I remove the vce as well as the weight option. Is there something wrong with my syntax? I apologize in advance if it's obvious and I am missing something.

Thank you.

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.