Announcement

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

  • r(2000) error in Newey-West

    Dear all,

    I have monthly data on stock market and when I tried to use Newey-West standard errors to deal with heteroskedasticity and autocorrelation, Stata says that there is no observation. Below is my -dataex- :
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int date float(csad r_mt abs_r_mt)
    15341         .          .         .
    15372  10.40015 -21.771555 21.771555
    15400 3.6831214  1.3696393 1.3696393
    15431   5.40642   6.454342  6.454342
    15461  4.572629 -1.0483736 1.0483736
    15492  3.924419 -12.194602 12.194602
    15522 4.0851216  15.245831 15.245831
    15553  4.421038   3.213805  3.213805
    15584  1.545293  -.3501535  .3501535
    15614 2.0632555 -4.6421685 4.6421685
    15645  3.666877  -14.84067  14.84067
    15675 4.5075574 -4.4080067 4.4080067
    15706 1.8428906 -2.1559913 2.1559913
    15737   2.49485  11.278244 11.278244
    15765 2.1604996 -1.2514616 1.2514616
    15796 4.3232718  -1.257523  1.257523
    15826 10.606026   3.962764  3.962764
    15857  5.112213   6.413789  6.413789
    15887  4.484928  -4.856054  4.856054
    15918  6.263611   6.968433  6.968433
    15949 2.9614744   -.802722   .802722
    15979  3.076989  -.8465761  .8465761
    16010 10.489506   19.19976  19.19976
    16040 3.4005265 -1.0016072 1.0016072
    16071  8.629517  -.3082933  .3082933
    16102  4.420031   7.663479  7.663479
    16131   7.91593  1.8529012 1.8529012
    16162  4.938119     1.0648    1.0648
    16192   4.95072 -14.607905 14.607905
    16223 3.8892744  3.9174936 3.9174936
    16253  5.702363  -5.584903  5.584903
    16284  7.320863  -5.576176  5.576176
    16315  6.825109 -10.216467 10.216467
    16345  3.911943  10.581155 10.581155
    16376  8.563342  -8.825836  8.825836
    16406 4.0248747    7.06366   7.06366
    16437  6.767444  -8.656428  8.656428
    16468  9.667854   5.605936  5.605936
    16496 4.4664264   9.692858  9.692858
    16527 12.659364   2.459548  2.459548
    16557   11.2451   -4.35966   4.35966
    16588  7.937766  -11.16009  11.16009
    16618  5.769467  -4.593168  4.593168
    16649  8.396846   2.259447  2.259447
    16680  9.871736  2.2887776 2.2887776
    16710  6.986581  -.5051034  .5051034
    16741  7.922635 -16.813925 16.813925
    16771  3.609957   2.732373  2.732373
    16802  5.349097   .7332054  .7332054
    16833  7.527323   23.25859  23.25859
    16861  6.718209  3.0368414 3.0368414
    16892  7.630779    4.88974   4.88974
    16922 10.340603   5.886937  5.886937
    16953  9.688768   8.262988  8.262988
    16983  5.447178 -2.6733925 2.6733925
    17014  6.039441  -5.767948  5.767948
    17045  5.145508  2.8006885 2.8006885
    17075   14.2246  10.567738 10.567738
    17106  9.340332   5.390509  5.390509
    17136  8.937711  10.640285 10.640285
    17167  12.09225  13.240386 13.240386
    17198  13.75918  4.6114182 4.6114182
    17226  7.096007   7.630084  7.630084
    17257  7.987866   7.694463  7.694463
    17287 11.686085  16.659527 16.659527
    17318 10.900064   4.312224  4.312224
    17348  17.43714  2.0001624 2.0001624
    17379  7.945005  13.660383 13.660383
    17410  8.063833 -1.5955248 1.5955248
    17440  5.245726  3.9520586 3.9520586
    17471  8.522331   .4120224  .4120224
    17501  5.714562  -10.72098  10.72098
    17532   5.00455   .7190944  .7190944
    17563  7.142439  -10.26564  10.26564
    17592  6.609317 -1.1376902 1.1376902
    17623   11.2239  -16.59991  16.59991
    17653  8.833878   6.459142  6.459142
    17684  6.001316  -4.918726  4.918726
    17714  8.055031 -15.197256 15.197256
    17745  8.108354  -2.220311  2.220311
    17776  8.099585 -18.786123 18.786123
    17806  10.02093  -19.74054  19.74054
    17837  13.65648  -32.34998  32.34998
    17867  8.914493   14.30076  14.30076
    17898   6.74604   4.287829  4.287829
    17929  5.719338   4.822899  4.822899
    17957  6.543387   6.488205  6.488205
    17988  5.720366  15.008144 15.008144
    18018  6.967344    3.38667   3.38667
    18049  7.954954   19.29539  19.29539
    18079  6.887875  12.942645 12.942645
    18110  6.234223  10.758305 10.758305
    18141  5.344579  -17.07722  17.07722
    18171 4.5722775   6.080737  6.080737
    18202  5.578828   8.842843  8.842843
    18232  9.408226   12.99844  12.99844
    18263 4.6079955  .06648097 .06648097
    18294  5.668927   -7.62164   7.62164
    18322  3.139144   4.595733  4.595733
    18353 4.2208114   4.677813  4.677813
    end
    format %tm date
    Here are the problematic results:
    Code:
    . tsset date, monthly
            time variable:  date, 3238m6 to 3512m5, but with gaps
                    delta:  1 month
    
    . newey csad c.abs_r_mt##c.abs_r_mt, lag(1) force
    no observations
    r(2000);
    
    .
    Why is there 'no observations'? Below is my 'normal' regression.
    Code:
    .  reg csad c.abs_r_mt##c.abs_r_mt
    
          Source |       SS           df       MS      Number of obs   =       108
    -------------+----------------------------------   F(2, 105)       =      6.12
           Model |  93.9271731         2  46.9635866   Prob > F        =    0.0031
        Residual |   805.43128       105  7.67077409   R-squared       =    0.1044
    -------------+----------------------------------   Adj R-squared   =    0.0874
           Total |  899.358453       107  8.40521918   Root MSE        =    2.7696
    
    ------------------------------------------------------------------------------
            csad |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        abs_r_mt |    .043472   .1171705     0.37   0.711    -.1888554    .2757994
                 |
      c.abs_r_mt#|
      c.abs_r_mt |   .0046852   .0049204     0.95   0.343    -.0050709    .0144414
                 |
           _cons |   6.077043   .5529866    10.99   0.000     4.980573    7.173513
    ------------------------------------------------------------------------------
    Last edited by sladmin; 09 Apr 2018, 08:56. Reason: anonymize poster

  • #2
    You do not understand how Stata datetime variables work.

    Here are the first five dates in your data, with two different formats.
    Code:
    . format %tm date
    
    . list date in 1/5
    
         +---------+
         |    date |
         |---------|
      1. |  3238m6 |
      2. |  3241m1 |
      3. |  3243m5 |
      4. | 3245m12 |
      5. |  3248m6 |
         +---------+
    
    . format %td date
    
    . list date in 1/5
    
         +-----------+
         |      date |
         |-----------|
      1. | 01jan2002 |
      2. | 01feb2002 |
      3. | 01mar2002 |
      4. | 01apr2002 |
      5. | 01may2002 |
         +-----------+
    You have Stata daily dates, and you attempted to make them monthly dates by changing the format. That is not correct, as a simple inspection shows.

    You will want to follow the instructions for using your Stata Internal Format (SIF) daily date variable to create a new SIF monthly date variable following the guidance in help datetime, which is without a doubt the most visited documentation on my system, with the second-most-visited being Chapter 24 (Working with dates and times) of the Stata User's Guide PDF available from the PDF Documentation item on Stata's Help menu. Before working with dates and times, any Stata user should read the very detailed Chapter 24 thoroughly. After that, the help datetime documentation will usually be enough to point the way. Some people may be able to remember everything without have to continually refer to the documentation, but I for one am not such a person

    Comment


    • #3
      Same points made within https://www.statalist.org/forums/for...tions-on-r-198

      Please try to run just one thread at any time when the issues are so similar. .

      Comment

      Working...
      X