Announcement

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

  • Nonlinear Regression Help

    Hello everyone

    I am trying to estimate the following nonlinear regression:



    The methodology I am following is from the paper - Fearing the Fed: How Wall Street Reads Main Street (Law, Song and Yaron, 2018).

    The method is a 2 stage process whereby:

    1. We run an OLS regression to obtain initial guesses of the beta which is used in step 2.
    2. Use the initial guess of beta from (1), create dummy variables (tau = 2007, 2008, 2009...) for each year in the sample and run the above nonlinear regression to get estimates of beta and gamma at the same time.

    I have done the OLS regression as per (1), collected the betas (which have been merged to my sample) and created the year dummies accordingly.

    Below is a snapshot of my dataset, after step (1).

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(date yr) long category float(category_id obs returns) double betahat1 byte(ndeltas1 ndeltas2 ndeltas3 ndeltas4 ndeltas5 ndeltas6 ndeltas7 ndeltas8 ndeltas9 ndeltas10)
    17174 2007  3  8   1   .0022178572   -.004849219792766927 1 0 0 0 0 0 0 0 0 0
    17176 2007  3  8   2   .0019384718   -.004849219792766927 1 0 0 0 0 0 0 0 0 0
    17197 2007  7 11   3    .006571246  .00045136446260455167 1 0 0 0 0 0 0 0 0 0
    17205 2007  1 10   4   -.001179963 -.00025042105928707055 1 0 0 0 0 0 0 0 0 0
    17218 2007  8 12   5   -.001405438  -.0013411201504753187 1 0 0 0 0 0 0 0 0 0
    17258 2007 11  1   6    .002593697  -.0044835308651445145 1 0 0 0 0 0 0 0 0 0
    17266 2007  8 12   7    .002613226  -.0013411201504753187 1 0 0 0 0 0 0 0 0 0
    17267 2007  7 11   8   -.006594525  .00045136446260455167 1 0 0 0 0 0 0 0 0 0
    17283 2007  8 12   9 -.00012050498  -.0013411201504753187 1 0 0 0 0 0 0 0 0 0
    17321 2007  7 11  10      .0018469  .00045136446260455167 1 0 0 0 0 0 0 0 0 0
    17357 2007 11  1  11   -.014287025  -.0044835308651445145 1 0 0 0 0 0 0 0 0 0
    17359 2007  8 12  12    .018875707  -.0013411201504753187 1 0 0 0 0 0 0 0 0 0
    17378 2007 11  1  13   -.012727293  -.0044835308651445145 1 0 0 0 0 0 0 0 0 0
    17379 2007  3  8  14    .007216567   -.004849219792766927 1 0 0 0 0 0 0 0 0 0
    17386 2007  3  8  15    .013973753   -.004849219792766927 1 0 0 0 0 0 0 0 0 0
    17387 2007  2  7  16    -.03009807  -.0023360666977677354 1 0 0 0 0 0 0 0 0 0
    17388 2007  5  2  17   .0003784657   .0020586545571350894 1 0 0 0 0 0 0 0 0 0
    17395 2007  5  2  18    .024269566   .0020586545571350894 1 0 0 0 0 0 0 0 0 0
    17401 2007 11  1  19  -.0010728918  -.0044835308651445145 1 0 0 0 0 0 0 0 0 0
    17415 2007  1 10  20   .0042428724 -.00025042105928707055 1 0 0 0 0 0 0 0 0 0
    17423 2007  2  7  21  .00020217562  -.0023360666977677354 1 0 0 0 0 0 0 0 0 0
    17427 2007  5  2  22     .02878958   .0020586545571350894 1 0 0 0 0 0 0 0 0 0
    17433 2007  7 11  23   -.005270308  .00045136446260455167 1 0 0 0 0 0 0 0 0 0
    17455 2007  8 12  24   -.006594867  -.0013411201504753187 1 0 0 0 0 0 0 0 0 0
    17456 2007  7 11  25   .0017598468  .00045136446260455167 1 0 0 0 0 0 0 0 0 0
    17471 2007  5  2  26    -.02677889   .0020586545571350894 1 0 0 0 0 0 0 0 0 0
    17482 2007 11  1  27   -.010038452  -.0044835308651445145 1 0 0 0 0 0 0 0 0 0
    17485 2007  6  3  28    -.01330049   -.002895970351761133 1 0 0 0 0 0 0 0 0 0
    17506 2007  6  3  29    .014924972   -.002895970351761133 1 0 0 0 0 0 0 0 0 0
    17512 2007  5  2  30    .006031879   .0020586545571350894 1 0 0 0 0 0 0 0 0 0
    17518 2007  5  2  31     .00626016   .0020586545571350894 1 0 0 0 0 0 0 0 0 0
    17527 2007  1 10  32   -.014317544 -.00025042105928707055 1 0 0 0 0 0 0 0 0 0
    17541 2008  2  7  33    .007916712  -.0023360666977677354 0 1 0 0 0 0 0 0 0 0
    17542 2008 11  1  34    -.01368865  -.0044835308651445145 0 1 0 0 0 0 0 0 0 0
    17575 2008  6  3  35    .013512358   -.002895970351761133 0 1 0 0 0 0 0 0 0 0
    17584 2008  2  7  36     .00784972  -.0023360666977677354 0 1 0 0 0 0 0 0 0 0
    17615 2008 11  1  37    .015205243  -.0044835308651445145 0 1 0 0 0 0 0 0 0 0
    17624 2008  3  8  38   -.001935943   -.004849219792766927 0 1 0 0 0 0 0 0 0 0
    17660 2008  2  7  39    .003662835  -.0023360666977677354 0 1 0 0 0 0 0 0 0 0
    17688 2008  2  7  40    .019308535  -.0023360666977677354 0 1 0 0 0 0 0 0 0 0
    17737 2008  3  8  41    -.02339599   -.004849219792766927 0 1 0 0 0 0 0 0 0 0
    17743 2008  6  3  42    .016534539   -.002895970351761133 0 1 0 0 0 0 0 0 0 0
    17752 2008  3  8  43     .02361187   -.004849219792766927 0 1 0 0 0 0 0 0 0 0
    17790 2008 11  1  44    -.04828298  -.0044835308651445145 0 1 0 0 0 0 0 0 0 0
    17791 2008  5  2  45    .017363276   .0020586545571350894 0 1 0 0 0 0 0 0 0 0
    17792 2008 11  1  46    -.04827978  -.0044835308651445145 0 1 0 0 0 0 0 0 0 0
    17793 2008  1 10  47     .04242881 -.00025042105928707055 0 1 0 0 0 0 0 0 0 0
    17794 2008  9  4  48      .0394594   .0030085467092649462 0 1 0 0 0 0 0 0 0 0
    17797 2008  5  2  49    -.03897883   .0020586545571350894 0 1 0 0 0 0 0 0 0 0
    17804 2008  2  7  50     -.0920024  -.0023360666977677354 0 1 0 0 0 0 0 0 0 0
    17808 2008  6  3  51   -.013598566   -.002895970351761133 0 1 0 0 0 0 0 0 0 0
    17811 2008  2  7  52    -.03927927  -.0023360666977677354 0 1 0 0 0 0 0 0 0 0
    17812 2008  2  7  53    -.05910779  -.0023360666977677354 0 1 0 0 0 0 0 0 0 0
    17813 2008  1 10  54   -.011397407 -.00025042105928707055 0 1 0 0 0 0 0 0 0 0
    17814 2008  8 12  55    -.07922406  -.0013411201504753187 0 1 0 0 0 0 0 0 0 0
    17818 2008  2  7  56     .10957197  -.0023360666977677354 0 1 0 0 0 0 0 0 0 0
    17819 2008  9  4  57    -.00533635   .0030085467092649462 0 1 0 0 0 0 0 0 0 0
    17821 2008  2  7  58     .04162882  -.0023360666977677354 0 1 0 0 0 0 0 0 0 0
    17828 2008  7 11  59    .012554898  .00045136446260455167 0 1 0 0 0 0 0 0 0 0
    17829 2008  8 12  60   -.035120778  -.0013411201504753187 0 1 0 0 0 0 0 0 0 0
    17832 2008  7 11  61    -.03227979  .00045136446260455167 0 1 0 0 0 0 0 0 0 0
    17833 2008  2  7  62     .10244671  -.0023360666977677354 0 1 0 0 0 0 0 0 0 0
    17834 2008  7 11  63   -.011130264  .00045136446260455167 0 1 0 0 0 0 0 0 0 0
    17842 2008  1 10  64    -.05157121 -.00025042105928707055 0 1 0 0 0 0 0 0 0 0
    17846 2008  5  2  65   -.012733896   .0020586545571350894 0 1 0 0 0 0 0 0 0 0
    17855 2008  2  7  66   -.063105494  -.0023360666977677354 0 1 0 0 0 0 0 0 0 0
    17856 2008  1 10  67    -.06948184 -.00025042105928707055 0 1 0 0 0 0 0 0 0 0
    17857 2008  7 11  68       .061328  .00045136446260455167 0 1 0 0 0 0 0 0 0 0
    17862 2008  5  2  69      .0347184   .0020586545571350894 0 1 0 0 0 0 0 0 0 0
    17869 2008 11  1  70     .02550805  -.0044835308651445145 0 1 0 0 0 0 0 0 0 0
    17883 2008  8 12  71    -.00963917  -.0013411201504753187 0 1 0 0 0 0 0 0 0 0
    17885 2008  6  3  72    .002932592   -.002895970351761133 0 1 0 0 0 0 0 0 0 0
    17890 2008  5  2  73    .005764497   .0020586545571350894 0 1 0 0 0 0 0 0 0 0
    17896 2008  9  4  74     .02411402   .0030085467092649462 0 1 0 0 0 0 0 0 0 0
    17902 2009  3  8  75   -.004679288   -.004849219792766927 0 0 1 0 0 0 0 0 0 0
    17904 2009  3  8  76    -.03046912   -.004849219792766927 0 0 1 0 0 0 0 0 0 0
    17905 2009  2  7  77    .003391316  -.0023360666977677354 0 0 1 0 0 0 0 0 0 0
    17906 2009  8 12  78   -.021533214  -.0013411201504753187 0 0 1 0 0 0 0 0 0 0
    17909 2009  6  3  79   -.022822587   -.002895970351761133 0 0 1 0 0 0 0 0 0 0
    17911 2009  2  7  80   -.034032464  -.0023360666977677354 0 0 1 0 0 0 0 0 0 0
    17912 2009  1 10  81    .001328299 -.00025042105928707055 0 0 1 0 0 0 0 0 0 0
    17913 2009  9  4  82    .007533132   .0030085467092649462 0 0 1 0 0 0 0 0 0 0
    17917 2009  3  8  83    -.05426202   -.004849219792766927 0 0 1 0 0 0 0 0 0 0
    17927 2009  7 11  84    -.02305282  .00045136446260455167 0 0 1 0 0 0 0 0 0 0
    17931 2009  5  2  85    .015709938   .0020586545571350894 0 0 1 0 0 0 0 0 0 0
    17933 2009  2  7  86    .016233189  -.0023360666977677354 0 0 1 0 0 0 0 0 0 0
    17934 2009  5  2  87     .02654068   .0020586545571350894 0 0 1 0 0 0 0 0 0 0
    17938 2009  5  2  88    -.05036867   .0020586545571350894 0 0 1 0 0 0 0 0 0 0
    17941 2009  6  3  89   -.010048009   -.002895970351761133 0 0 1 0 0 0 0 0 0 0
    17945 2009  6  3  90     -.0466295   -.002895970351761133 0 0 1 0 0 0 0 0 0 0
    17946 2009  6  3  91  -.0009508175   -.002895970351761133 0 0 1 0 0 0 0 0 0 0
    17948 2009  2  7  92   -.011478593  -.0023360666977677354 0 0 1 0 0 0 0 0 0 0
    17952 2009  5  2  93     .03932005   .0020586545571350894 0 0 1 0 0 0 0 0 0 0
    17955 2009  9  4  94   -.023846485   .0030085467092649462 0 0 1 0 0 0 0 0 0 0
    17958 2009  9  4  95    -.04774189   .0030085467092649462 0 0 1 0 0 0 0 0 0 0
    17969 2009  5  2  96    .007709235   .0020586545571350894 0 0 1 0 0 0 0 0 0 0
    17974 2009  5  2  97     .02064339   .0020586545571350894 0 0 1 0 0 0 0 0 0 0
    17975 2009  9  4  98   -.013064128   .0030085467092649462 0 0 1 0 0 0 0 0 0 0
    17979 2009  9  4  99    .068366386   .0030085467092649462 0 0 1 0 0 0 0 0 0 0
    17986 2009  2  7 100   -.035439324  -.0023360666977677354 0 0 1 0 0 0 0 0 0 0
    end
    format %-td date
    label values category c
    label def c 1 "ECB", modify
    label def c 2 "EU Macro News", modify
    label def c 3 "EU Political News", modify
    label def c 5 "FED", modify
    label def c 6 "FED GOV", modify
    label def c 7 "IMF", modify
    label def c 8 "Other Regions Macro News", modify
    label def c 9 "Treasury", modify
    label def c 11 "US Subprime, SEC & Others", modify
    I'm struggling with the creating a suitable expression in Stata to run the nonlinear regression.

    Would really appreciate if someone could provide some advice on the above.

    Thank you in advance.

    Regards
    Parvesh
    Last edited by Parvesh Seeballack; 10 Jul 2018, 04:01.

  • #2
    You didn't get a quick answer. You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, provide readable output, and sample data using dataex. We also don't do well with pictures or files. It would also help if you shorten your posting to the essentials necessary to demonstrate the problem. Recognize also that we are not from your research area so you need to explain stuff rather than saying " the above nonlinear regression to get estimates of beta and gamma at the same time."

    You are asking us to volunteer our time to help you. It is not reasonable to expect us to read a paper (sometimes we do if it seems of interest, but often not) - you need to invest sufficient of your time to clearly explain what you need.

    You want to specify a non-linear model. So tell us what the model looks like. Provide us with whatever you have done so far. nl is the standard non-linear least squares estimator in Stata.

    Comment

    Working...
    X