Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: ml mixture distribution

From   Lukas Kornher <>
Subject   st: ml mixture distribution
Date   Mon, 09 Jul 2012 18:14:29 +0200

Dear Statalisters,

I am trying to set up a ml model for a mixture distribution function with three regimes. Stata cannot find a maximum and returns: /could not calculate numerical derivatives -- discontinuous region with missing values encountered/. I am quite new to ml in Stata and I find very little on mixture distribution on the web and in MLE with Stata. Any comments would be really appreciated. Especially how one can constraint the sum of the regime probabilities to 1.
Many thanks.



program define pbm_mixture ;
args todo b lnf;
tempvar lnf_j;
tempname lambda1 lambda2 sigma_1 sigma_2 sigma_3 mu;
scalar `mu' = `b'[1,1];
scalar `sigma_1' = exp(`b'[1,2]);
scalar `sigma_2' = exp(`b'[1,3]);
scalar `sigma_3' = exp(`b'[1,4]);
scalar `lambda1'  = normal(`b'[1,5]);
scalar `lambda2'  = normal(`b'[1,6]);
gen double `lnf_j' =
  `lambda1' * (1/`sigma_1') * normalden(($ML_y1 - `mu')/`sigma_1') +

`lambda2'*(2/sqrt(`sigma_1'^2+`sigma_2'^2)) * normalden(($ML_y1 - `mu')/ sqrt(`sigma_1'^2+`sigma_2'^2))* (1-normal((-($ML_y1 - `mu')*(`sigma_1'/`sigma_2'))/ sqrt(`sigma_1'^2+`sigma_2'^2)))+

(1-`lambda1'-`lambda2') * (2/sqrt(`sigma_1'^2+`sigma_3'^2)) * normalden(($ML_y1 - `mu')/ sqrt(`sigma_1'^2+`sigma_3'^2))* (1-normal((($ML_y1 - `mu')*(`sigma_1'/`sigma_3'))/ sqrt(`sigma_1'^2+`sigma_3'^2)));
 mlsum `lnf' = log(`lnf_j');

gen mu = -0.00001;

ml model d0 pbm_mixture (tau = mu, noconst technique(dfp) ) /ln_sigma_1 /ln_sigma_2 /ln_sigma_3 /inv_lambda1 /inv_lambda2 ;
ml init mu=0;
ml check;
ml search lambda1 0 1 lambda2 0 1, repeat(250);
ml maximize;

Lukas Kornher

Phd Candidate
Department of Economic and Technological Change
Center for Development Research
University of Bonn

Tel.: +49 (0) 228 / 73-1842
Room 1.031

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index