[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Stas Kolenikov" <skolenik@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Likelihood function of uniform distribution |

Date |
Tue, 1 Apr 2008 15:53:33 -0500 |

On 4/1/08, Bob Hammond <robert.g.hammond@vanderbilt.edu> wrote: > program myunif > args lnf theta > quietly replace `lnf' =ln(`theta') if $ML_y1==1 > quietly replace `lnf' =ln(1-`theta') if $ML_y1==0 > end what this does is f(x|theta) = theta^y (1-theta)^{1-y) that is, the binomial/Bernoulli likelihood. What you need is program myunif args lnf theta quietly replace `lnf' = 0 if $ML_y1>0 & $ML_y1 <1 quietly replace `lnf' = . if $ML_y1<=0 & $ML_y1 >=1 end Note that theta is not used. Which is proper since there are no parameters to estimate, you know everything in perfection already. As for the triangular distribution (again, nothing to estimate): > Also, how do you define the following triangular probability > distribution function? > > f(x)= 4x if 0<x<0.5 > =4-4x if 0.5<x<1 > =0 otherwise. prog def mytriang args lnf theta qui replace `lnf' = ln(4*$ML_y1) if $ML_y1 >0 & $ML_y1 < 0.5 qui replace `lnf' = ln(4*(1-$ML_y1)) if $ML_y1 >=0.5 & $ML_y1 <=1 qui replace `lnf' = . if $ML_y1 < 0 & $ML_y1 >1 end Since the likelihood does not change with theta, either function will fail -ml check-. You really need to estimate something. Stata's optimizer does not handle non-smooth densities like those of uniform or triangular very graciously; you'll see a lot of error messages (derivatives cannot be computed) when it has to work near the boundary of the support. -- Stas Kolenikov, also found at http://stas.kolenikov.name Small print: Please do not reply to my Gmail address as I don't check it regularly. * * 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/

**Follow-Ups**:**RE: st: Likelihood function of uniform distribution***From:*"Mostafa Beshkar" <mostafa.beshkar@vanderbilt.edu>

**References**:**st: Likelihood function of uniform distribution***From:*Bob Hammond <robert.g.hammond@vanderbilt.edu>

- Prev by Date:
**Re: st: Stata graph how to?** - Next by Date:
**st: RE: F-stat of excl inst too big in robsut estimation with dummydependent variable (xtivreg2)** - Previous by thread:
**st: RE: RE: Likelihood function of uniform distribution** - Next by thread:
**RE: st: Likelihood function of uniform distribution** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |