Announcement

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

  • limit maximum execution time of command

    Is there a way to limit the maximum execution time of a command, so that if the time to compute exceeds the set threshold - stata will give an error and proceed the next command?
    I just woke up and saw that some estimation command got stuck at some iteration for more than 8 hours - I wish I could have set the maximum time of estimation for something like 2 hours so that other commands could have been estimated (similar in a way to capture noisily)

    for example, say that the first 2 regressions in this code take more than 10 minutes to estimate, while the third one takes 5 minutes - and the maximum time for estimation is set at 8 minutes. I'm looking for something like this:
    Code:
    sysuse auto
    reg price mpg foreign
    --- estimation time exceeds max set in c(max_time) ---
    reg price mpg rep78
    --- estimation time exceeds max set in c(max_time) ---
    reg price mpg
          Source |       SS       df       MS              Number of obs =      74
    -------------+------------------------------           F(  1,    72) =   20.26
           Model |   139449474     1   139449474           Prob > F      =  0.0000
        Residual |   495615923    72  6883554.48           R-squared     =  0.2196
    -------------+------------------------------           Adj R-squared =  0.2087
           Total |   635065396    73  8699525.97           Root MSE      =  2623.7
    
    ------------------------------------------------------------------------------
           price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             mpg |  -238.8943   53.07669    -4.50   0.000    -344.7008   -133.0879
           _cons |   11253.06   1170.813     9.61   0.000     8919.088    13587.03
    ------------------------------------------------------------------------------

  • #2
    I don't think this is possible in a programming language like Stata's. I think theoretically it could be done in Mata, but I don't think it's implemented at the moment.

    I could be wrong though!

    Comment


    • #3
      Ariel: what command are you using for real? Is it really regress? You mention "iteration", but I don't think the estimates are derived using "iterations" in the same way that, say, maximum likelihood estimates are. In the ML case, you can use the maxit() option to indirectly control how long something runs. You can also use other maximize options to tune how much is shown in the iteration log, and that can be informative about why something may be taking so long

      Comment


      • #4
        By the way, if it is something relatively straightforward (as in, linear), you might be able to use -reghdfe- to do this. At least for my regressions it's at least 10x faster than regress and xtreg.

        Comment


        • #5
          Jenkins is of course correct - the issue does not present itself in regress (as it does not involve an iterated maximzation process). The usage of regress was just for illustration purposes.
          I know that I can use iterate() or maxiterate() to specify a maximum threshold for the number of iterations performed. Issue is that some estimation may get stuck at a particular iteration (which can be low) for a long time. So specifying the maximum number of iterations is unhelpful in that regard. The imperative for this question and a similar issue can be found in a new thread I just opened, here:
          http://www.statalist.org/forums/foru...rho-estimation

          Comment

          Working...
          X