Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • IVQREG2: module to estimare structural quantile functions now available in SSC

    Dear All:

    Thanks to Kit Baum, ivqreg2 is now available in SSC.

    This module estimates the structural quantile functions defined by Chernozhukov and Hansen (2008) using the method of Machado and Santos Silva (forthcoming in the Journal of Econometrics). Note that, unlike the command ivqreg written by Do Won Kwak, ivqreg2 does not implement the estimator proposed by Chernozhukov and Hansen (2008). However, under suitable regularity conditions, it estimates the same parameters.

    If no instruments are specified, ivqreg2 estimates the regression quantiles imposing the restriction that quantiles do not cross; see also He (1997).

    Please do let me know if you find any problems with the new module or if you have suggestions to improve it.

    Joao

    References

    Chernozhukov, V. and Hansen, C. (2008). "Instrumental Variable Quantile Regression: A Robust Inference Approach," Journal of Econometrics, 142, 379-398.

    He, X. (1997). "Quantile Curves Without Crossing," The American Statistician, 51, 186-192.

    Machado, J.A.F. and Santos Silva, J.M.C. (2018), Quantiles via Moments, Journal of Econometrics, forthcoming.


    Last edited by Joao Santos Silva; 09 Dec 2018, 06:21.

  • #2
    Dear All,

    With the usual thanks to Kit Baum, an updated version of ivqreg2 is now available in SSC.

    The new version corrects a small error in the computation of the standard errors and allows the estimation of over-identified models. Please update as soon as possible.

    Best regards,

    Joao

    Comment


    • #3
      Originally posted by Joao Santos Silva View Post
      Dear All,

      With the usual thanks to Kit Baum, an updated version of ivqreg2 is now available in SSC.

      The new version corrects a small error in the computation of the standard errors and allows the estimation of over-identified models. Please update as soon as possible.

      Best regards,

      Joao
      Dear Professor Joao Santos Silva,
      Thank you for your great contributions to this newly developed command -ivreg2- as the old version seems to have outdated and is now untraceable.
      I am now working on my new paper that would apply this command. In brief, here is my model and data:
      Code:
      ivqreg2 lnwage yedu gender exp exp2 invmshare lnpd, q(0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9) instruments(historic lnproxh lntel_1990 lndoc_1990 lnnagsh_1990)
      where the endogenous variables include invmshare, lnpd and the exogenous instrument variables include historic lnproxh lntel_1990 lndoc_1990 lnnagsh_1990.
      The reported result is an error message:
      "The model is not identified"
      Can you please help check where my mistake is? Thanks in advance.

      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input double(lnwage yedu) byte gender double(exp exp2 invmshare lnpd historic lnproxh lntel_1990 lndoc_1990 lnnagsh_1990)
       3.324236340526027  9 1 27  729  .32517627687936146  7.995956897523879 1 6.7262650091510645 1.2809338454620642 3.5263605246161616  -.13219493978987207
      2.1892564076870427  9 0 17  289   .8025157176153104  6.149578790201674 0  6.815876031747156 1.4586150226995167 2.5649493574615367   -.7050562528953167
       2.655781772556453  9 1 31  961  .38566248081198473  6.759011621494086 1   7.08738139606511  1.308332819650179 3.6109179126442243     -.23594074471283
      3.1675825304806504 15 0 12  144   .4555486082761511  6.708779812473747 1  7.133085538688554 2.2512917986064953  3.871201010907891  -.19544390949330062
      2.9311937524164198  9 1 35 1225   .5144990291322996                  . 1  6.887252391871955 1.8870696490323797 3.8066624897703196 -.045155050956508264
      2.9311937524164198  9 1 12  144    .689952289663426  6.675419609299012 0  6.989862456852736  1.308332819650179 2.5649493574615367  -1.4587548277717903
      2.5414770012763945  9 1 44 1936  .18850060787067013  7.080161170988715 1 7.1473992188549476   1.33500106673234  3.091042453358316   -.3335127185183903
      2.5665506388285104 12 0 14  196    .345735003900398  7.322906656679722 0  6.830454880803419 2.0541237336955462  3.044522437723423  -.12313570579439227
      3.1088749296538722 15 1 14  196  .38566248081198473  6.759011621494086 1   7.08738139606511  1.308332819650179 3.6109179126442243     -.23594074471283
      2.6798793241355137  9 1 33 1089   .4555486082761511  6.708779812473747 1  7.133085538688554 2.2512917986064953  3.871201010907891  -.19544390949330062
      2.1892564076870427  9 0 46 2116   .3057102749711722  6.840172127658341 0  7.089661145029285  .7884573603642703 3.8066624897703196   -.4106866999218388
      2.9639835752394106 16 1  8   64   1.058430499035278   7.48305879704793 0  7.021703204172785 3.3463891451671604 3.8501476017100584  -.12770781461975386
      3.3932292120129786  9 1 30  900   .7080577932956994   6.59695468773738 1  6.842033081579257 1.8082887711792655 2.8903717578961645  -.18081569437410366
      2.5257286443082556 12 1 15  225   .3974969384589877  6.587797917978567 1  7.324650841156412  .6151856390902335  3.295836866004329   -.7252909700740661
      2.2762677846766723  0 0 42 1764   .8025157176153104  6.149578790201674 0  6.815876031747156 1.4586150226995167 2.5649493574615367   -.7050562528953167
       2.469639177657212 12 0  9   81    .689952289663426  6.675419609299012 0  6.989862456852736  1.308332819650179 2.5649493574615367  -1.4587548277717903
      2.4405708359679483  9 1 19  361  .38566248081198473  6.759011621494086 1   7.08738139606511  1.308332819650179 3.6109179126442243     -.23594074471283
      1.9661128563728327  6 1 45 2025  .23471018768567525  6.444989393959706 0 7.2427787181853365 1.4350845252893227 3.6635616461296463   -.3025508035365015
       3.912023005428146 16 1 11  121   .3539643352457612  7.675230407499353 1  7.180304207988398  1.410986973710262 3.1780538303479458  -.49813128227802816
      2.9311937524164198  9 0 15  225   .8677386912919894 7.1244057960996825 1  6.952333689356577 1.7749523509116738  3.091042453358316   -.4448688572515106
       1.742969305058623  9 1 42 1764   .3974969384589877  6.587797917978567 1  7.324650841156412  .6151856390902335  3.295836866004329   -.7252909700740661
      2.1892564076870427  9 1 39 1521    .706435074886881  6.996782123551787 1 6.8193404882551585 1.9740810260220096 3.2188758248682006  -.19889903788576135
       3.036554268074246  9 1 44 1936   .7080577932956994   6.59695468773738 1  6.842033081579257 1.8082887711792655 2.8903717578961645  -.18081569437410366
      2.7488721956224653  6 1 44 1936   .8025157176153104  6.149578790201674 0  6.815876031747156 1.4586150226995167 2.5649493574615367   -.7050562528953167
       4.086376392572924  9 1 30  900  .18850060787067013  7.080161170988715 1 7.1473992188549476   1.33500106673234  3.091042453358316   -.3335127185183903
      1.9661128563728327 12 1 45 2025  .11260894438265427 6.2884903308128965 1  7.597226772186708                  . 3.6375861597263857    -.145746147064981
       2.882403588246988  6 1 44 1936   .2789205667832083  6.899067650584572 1  6.780405458519309   1.62924053973028 3.4339872044851463  -.18028232504109246
      2.6741486494265287  9 1 17  289    .396753167506143  7.143783465725341 1  6.890230314536831  1.547562508716013 2.1972245773362196  -.33956054293375065
       3.036554268074246 16 1 16  256  .08784809057319518  7.533014334740589 0  7.037304423651433   1.62924053973028 3.6888794541139363  -.20956889897878234
      3.4420193761824107 15 1 10  100    .345735003900398  7.322906656679722 0  6.830454880803419 2.0541237336955462  3.044522437723423  -.12313570579439227
      1.6784307839210517 12 1 32 1024    .799619425070462  6.848344919650529 1  6.896614192117666 1.7227665977411035   2.70805020110221   -.6800980855424956
       2.407945608651872  6 0 26  676   .2296647683044753  7.708478020175458 0   6.74877579212934 1.5260563034950492  2.995732273553991  -.31601375503272133
      2.2762677846766723 12 1 35 1225   .2296647683044753  7.708478020175458 0   6.74877579212934 1.5260563034950492  2.995732273553991  -.31601375503272133
      2.2845665874913674  9 1 54 2916  .11260894438265427 6.2884903308128965 1  7.597226772186708                  . 3.6375861597263857    -.145746147064981
       2.371577964480997  9 1 23  529   .3539643352457612  7.675230407499353 1  7.180304207988398  1.410986973710262 3.1780538303479458  -.49813128227802816
      2.9311937524164198 16 0  7   49  .05604139088362485  6.424885231229478 1 7.0499856903592075  .9162907318741551  2.833213344056216  -.27566672142579557
      1.6094379124341003  9 1 24  576  .15782408519356717  7.379625914286913 0  7.010294000650422   1.62924053973028 3.4339872044851463  -.34066120531242067
      2.7668907011251433 12 1 18  324   .5144990291322996                  . 1  6.887252391871955 1.8870696490323797 3.8066624897703196 -.045155050956508264
       2.882403588246988  9 1 19  361 .051503842867115616  6.593332164005878 0  7.125398959105349 1.0296194171811581 2.6390573296152584   -.3645356499223359
       2.594721515795207 12 1 25  625   .3974969384589877  6.587797917978567 1  7.324650841156412  .6151856390902335  3.295836866004329   -.7252909700740661
      2.6798793241355137 15 1 20  400    .345735003900398  7.322906656679722 0  6.830454880803419 2.0541237336955462  3.044522437723423  -.12313570579439227
      2.7488721956224653  9 0 16  256  .32517627687936146  7.995956897523879 1 6.7262650091510645 1.2809338454620642 3.5263605246161616  -.13219493978987207
      2.3434070875143007  9 0 11  121  .44941699563734716  6.932808802046243 0  6.818152287326264 1.8562979903656263 2.8903717578961645  -.23741229361094357
      3.2188758248682006  9 1 12  144   .3974969384589877  6.587797917978567 1  7.324650841156412  .6151856390902335  3.295836866004329   -.7252909700740661
      2.8542327112802917  9 1 13  169   .4555486082761511  6.708779812473747 1  7.133085538688554 2.2512917986064953  3.871201010907891  -.19544390949330062
      1.9661128563728327  6 1 17  289  .16570045577771866  6.879911205752139 0  6.734831617974049 1.1939224684724346  3.295836866004329  -.22075235375719274
      2.4203681286504293 16 0 12  144  .05604139088362485  6.424885231229478 1 7.0499856903592075  .9162907318741551  2.833213344056216  -.27566672142579557
      2.2380465718564744  9 0 35 1225  .18850060787067013  7.080161170988715 1 7.1473992188549476   1.33500106673234  3.091042453358316   -.3335127185183903
      2.1892564076870427 12 0 16  256  .17554457251493083  7.135790844856772 1  7.287919755032479   1.62924053973028 3.4011973816621555   -.2291153344696842
      2.9565115604007097  9 1 33 1089  .15782408519356717  7.379625914286913 0  7.010294000650422   1.62924053973028 3.4339872044851463  -.34066120531242067
      2.2155737160044158 12 0 38 1444  .17363935641112077  6.600196976525564 0   6.84243615545031 2.0149030205422647 2.4849066497880004  -.43627651214287977
       4.135166556742356 15 1 18  324   .4555486082761511  6.708779812473747 1  7.133085538688554 2.2512917986064953  3.871201010907891  -.19544390949330062
      2.7488721956224653 12 1 28  784   .2819651121225519  4.706552800276694 0   7.21598102083621 1.1314021114911006  3.912023005428146   -.6192459696369965
      2.8134107167600364  6 0 39 1521   .5144990291322996                  . 1  6.887252391871955 1.8870696490323797 3.8066624897703196 -.045155050956508264
       2.302585092994046  9 0 33 1089  .11462552584130327  7.073218868709308 0  7.045980898437062  .9162907318741551 3.4011973816621555  -.18529035933037333
       3.302257433807252 12 0 14  196  .18850060787067013  7.080161170988715 1 7.1473992188549476   1.33500106673234  3.091042453358316   -.3335127185183903
      1.9661128563728327  9 1 25  625   .4555486082761511  6.708779812473747 1  7.133085538688554 2.2512917986064953  3.871201010907891  -.19544390949330062
      2.5257286443082556  9 0 19  361  .33855440282553756 7.0076549111202695 0  6.953755425229315 1.3862943611198906 3.5263605246161616  -.43715846756687055
      2.5257286443082556 12 0 27  729  .20825493882045895  6.091626574006963 0  7.161458091143661 1.0986122886681098  3.367295829986474   -.3925488833352015
       2.882403588246988  9 1 13  169  .27680807589990264   7.14137179682892 0 6.9427171454693655  .9932517730102835 1.9459101490553132   -.9770814129464149
      2.6798793241355137 12 0 14  196  .05604139088362485  6.424885231229478 1 7.0499856903592075  .9162907318741551  2.833213344056216  -.27566672142579557
      2.8622008809294686 16 0  9   81   .7080577932956994   6.59695468773738 1  6.842033081579257 1.8082887711792655 2.8903717578961645  -.18081569437410366
      2.7488721956224653  6 1 47 2209   .8025157176153104  6.149578790201674 0  6.815876031747156 1.4586150226995167 2.5649493574615367   -.7050562528953167
       2.882403588246988 12 1 25  625   .3808212771954044  4.392224459650327 0  7.154061644975804                  .                  .                    .
      2.8534160513737357  6 0 34 1156   .5144990291322996                  . 1  6.887252391871955 1.8870696490323797 3.8066624897703196 -.045155050956508264
      1.4961092271270973  9 0 32 1024  .32517627687936146  7.995956897523879 1 6.7262650091510645 1.2809338454620642 3.5263605246161616  -.13219493978987207
       2.371577964480997  9 0 31  961   .8677386912919894 7.1244057960996825 1  6.952333689356577 1.7749523509116738  3.091042453358316   -.4448688572515106
      2.5257286443082556  9 0 27  729  .31951679597179955  7.421195481755599 1  6.770880323208592 1.4586150226995167  3.044522437723423  -.17811890352562726
       2.180888158016526  9 0 26  676  .17363935641112077  6.813906031496319 0  7.486795341853597 1.4586150226995167  3.044522437723423  -.22542976395788966
       2.882403588246988  6 0 45 2025   .5144990291322996                  . 1  6.887252391871955 1.8870696490323797 3.8066624897703196 -.045155050956508264
      3.2188758248682006  9 1 29  841   .2296647683044753  7.708478020175458 0   6.74877579212934 1.5260563034950492  2.995732273553991  -.31601375503272133
      3.0853444322436783 12 1 46 2116   .5144990291322996                  . 1  6.887252391871955 1.8870696490323797 3.8066624897703196 -.045155050956508264
      3.2188758248682006  9 1 30  900   .5144990291322996                  . 1  6.887252391871955 1.8870696490323797 3.8066624897703196 -.045155050956508264
       2.371577964480997  6 1 41 1681   .2296647683044753  7.708478020175458 0   6.74877579212934 1.5260563034950492  2.995732273553991  -.31601375503272133
      2.2112353144058177  9 1 34 1156    .345735003900398  7.322906656679722 0  6.830454880803419 2.0541237336955462  3.044522437723423  -.12313570579439227
      2.8134107167600364 12 1 24  576   .4555486082761511  6.708779812473747 1  7.133085538688554 2.2512917986064953  3.871201010907891  -.19544390949330062
      2.5257286443082556 12 0 20  400  .08784809057319518  7.533014334740589 0  7.037304423651433   1.62924053973028 3.6888794541139363  -.20956889897878234
      3.8632328412587142 15 0 13  169  .38566248081198473  6.759011621494086 1   7.08738139606511  1.308332819650179 3.6109179126442243     -.23594074471283
      3.1543373037306295 15 1  6   36  .38566248081198473  6.759011621494086 1   7.08738139606511  1.308332819650179 3.6109179126442243     -.23594074471283
       2.631089159966082 12 0 11  121  .05604139088362485  6.424885231229478 1 7.0499856903592075  .9162907318741551  2.833213344056216  -.27566672142579557
      2.8134107167600364  9 1 30  900  .11260894438265427 6.2884903308128965 1  7.597226772186708                  . 3.6375861597263857    -.145746147064981
      3.2188758248682006  9 1 23  529   .4555486082761511  6.708779812473747 1  7.133085538688554 2.2512917986064953  3.871201010907891  -.19544390949330062
       3.036554268074246  9 1 45 2025  .17363935641112077  6.813906031496319 0  7.486795341853597 1.4586150226995167  3.044522437723423  -.22542976395788966
      2.5902671654458267  9 0 11  121   .9662691016803967  6.471805189861254 0   7.04443182615418 2.9444389791664403 3.1780538303479458  -.43435052629864795
       .3566749439387324  9 1 47 2209  .05604139088362485  6.424885231229478 1 7.0499856903592075  .9162907318741551  2.833213344056216  -.27566672142579557
       2.643511679964639  9 0 17  289   .3974969384589877  6.587797917978567 1  7.324650841156412  .6151856390902335  3.295836866004329   -.7252909700740661
      3.2008573193655225  0 1 45 2025  .27680807589990264   7.14137179682892 0 6.9427171454693655  .9932517730102835 1.9459101490553132   -.9770814129464149
      2.1892564076870427  6 0 39 1521  .27680807589990264   7.14137179682892 0 6.9427171454693655  .9932517730102835 1.9459101490553132   -.9770814129464149
      1.9343641580582525  9 0 36 1296  .05604139088362485  6.424885231229478 1 7.0499856903592075  .9162907318741551  2.833213344056216  -.27566672142579557
      3.9810158769150976  9 1 32 1024   .5144990291322996                  . 1  6.887252391871955 1.8870696490323797 3.8066624897703196 -.045155050956508264
       2.371577964480997  6 1 28  784  .27680807589990264   7.14137179682892 0 6.9427171454693655  .9932517730102835 1.9459101490553132   -.9770814129464149
       3.036554268074246 12 0 15  225   .5144990291322996                  . 1  6.887252391871955 1.8870696490323797 3.8066624897703196 -.045155050956508264
       2.631089159966082 15 0  7   49   .2296647683044753  7.708478020175458 0   6.74877579212934 1.5260563034950492  2.995732273553991  -.31601375503272133
      2.7488721956224653 12 1 13  169  .20825493882045895  6.091626574006963 0  7.161458091143661 1.0986122886681098  3.367295829986474   -.3925488833352015
       2.594721515795207  9 1 17  289  .08784809057319518  7.533014334740589 0  7.037304423651433   1.62924053973028 3.6888794541139363  -.20956889897878234
       2.302585092994046  9 0 10  100   .3974969384589877  6.587797917978567 1  7.324650841156412  .6151856390902335  3.295836866004329   -.7252909700740661
      3.5553480614894135 12 1 27  729   .1983289949397715  5.584623492819887 0  7.607528308086076  1.252762968495368 3.8066624897703196   -.3518453296096878
       4.605170185988092  9 0 36 1296  .17363935641112077  6.813906031496319 0  7.486795341853597 1.4586150226995167  3.044522437723423  -.22542976395788966
       3.036554268074246  9 0 32 1024   .5144990291322996                  . 1  6.887252391871955 1.8870696490323797 3.8066624897703196 -.045155050956508264
       2.371577964480997 12 0  8   64  .27680807589990264   7.14137179682892 0 6.9427171454693655  .9932517730102835 1.9459101490553132   -.9770814129464149
      end
      label values gender LABB
      label def LABB 1 "男", modify
      Last edited by Liu Qiang; 17 May 2019, 02:43.
      2B or not 2B, that's a question!

      Comment


      • #4
        Dear Liu Qiang

        Please note that the list of instruments should include all the exogenous variables (so these appear twice in the command) and therefore the number of instruments needs to be at least equal to the number of explanatory variables.

        Best wishes,

        Joao

        Comment


        • #5
          Originally posted by Joao Santos Silva View Post
          Dear Liu Qiang

          Please note that the list of instruments should include all the exogenous variables (so these appear twice in the command) and therefore the number of instruments needs to be at least equal to the number of explanatory variables.

          Best wishes,

          Joao
          Thank you for your timely and kind reminder. It works now.
          2B or not 2B, that's a question!

          Comment


          • #6
            Dear Prof. João Santos Silva, please may I ask you two questions? I installed your command IVQRE2 and am trying to run the examples from the Stata help, but I keep getting the message: "option residuals not allowed".
            The second question is: how do I use clustered standard errors? I need to cluster by municipality. Thank you very much. Kind regards, Juliana

            Comment


            • #7
              Dear juliana pinto,

              The error you are getting is because your Stata is not updated. In the paper we did not consider clustered standard errors, so those are not implemented in the command, but you can use bootstrap by clusters.

              Best wishes,

              Joao

              Comment


              • #8
                Dear Prof. João Santos Silva, I am also using ivqreg2 to estimate the effects. As my endogenous variable is a binary variable, I have added another step to estimate the effects of a binary endogenous variable. My code is below:

                probit X Z1 Z2 x1 x2,robust
                predict x_hat,p
                ivqreg2 Y X x1 x2, q(0.2 0.4 0.6 0.8) instruments(Z1 Z2 x1 x2 x_hat )

                where Y is the dependent variable, X is a binary endogenous variable, Z1Z2 is the instruments, x1 x2 is the covariates.

                Do you think it can get the unbiased causal effects of a binary treatment variable? Also, how can I get the Wald statistic ( p-value) in the ivqreg2 package? And can the ivqreg2 include factor-variables? Thank you!

                Comment


                • #9
                  Dear Lumeng Liu,

                  The method you are using is fine. The p-value of the Wald statistics (t-tests) are reported by default; it that what you are asking about? To use factor variables, you need the xi prefix.

                  Best wishes,

                  Joao

                  Comment


                  • #10
                    Thank you, Prof. João Santos Silva. You are very helpful.

                    I have another question to consult you. When ivqreg2 works, does it first do an OLS regression for X and Z(and covariates) and then do quantile regression for Y and the predicted value of X (and covariates)? Or does it first calculate the predicted values of X for some quantiles of Y and then regress Y by the predicted values of X? For example, when we have a continuous variable Y, there are two ways to analyze the different effects influenced by different levels of Y. The first is to use IV quantile regression, and the second is to separate the continuous variable Y into several categories based on different quantiles and then for each category, repeat IV regression. Will the results be the same for the two methods?

                    Thank you very much!

                    Comment


                    • #11
                      Dear Lumeng Liu,

                      The estimator implemented in ivqreg2 is not as you describe because none of the methods you describe would lead to a valid estimator. For details on the method, please see

                      Machado, J.A.F. and Santos Silva, J.M.C. (2019), Quantiles via Moments, Journal of Econometrics, 213(1), pp. 145–173.

                      Best wishes,

                      Joao

                      Comment


                      • #12
                        Thank you, Prof. João Santos Silva. I will read it carefully.

                        Best wishes,

                        Lumeng

                        Comment


                        • #13
                          Dear All,

                          With the usual thanks to Kit Baum, an updated version of ivqreg2 is now available in SSC.

                          The new version adds a couple of new options and uses better starting values; please update as soon as possible.

                          Best regards,

                          Joao

                          Comment


                          • #14
                            Dear professor Joao,

                            I am using ivqreg2 for my thesis and I find a problem when running the command. This is my syntax:

                            ivqreg2 Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 , inst(Z x2 x3 x4 x5 x6 x7 x8 x9 x10) q(.05 .95)

                            I am instrumenting the variable x1n by mean of the variable Z and I have also included in the instrument brackets all the other explanatory variables of my model. The problem I face is that after 2 hours Stata does not report any result to me , it is still loading... Is this normal?

                            Thank you in advance.

                            Best regards,

                            Nerea.

                            Comment


                            • #15
                              Dear Nerea Gomez,

                              I am not sure if I understand what you mean when you say "it is still loading", but try to use the different options on the command, especially mu (and make sure you have the updated version); changing the scale of the dependent variable may also help.

                              Best wishes,

                              Joao

                              Comment

                              Working...
                              X