Announcement

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

  • Displaying results with an estimation command written in Mata's moptimize()

    I've written an estimation command that uses Mata's moptimize() suite of functions along with an evaluator function. After moptimize(M), I use moptimize_result_post(M), st_global("e(cmd)", . . .) etc.

    I would like to allow options for the ado-file (the command) to take, for example [OR Level(cilevel)], but I cannot see in the help file or user's manual for the moptimize() suite anything to set these options. (Did I overlook this somewhere?) I also Googled "stata moptimize() confidence interval display" and didn't notice anything among the first few browser screenfuls of results that would indicate that this has been asked before and addressed.

    For now, I'm using the Stata command ml display , level(`level') `or' up above in the ado code, but is there anyway to accomplish this directly in Mata? I keep thinking that it's got to be in the documentation someplace; could someone point me in the right direction?

  • #2
    You mean ereturn display (and not ml display) ?
    There is also a moptimize_return_display(), but it does not take arguments.
    The only way I see is to use the stata("ereturn display , level()") function.

    Comment


    • #3
      Christophe, thanks for the reply.

      I do mean ml display, and wasn't actually aware of ereturn display, which, as I now read its help file, does a similar if not identical thing. (One might be nothing but a wrapper for the other, for all I know.)

      As far as moptimize_return_display(), that is what I used to work up the Mata code (passing in the transmorphic scalar optimization problem handle as its argument).

      When I look at the Mata chapter of Maximum Likelihood Estimation with Stata, Fourth Edition, it seems that StataCorp is still recommending doing most of the work in Stata's ml suite, and using Mata for only for coding a single evaluator function called by ml maximize.

      It seems that there is no native Mata function that has as rich a set of options for display as ereturn display and ml display have.

      Comment


      • #4
        I guess that you can use ml display because you use an ml evaluator. Besides ereturn display requires that your ado-file is of e-classtype. I use to do all the ml estimation in mata and have given up the ml evaluator. Maybe I should reconsider it if StataCorp recommends to use ml maximize. Best Christophe

        Comment


        • #5
          Again, thanks for the follow-up.

          I actually don't use an ml evaluator. Everything past
          Code:
          marksample touse
          gettoken response predictors : varlist
           _fv_check_depvar  `response'
          local wgt = cond("`weight'" == "", "", "[`weight'`exp']")
          _rmcoll `predictors' if `touse' `wgt', `constant' expand
          is written in Mata. I use ml display afterward, and it works despite not using ml maximize, because of moptimize_result_post(M).

          I had to use Mata for the evaluator, because computing the score vector involves weighted cross-products, and matrix glsaccum cannot accommodate factor variables. I planned just to code the gradient computation in Mata in an evaluator ado-file called by the command ado-file as conventionally done, but when I saw how easy it is to do, I went ahead and wrote the entire evaluator in Mata and wrote the maximization set up & execution in Mata, as well. The only hitches were processing the constraints--these are handled very easily in ml--and the display. After inspection of official Stata makecns and matcproc and the Mata code and built-ins that they call, it wasn't difficult to write a Mata routine to handle constraints, but it looks as if I need to use either ml display or ereturn display Stata commands for the final display of the coefficient table.

          Comment

          Working...
          X