Announcement

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

  • "Program" ml model - ml check error message: returned error 198

    Dear all,

    I programmed the following ml model d0 which I somehow don't get to run, supposedly because of some invalid names. I am using a balanced panel dataset T=7, N = 187. Year is the variable defining the time dimension and countryid is the panel variable. Let me give you the code:

    Code:
    global MY_panel countryid
        program ziqcmle
        args todo b lnf
        tempvar xb zb last mu_it mu_i_ mu_i p_it y_i_ y_i sumqcl_i
        mleval ‘`xb' =‘ `b'’, eq(1)
        mleval ‘`zb’' =‘ `b'’, eq(2)
        local y_it "$ML_y1"
        local i $MY_panel
        * calculate the log-likelihood
        quietly {
        sort `‘i'’
        by ‘`i'’: gen double `‘last'’ = (_n==_N)
        gen double ‘`mu_it'’ = (exp(`‘xb'’)/(1+exp(`‘zb'’)))
        by ‘`i'’: gen double `‘mu_i_' = sum(`‘mu_it'’)
        by ‘`i'’: gen double ‘`mu_i’' = ‘`mu_i_'’[_N]
        gen double `‘p_it'’ = ‘`mu_it'’/`‘mu_i'’
        by ‘`i'’: gen double ‘`y_i_'’ = sum(`‘y_it'’)
        by ‘`i’': gen double ‘`y_i'’ = `‘y_i_'’[_N]
        by ‘`i’': gen double `‘sumqcl_i’' = sum(‘`y_it'’*ln(`‘p_it’') - ‘`p_it'’*`‘y_i’')
        mlsum `‘lnf'’ = ‘`sumqcl_i'’ if `‘last'’==1
        if (`‘todo'’ == 0 | `‘lnf'’==.) exit
        }
        end
        
        * Estimate the ZI-QCML model
        ml model d0 ziqcmle (y = x , nocons) (y = z)
        ml check        
        ml search    
        ml maximize
    I now get the following error message after ml check (irrespective of which variables I use for y, x and z). So there seems to be some error with the line where
    Code:
    mleval ‘`xb' =‘ `b'’, eq(1)
    .

    Output after ml check:

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

    Here is a trace of its execution:

    -> ziqcmle 0 __000009 __00000A __00000B __00000C
    - `begin'
    = capture noisily version 14.2: ziqcmle 0 __000009 __00000A __00000B __00000C
    --------------------------------------------------------------------------------------------------------------------------- begin ziqcmle ---
    - args todo b lnf
    - tempvar xb zb last mu_it mu_i_ mu_i p_it y_i_ y_i sumqcl_i
    - mleval ‘`xb' =‘ `b'’, eq(1)
    = mleval ‘__00000D =‘ __000009’, eq(1)
    ‘__00000D invalid name
    ----------------------------------------------------------------------------------------------------------------------------- end ziqcmle ---
    - `end'
    = set trace off

    Fix ziqcmle.
    r(198);

    end of do-file

    I am not quite sure what I am doing wrong here, though I have to admit I am just starting with ml model programming. Does anyone have a hint?

    Many thanks and please let me know if you need more information.

    Best, Insa
    Last edited by Insa Flachsbarth; 13 Nov 2018, 08:13.

  • #2
    The problem is solved. Just for your information: I had copy pasted part of the code from another source. Somehow Stata had difficulties identifying the copied text. So I rewrote the code again and it worked. It is a bit strange as it looks exactly the same, but it solved the problem...
    Just in case someone faces a similar issue at some point...

    Comment

    Working...
    X