On Sat, February 18, 2006 23:11, Arnaud Bervas wrote:
Hi
What are the limitations in the format for the formulas of log-likelihood ?
I tried unsuccessfully to make a mle with the following script:
genr BUY = BUYE + BUYF
genr SELL = SELLE + SELLF
genr c1 = 0.5
genr c2 = 0.2
genr c3 = 0.2
mle loglik= log (c3*((1-c1)*((0.5*(1+c2))^BUY *(0.5*(1-c2))^SELL)+
c1*((0.5*(1-c2))^BUY *(0.5*(1+c2))^SELL)) +(1-c3)*0.5^BUY*0.5^SELL)
params c1 c2 c3
end mle
Can you see why ?
I can't, unless you provide more information. From what seems likely from the
script, I suppose BUY and SELL are nonnegative. Or strictly positive? Are they
integers or floats? How big is your sample?
I tried to run your script snippet with some artificially-generated data as
follows and it seems to run fine here.
nulldata 200
genr BUY = int(uniform()*10)
genr SELL = int(uniform()*10)
Also, it looks like your 3 parameters are in the [0-1] range. In this case,
sometimes numerical algorithms get into trouble when the gradient points
outside the [0-1] interval. You may want to consider some nonlinear
transformation that maps onto the real line, like the following
genr c1 = 0.5
genr c2 = 0.2
genr c3 = 0.2
mle loglik= log (p3*((1-p1)*((0.5*(1+p2))^BUY
*(0.5*(1-p2))^SELL)+p1*((0.5*(1-p2))^BUY *(0.5*(1+p2))^SELL))
+(1-p3)*0.5^BUY*0.5^SELL)
scalar p1 = 1/(1+exp(-c1))
scalar p2 = 1/(1+exp(-c2))
scalar p3 = 1/(1+exp(-c3))
params c1 c2 c3
end mle
This way c1, c2 and c3 gofrom minus to plus infinity and your parameters of
interest become p1, p2, p3. This formulation (obviously equivalent) should be
more robust to numerical problems.
HTH,
--
Riccardo "Jack" Lucchetti
Dipartimento di Economia
FacoltĂ di Economia "G. FuĂ "
Ancona