On Sat, 21 Jun 2014, Alecos Papadopoulos wrote:
 Good afternoon.
 I am running maximum likelihood using the script window.
 I have the need to estimate a log-likelihood that has a different
 functional form depending on whether the estimated value of the
 variable(the residual) at each observation is lower or greater than zero.
 In generic terms
 if u_i <=0
 mle   logl_i = f(u_i, a, b)
 else
 mle   logl_i = g(u_i, a, b)
 endif
 where u_i = y_i - c0 - c1*x_1i - c_2*x_2i     and the coefficients c0,
 c1, c2 are also under estimation, together with the variance terms a,b
 I am not sure how to write the mle command for this case. 
it should be quite easy if you use functions:
<pseudo-hansl>
function series f(series u, scalar a, scalar b)
    [whatever]
end function
function series g(series u, scalar a, scalar b)
    [whatever]
end function
function series loglik(series y, list X, matrix coef,
                        scalar a, scalar b)
     series u = y - lincomb(X, coef)
     series logl = (u>0) ? g(u, a, b) : f(u, a, b)
     return logl
end function
mle ll = logl(y, X, coef, a, b)
     coeff coef a b
end mle
</pseudo-hansl>
Hope this helps!
-------------------------------------------------------
   Riccardo (Jack) Lucchetti
   Dipartimento di Scienze Economiche e Sociali (DiSES)
   Università Politecnica delle Marche
   (formerly known as Università di Ancona)
   r.lucchetti(a)univpm.it
   
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------