Announcement

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

  • A problem in Maximum Likelihood estimation (MLE) "‘lnfj’ invalid name".

    .Hello everyone, I am learning the MLE model and practicing through the book examples using Stata12. Even applying the given example of the book is continuously showing this error. Please suggest me the reason of this error. I am stuck with this problem and unable to proceed. ml check description is also mentioned below for clarificaton
    program myprobit_lf
    1. version 11
    2. args lnfj xb
    3. quietly replace ‘lnfj’ = ln(normal( ‘xb’)) if $ML_y1 == 1
    4. quietly replace ‘lnfj’ = ln(normal(-‘xb’)) if $ML_y1 == 0
    5. end
    ml check

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

    Here is a trace of its execution:
    ------------------------------------------------------------------------------
    -> myprobit_lf __000008 __000009
    - `begin'
    = capture noisily version 12: myprobit_lf __000008 __000009
    ---------------------------------------------------------------------------------------------------------- begin myprobit_lf ---
    - version 11
    - args lnfj xb
    - quietly replace ‘lnfj’ = ln(normal( ‘xb’)) if $ML_y1 == 1
    = quietly replace ‘lnfj’ = ln(normal( ‘xb’)) if died == 1
    ‘lnfj’ invalid name
    ------------------------------------------------------------------------------------------------------------ end myprobit_lf ---
    - `end'
    = set trace off
    ------------------------------------------------------------------------------
    Fix myprobit_lf.
    r(198);

    .


  • #2
    Your problem is that these two lines of code
    Code:
    quietly replace ‘lnfj’ = ln(normal( ‘xb’)) if $ML_y1 == 1
    quietly replace ‘lnfj’ = ln(normal(-‘xb’)) if $ML_y1 == 0
    were probably copied from a PDF of Stata documentation, or some other PDF.

    Because many official PDFs are printed in a typeface that does not display punctuation identically to Stata, note that where the PDF has something that looks like
    Code:
     ‘xb’ 
    you need to type on your keyboard
    Code:
     `xb' 
    where the first character is (on an American English keyboard) the "left single quote" beneath the tilde (~) character below the ESC key, and the final character is the usual "single quote" ("apostrophe") just to the left of the RETURN key. Put another way, don't copy your code from a Word or PDF document that uses "smart quotes" and then copy-and-paste it into Stata 16 earlier without correcting it afterwards. Stata 17 includes a preference setting (on by default) to "replace pasted curly quotes with ASCII quotes" to work around this problem.

    So correct your references to the function arguments and that problem will go away.

    Comment


    • #3
      Thank you

      Comment

      Working...
      X