My problem is that the middle part (by Security_ID:...) doesn´t really generate the sub-likelihood functions..
by without the
sort option requires that the data be sorted
cap pr drop ML_My_problematic_model_1
pr ML_My_problematic_model_1
args todo b
lnf
tempvar alpha lambda gamma last
lj utility_diff
mleval `alpha' = `b', eq(1)
mleval `lambda' = `b', eq(2)
mleval `gamma' = `b', eq(3)
qui{
sort security_ID
by security_ID: g double `utility_diff'=`utility_alternative_2' -`utility_alternative_1'
by security_ID: g byte `last'=_n==_N
g double `lj'=.
by security_ID: replace `
lj' =normal(`utility_diff'*(-1)^$ML_y1)
mlsum `
lnf' = ln(`
lj') if `last'
if (!`todo'|`
lnf'>=.) exit
}
end
(1) It seems that the first macro after "args" stands for the general term in the cumulative sum.
(2) "** **" cannot be used as "in-line" comment delimiters.