Announcement

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

  • STATA has been running for a week

    gen b = .
    gen z = .
    gen p = .
    forvalue i=1(1)478 {
    tempname M
    capture noisily arch ut rmrf smb hml umd if id==`i', archm arch(1) garch(1) archmex(sqrt(X)) distribution(t)
    if _rc==0 {
    matrix `M'= r(table)
    replace b=`M'[1,6] if id==`i'
    replace z=`M'[3,6] if id==`i'
    replace p=`M'[4,6] if id==`i'
    }
    }
    I use this code to de GARCH-M regression and save the coefficients as well as z-statistics/ p-value of conditional variance. I use daily data across 23 years. Plus, the observations for each portfolio (id) are different.

    The STATA has been running for almost 6 days and nights. Is it normal?

    Many thanks.

  • #2
    These models seem to have a reputation as often very difficult to fit. I have never used any myself. I naturally can't comment on what the problems are in your case, e.g. too few data, too complicated a model, unsuitable model.

    Beyond the obvious, you have at least two problems:

    1. Nothing in your code shows how much progress you have made. You could still be on the first series or you could be on the last. For projects like this a line within the loop

    Code:
    di `i' 
    would be a record of progress.

    2. You are not using any maximize options e.g. to bail out if 10000 iterations don't converge.

    You need specific advice from someone who uses these models routinely. These are just generic comments.

    Comment


    • #3
      Dear Nick,

      Yes, you are right. Sometimes, the iteration goes to 100 or 200 and discontinuous. I talked to my supervisors, deciding to drop portfolios if the data in that portfolio is not converge.

      Also, yes. I don't know which portfolio is running without -di `i'-

      I have not found some one around me using both STATA and GARCH family, so can't get specific suggestions. It is annoying.

      Plus, as it has been running for 6 days, I cannot bear to re-start again. As I use -capture- code, the only way to stop it should be shut down the computer and I will loss all the results, is it?

      It looks on the right way, is it?
      (setting optimization to BHHH)
      Iteration 0: log likelihood = 5195.8453 (not concave)
      Iteration 1: log likelihood = 5218.9637
      Iteration 2: log likelihood = 5236.5865
      Iteration 3: log likelihood = 5254.2901
      Iteration 4: log likelihood = 5261.7522
      (switching optimization to BFGS)
      Iteration 5: log likelihood = 5272.3184
      BFGS stepping has contracted, resetting BFGS Hessian (0)
      Iteration 6: log likelihood = 5277.7121
      Iteration 7: log likelihood = 5277.8299 (backed up)
      Iteration 8: log likelihood = 5277.8327 (backed up)
      Iteration 9: log likelihood = 5278.0802 (backed up)
      Iteration 10: log likelihood = 5278.2001 (backed up)
      Iteration 11: log likelihood = 5278.7869 (backed up)
      Iteration 12: log likelihood = 5280.3425 (backed up)
      Iteration 13: log likelihood = 5280.8293 (backed up)
      Iteration 14: log likelihood = 5280.9084 (backed up)
      (switching optimization to BHHH)
      Iteration 15: log likelihood = 5280.9365
      Iteration 16: log likelihood = 5281.6523
      Iteration 17: log likelihood = 5281.7501
      Iteration 18: log likelihood = 5281.7733
      Iteration 19: log likelihood = 5281.7768
      (switching optimization to BFGS)
      Iteration 20: log likelihood = 5281.7791
      Iteration 21: log likelihood = 5281.7793
      Iteration 22: log likelihood = 5281.7797

      ARCH family regression

      Sample: 08apr1998 - 20may2004, but with gaps Number of obs = 1,543
      Distribution: t Wald chi2(5) = 3042.71
      Log likelihood = 5281.78 Prob > chi2 = 0.0000

      ------------------------------------------------------------------------------
      | OPG
      ut | Coef. Std. Err. z P>|z| [95% Conf. Interval]
      -------------+----------------------------------------------------------------
      ut |
      rmrf | 1.047012 .0225769 46.38 0.000 1.002762 1.091262
      smb | .569455 .0273299 20.84 0.000 .5158893 .6230207
      hml | .0708088 .0195766 3.62 0.000 .0324395 .1091781
      umd | -.0378676 .019251 -1.97 0.049 -.0755989 -.0001364
      _cons | -.001613 .001109 -1.45 0.146 -.0037866 .0005606
      -------------+----------------------------------------------------------------
      ARCHM |
      sigma2ex | .1858153 .1413551 1.31 0.189 -.0912356 .4628662
      -------------+----------------------------------------------------------------
      ARCH |
      arch |
      L1. | .3038279 .0519876 5.84 0.000 .201934 .4057218
      |
      garch |
      L1. | .3781494 .1249691 3.03 0.002 .1332144 .6230844
      |
      _cons | .0000221 7.19e-06 3.07 0.002 7.96e-06 .0000362
      -------------+----------------------------------------------------------------
      /lndfm2 | 1.809912 .2630429 6.88 0.000 1.294357 2.325466
      -------------+----------------------------------------------------------------
      df | 8.109907 1.607168 5.648649 12.23145
      ------------------------------------------------------------------------------
      (6,442 real changes made)
      (6,442 real changes made)
      (6,442 real changes made)

      Comment


      • #4
        Even with capture you can still use the standard break mechanism.

        Comment


        • #5
          Dear Jesse,

          Many thanks for your help. Unfortunately, I tried, but doesn't work. I used the break button as well as Ctrl+Pause/Break. Both, doesn't work.



          Comment


          • #6
            You may need to press it a few times. If it doesn't work, it's likely due to the arch command. I just tried with

            Code:
            capture sleep 20000
            And I was able to interrupt it just fine. One thing you might want to try is running your arch model on a dataset containing only id = `i' and comparing the time that takes to running the same arch model on the full dataset (with the if id == `i') condition. For some commands, the size of the dataset matters, even if the observations aren't used. You can also try experimenting with different mat-sizes, this sometimes makes a difference. You can time how long something takes by using timer on/timer off, or alternatively the single-line timeit command from ssc.

            Comment


            • #7
              Dear Jesse,

              I see. I am really grateful for your help. I will try all your suggestions. BIG THX AGAIN!

              Comment


              • #8
                Best of luck

                Comment


                • #9
                  Stata throws an error 1 when the break button is pressed. In your case, this will most likely happen while Stata is processing the arch command. At that point, arch will terminate and _rc will be set to 1. You use capture as a device to ignore errors but you do not handle the case where the returned error is 1 so the loop continues to the next iteration.

                  I have no experience with arch but I would think that the first step would be to just try it on a single group and fine tune the command and optimization parameters based on that by-group. If that seems to take a long time, then I would point out that each by-group is processed independently of the others so you should do just a few groups at a time. Just save these results and append them later when all the groups have been processed.

                  Here's an example that you can break out of. I also set a very low limit for the number of iterations and I prints out a status line to indicate the current by-group.

                  Code:
                  * create a demonstration dataset
                  version 15
                  clear all
                  set obs 478
                  gen id = _n
                  expand 100
                  bysort id: gen t = mdy(1,1,1995) + _n
                  format %td t
                  set seed 3123
                  foreach v in ut rmrf smb hml umd {
                      gen `v' = runiform()
                  }
                  tsset id t
                  
                  
                  set maxiter 5
                  gen b = .
                  gen z = .
                  gen p = .
                  forvalue i=1(1)478 {
                      dis _n(3) _dup(10) "****" " id = `i' " _dup(10) "****" _n(3) 
                      capture noisily arch ut rmrf smb hml umd if id==`i', archm arch(1) garch(1) archmex(sqrt(X)) distribution(t)
                      if _rc==0 {
                          tempname M
                          matrix `M'= r(table)
                          replace b=`M'[1,6] if id==`i'
                          replace z=`M'[3,6] if id==`i'
                          replace p=`M'[4,6] if id==`i'
                      }
                      else if _rc == 1 exit 1
                  }

                  Comment

                  Working...
                  X