Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Maarten Buis <maartenlbuis@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: ml mixture distribution |

Date |
Tue, 10 Jul 2012 09:55:56 +0200 |

On Mon, Jul 9, 2012 at 6:39 PM, Lukas Kornher wrote: >I know the command. I have a mixture distribution of a > normal and two truncated normal which is not available for fmm. Do you think > it is possible to rewrite Deb's original code? Sure, I have learned most of my Stata programming from looking at other person's code for similar problems. You can see the code by typing -viewsource fmm.ado-. Another useful strategy is to first program a simpler problem. I would start with creating the programs inside a .do file and begin with just a normal distribution without any mixture components, check that against -regress-, than extend that to a problem that is already implemented in -fmm-, e.g. a normal distribution with two normal components. See if that works and gives the same results as -fmm-, than complicate it by changing the components to truncated normals, and than add bells and whistles like turning this into an .ado file and checking for valid input. Below is an example of how I would begin such a project. *---------------------- begin example ------------------------ // clear programs and data clear all // create log-likelihood evaluator program define mynormal_lf args lnf mu ln_sigma tempname sigma scalar `sigma' = exp(`ln_sigma') qui replace `lnf' = ln(normalden($ML_y1, `mu', `sigma')) end // open example data sysuse auto sum weight if foreign == 0, meanonly gen c_weight = (weight - r(min))/2000 label var c_weight /// "weight centered at lightest domestic car (short tons)" gen c_price = (price - 6000) / 1000 label var c_price "price centered at 6000$ (1000$)" // specify the model ml model lf mynormal_lf /// mu: c_price = c_weight foreign) /ln_sigma // check and maximize ml check ml search ml maximize // check against regress regress c_price c_weight foreign *----------------------- end example ------------------------- (For more on examples I sent to the Statalist see: http://www.maartenbuis.nl/example_faq ) Apart from that, you will need excess to: William Gould, Jeffrey Pitblado and Brian Poi (2010) "Maximum Likelihood Estimation with Stata", fourth edition. College Station, TX: Stata Press. <http://www.stata.com/bookstore/maximum-likelihood-estimation-stata/> Hope this helps, Maarten -------------------------- Maarten L. Buis Institut fuer Soziologie Universitaet Tuebingen Wilhelmstrasse 36 72074 Tuebingen Germany http://www.maartenbuis.nl -------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: ml mixture distribution***From:*Maarten Buis <maartenlbuis@gmail.com>

**References**:**st: ml mixture distribution***From:*Lukas Kornher <lukas.kornher@uni-bonn.de>

**Re: st: ml mixture distribution***From:*Maarten Buis <maartenlbuis@gmail.com>

**Re: st: ml mixture distribution***From:*Lukas Kornher <lukas.kornher@uni-bonn.de>

- Prev by Date:
**AW: AW: st: RE: Lagged dependent variable with fixed effects regression** - Next by Date:
**st: nlsuraids need help with AIDS model error please** - Previous by thread:
**Re: st: ml mixture distribution** - Next by thread:
**Re: st: ml mixture distribution** - Index(es):