Announcement

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

  • Maximum likelihood estimator bug

    Hi,

    I'm trying to make a simple maximum likelihood estimator. This is something I've done several times before, but this time I'm getting an error and I can't figure out why. I'm using Stata/MP 16.0.

    In this case I'm trying to estimate a multivariate normal model. Here's the code:

    Code:
    gen c1= invnorm(uniform())
    gen c2= invnorm(uniform())
    gen c3= invnorm(uniform())
    
    capture program drop mvn_ll
    program mvn_ll
            version 16.0
            args todo b lnf
            tempvar b1x b2x b3x lnsigma1 lnsigma2 lnsigma3
            mleval `b1x'        =     `b',        eq(1)
            mleval `b2x'         =     `b',        eq(2)
            mleval `b3x'         =     `b',        eq(3)
            mleval `lnsigma1'    =    `b',        eq(4)        scalar
            mleval `lnsigma2'    =    `b',        eq(5)        scalar
            mleval `lnsigma3'    =    `b',        eq(6)        scalar
            tempname Y MU SIGMA
            matrix `Y' = ($ML_y1 \ $ML_y2 \ $ML_y3)
            matrix `MU' = (`b1x'\ `b2x' \ `b3x')
            matrix `SIGMA' = (exp(`lnsigma1')^2, 0, 0 \ 0,exp(`lnsigma2')^2, 0 \ 0, 0, exp(`lnsigma3')^2)
            mlsum `lnf' = lnmvnormalden(`MU',`SIGMA',`Y')
    end
    
    ml model lf mvn_ll (c1=) (c2=) (c3=) (lnsigma1:) (lnsigma2:) (lnsigma3:)
    
    ml max
    When I run ml check, I'm getting the following message

    Code:
    Test 1:  Calling mvn_ll to check if it computes log likelihood and
             does not alter coefficient vector...
             FAILED; mvn_ll returned error 111.
    
    Here is a trace of its execution:
    ------------------------------------------------------------------------------
    -> mvn_ll __00000I __00000J __00000K __00000L __00000M __00000N __00000O
            - `begin'
            = capture noisily version 16: mvn_ll __00000I __00000J __00000K __00000L __00000M __00000N __00
    > 000O
              ---------------------------------------------------------------------------- begin mvn_ll ---
              - version 16.0
              - args todo b lnf
              - tempvar b1x b2x b3x lnsigma1 lnsigma2 lnsigma3
              - mleval `b1x' = `b', eq(1)
              = mleval __00000P = __00000J, eq(1)
    vector __00000J not found
              ------------------------------------------------------------------------------ end mvn_ll ---
            - `end'
            = set trace off
    ------------------------------------------------------------------------------
    Fix mvn_ll.
    r(111);
    And I can't figure out why that is. It's been a while since I've done this kind of thing, so I may be forgetting something basic. Can anyone shed some light on this?
    Last edited by Alex Stead; 26 Jan 2022, 05:05.

  • #2
    You specified ml model lf mvn_ll but the program definition for mvn_ll is for a d0 evaluator instead of an lf evaluator.

    Comment

    Working...
    X