! Maximum Likelihood Estimation with censored data;
! Keywords: Maximum Likelihood Estimation, Censored Data,
            Statistics;
SETS:
 obs: stock, leftover;
ENDSETS
! Renard de Lac newspaper data; DATA: ! Simple [mean,sd] of (stock-leftover) = [101.46, 13.10]; stock, leftover = 110 17 85 0 110 18 110 15 110 14 110 15 110 10 110 6 100 0 110 10 95 10 95 0 100 20 100 0 110 11 115 17 115 9 115 11 115 17 115 0 115 18 115 15 115 0 135 0 150 13 150 37; ENDDATA ! Find mu and sigma that maximize the log of the likelihood that we would observe the above data, assuming the demands are Normal with mean mu and standard deviation sigma. Some of the observations are "censored" in the sense that we do not know the exact demand, only that demand was at least equal to the amount of product we stocked(which we do know); MAX = ! Cases where demand = sales = stock - leftover; @SUM(obs(i)| leftover(i) #gt# 0: -.5* @LOG( 2*3.1415926)- @LOG(sigma) -.5*((stock(i)- leftover(i)- mu)/sigma)^2) ! Cases where we do not know demand, only that demand >= sales = stock; + @SUM(obs(i)| leftover(i) #eq# 0: @LOG(1 - @PSN((stock(i)-mu)/sigma)));