# st: Likelihood function of uniform distribution

 From Bob Hammond To statalist@hsphsun2.harvard.edu Subject st: Likelihood function of uniform distribution Date Tue, 01 Apr 2008 12:57:50 -0500

This message is from a friend who is having trouble sending a message to the list. Sorry if his message comes through later as a duplicate.

Hi,

In order to run a Maximum Likelihood Estimation, I need to define the likelihood function for a uniform distribution. But I am not sure how to define a uniform probability distribution function in Stata. For example, I don’t know how to define the following function or the associated likelihood function in Stata:

f(x)=1 if 0<x<1
=0 otherwise.

I have tried the following commands to define the log-likelihood function of a uniform distribution; however, I think it is NOT an appropriate way to do it since theta is not penalized when it falls outside the interval [0,1]:

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

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.

I appreciate any help or comment in advance.

Thanks,

Mostafa

-----------------------------------------------------------------

Mostafa Beshkar
PhD Candidate
Dept of Economics, Vanderbilt University
Phone: 1(615)522-1775
Fax: 1(615)343-8495
www.people.vanderbilt.edu/~mostafa.beshkar
SSRN page: http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=418146
--
------------------------------------------------------------------------
Bob Hammond
Department of Economics
Vanderbilt University
http://people.vanderbilt.edu/~robert.g.hammond/
*
* 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/