Announcement

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

  • -ereturn- with Mata outputs

    Hi,

    I have done an optimization in Mata. For the final output I use the -ereturn- command by using the variance-covariance matrix and the coefficients vector as its inputs (ereturn post b V). How can I add the other statistics to this output? e.g. I have the R-squared scalar but I don't know how to include it in the -ereturn- command.

    Kind regards,
    Eilya.

  • #2
    Use

    Code:
    st_numscalar("e(name)", real scalar)
    st_global("e(name)", string scalar)
    st_matrix("e(name)", real matrix)
    in Mata to post anything but e(b) and e(V), or

    Code:
    ereturn scalar name = scalar
    ereturn local  name string
    ereturn matrix name = matrix
    in Stata.

    You need to do this before (or after - can't remember, but the order was important) you use post.

    Hope this helps.
    Daniel

    Comment


    • #3
      Hi Daniel,

      Thanks for your help. Yes, I have done this. But, I get the error that "non e-class program may not set e()". How should I solve this?

      Kind regards,
      Eilya.

      Comment


      • #4
        You need at least one e-class program to post your results. I have no idea what you code looks like, but it could look like

        Code:
        program myoptimizer ,eclass
           ...
        
           mata : mymataoptimizer(args)
        
           ...
          
            ereturn post b V
           ereturn scalar r2 = r2
        end
        Hope this helps.
        Daniel

        Comment

        Working...
        X