Announcement

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

  • difficult to find the problem in MLE coding

    Hello everyone, this is the code i am writing to estimate MLE estimates. while writing this program i am trying to check this program by ML check command and getting "prob1l^ invalid name". it is showing that invalid name in the program. this i am unable to understand. please help me on this problem.


    Test 1: Calling HL_cpt0 to check if it computes log likelihood and
    does not alter coefficient vector...
    FAILED; HL_cpt0 returned error 198.

    Here is a trace of its execution:
    ------------------------------------------------------------------------------
    -> HL_cpt0 __000008 __000009
    - `begin'
    = capture noisily version 12: HL_cpt0 __000008 __000009
    ----------------------------------------------------------------------------------------------------------------------------------------- begin HL_cpt0 ---
    - args lnf alpha gamma
    - tempvar choices prob1l prob2l prob1r prob2r y1 y2 y3 y4 euL euR euDiff tmp
    - quietly {
    - generate double `tmp' = (($ML_y2^`gamma')+((1-$ML_y2)^`gamma'))
    = generate double __00000M = ((prob1l^)+((1-prob1l)^))
    prob1l^ invalid name
    replace `tmp' = `tmp'^(1/`gamma')
    generate double `prob1l' = ($ML_y2^`gamma')/`tmp'
    generate double `prob2l' = ((1-$ML_y2)^(`gamma'))/`tmp'
    replace `tmp' = (($ML_y3^`gamma')+((1-$ML_y3)^`gamma'))
    replace `tmp' = `tmp'^(1/`gamma')
    generate double `prob1r' = ($ML_y3^`gamma')/`tmp'
    generate double `prob2r' = ((1-$ML_y3)^(`gamma'))/`tmp'
    generate double `y1' = ($ML_y4)^(`alpha') if $ML_y4>=0
    generate double `y2' = ($ML_y5)^(`alpha') if $ML_y5>=0
    generate double `y3' = ($ML_y6)^(`alpha') if $ML_y6>=0
    generate double `y4' = ($ML_y7)^(`alpha') if $ML_y7>=0
    gen double `euL'=(`prob1l'*`y1')+(`prob2l'*`y2')
    gen double `euR'=(`prob1r'*`y3')+((1-`prob2r')*`y4')
    generate double `euDiff' = `euR' - `euL'
    replace `lnf' = ln(normal( `euDiff')) if $ML_y1==1
    replace `lnf' = ln(normal(-`euDiff')) if $ML_y1==0
    }
    ------------------------------------------------------------------------------------------------------------------------------------------- end HL_cpt0 ---
    - `end'
    = set trace off
    ------------------------------------------------------------------------------
    Fix HL_cpt0.
    r(198);

  • #2
    prob1l^ is an illegal variable name.

    Comment


    • #3
      The problem seems to be that the local macro gamma contains nothing, so that the line
      Code:
      generate double `tmp' = (($ML_y2^`gamma')+((1-$ML_y2)^`gamma'))
      is getting evaluated as
      Code:
      generate double __00000M = ((prob1l^)+((1-prob1l)^))
      and so Stata thinks you are using prob1l^ as a variable name. That is an illegal name, hence the error.

      I notice you are taking the third argument to the program as gamma, via the line
      Code:
      args lnf alpha gamma
      So the likely cause is that you are calling the program with fewer than three arguments.
      Last edited by Hemanshu Kumar; 26 Aug 2022, 23:38.

      Comment


      • #4
        thank you

        Comment

        Working...
        X