I would suggest that you either adjust the value of `F' for the observations
that you don't want in the sum or else don't use mlsum but instead perform
the calculation yourself.  I think the first suggestion might be easier.
How about inserting the line
replace `F'=log(F)*`last'
just before the mlsum and change the mlsum line to read
mlsum `lnf' = `F'
That is, take the logs yourself but count observation not flagged with
`last' as zero.
Michael Blasnik
[email protected]
----- Original Message ----- 
From: "Alfonso Miranda Caso Luengo"
<[email protected]>
To: <[email protected]>
Sent: Monday, June 14, 2004 11:47 AM
Subject: Re: st: fweights + ml d0
> Dear all,
>
> Here is an example of the problems I found with fw and ml d0. This code
estimates a sequential probit. A dummy dependent variable is observed for
each individual in various periods. The model predicts the probability of
observing a given sequence. For each individual draws are iid. However,
observations in the data set are not independent as each individual
contributes a group of observations. Hence, the ml linear-form restriction
is not met in this case.
>
> Here is the example. Can anyone see the error?
>
> Many thanks in advance,
>
> Alfonso.
>
>
<snip>
> . capture program drop mycode2_ll
>
> . program define mycode2_ll
>   1. args todo b lnf
>   2.
> .  local y "$ML_y1"
>   3.  local i "$S_ivar"
>   4.
> .  tempvar xb F  last
>   5.
> .  mleval `xb' = `b'
>   6.
> .  qui {
>   7.         by `i' : gen `last' = cond(_n==_N,1,0)
>   8.
> .         gen double `F' = . in 1  if  $ML_samp
>   9.
> .      #delimit ;
> delimiter now ;
> .      by `i': replace `F' =
> >      cond(_n==1,
> >      cond(`y',normprob(`xb'),normprob(-`xb')),
> >      cond(`y',
> >      normprob(`xb'),normprob(-`xb'))*`F'[_n-1] ) if $ML_samp;
>  10.      #delimit cr
> delimiter now cr
> .
> .      mlsum `lnf' = log(`F')  if `last'
>  11.
> .    }
>  12. end
>
<snip>
> Alfonso Miranda
> PhD Student
>
> Economics Department
> University of Warwick
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/