Announcement

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

  • Mata-based likelihood evaluators with extra variables

    I am using the ml command in Stata with mata-written likelihood evaluators.
    Here, the likelihood evaluators include variables that do not appear in the equations in the ml command.
    Specifically, consider the following mata-based evaluators
    Code:
    mata:
    void my_eval(transmorphic scalar ML, real rowvector b, real colvector lnf)
    {
            real vector depvar, xb, lnf
            depvar = moptimize_util_depvar(ML, 1)
            xb        = moprimize_util_depvar(ML, b, 1)
    
            lnf = a function including depvar, xb, and z
    }
    end
    
    ml model lf my_eval() (depvar = xvar)
    As you can see, the evaluator requires an extra variable z.
    In this case, I am not sure how to use the input z in the ml model lf command.
    How can I solve this problem?

  • #2
    Originally posted by Minchul Park;n1730082As you can see, the evaluator requires an extra variable [B
    z[/B].
    In this case, I am not sure how to use the input z in the ml model lf command.
    Have you seen this thread? It shows one (inelegant) way.

    I haven't thought this through, but you might possibly be able to accomplish this by trick, namely,specifying z as the response variable of a second empty, no-constant equation in ml model and then referring to it inside the Mata evaluator with moptimize_util_depvar(ML, 2).

    Otherwise, you could as the linked thread states go all Mata and use the moptimize_init_userinfo() / moptimize_util_userinfo() function pair.

    Comment


    • #3
      Joseph Coveney Following your direction, I have just read the post. I think, using global with very rare name seems reasonable for now. Thank you so much.

      Comment

      Working...
      X