Announcement

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

  • Is there an equivalent of stata's quietly and noisily in mata?

    I have some mata code for an optimization problem in a stata .do file. I'd like to print out the iteration log (and maybe a few other things) from this code, but suppress seeing most of the mata codet in my display or log file. Stata let's you do that with quietly and noisily. Is there an equivalent way to do this in mata?

  • #2
    Not as such. For example, an assignment is quiet unless it provokes an error message, but you do see the code if you are using Mata interactively. A display is noisy. I can't imagine why you would want to suppress a display. I suspect I am missing your point.

    Comment


    • #3
      My mata code does lots of things (copies data, evaluates an objective function, computes a gradient, initializes the optimize function, etc). I don't really need to see all that in my display or log. But I would like to see the iteration output from optimize and if I use "d1debug" I'd like to see the diagnostic output that's produced. For example, it would be nice to use a stata like command such as noi bh=optimize(S) so that I can see the output from just this command without having to see everything else that the mata code is doing. As it stands, I've figured out how to put either everything that's going on inside the block of mata code in my log or nothing.
      I apologize for not asking a better phrased question. I'm obviously new to mata and only about a third of the way through Gould's book. Maybe I'll answer my question or find a better way of phrasing it in a couple of days...

      Comment


      • #4
        Angelo Melino --

        I'm not sure it helps, but I had a utility program that I have put into some of my packages to display iterations. It works a little bit like the following:

        Code:
        mata:
        void makenoise(real scalar its,real scalar draws, real scalar val)
        {
            if (round(its/50)==its/50 & its!=draws) {
                printf(" %f: ln_fc(p) = %g\n",its,val)
                displayflush()
                                                        }
            else if (& its!=draws) {
                printf(".")
                displayflush()
                                     }
            else {
                    printf("\n %f: ln_fc(p) = %g\n",its,val)
                 }
        }
        
        
        for (i=1;i<=1000;i++) makenoise(i, 1000, runiform(1, 1))
        end

        Comment

        Working...
        X