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

From |
"Mostafa Beshkar" <mostafa.beshkar@vanderbilt.edu> |

To |
<statalist@hsphsun2.harvard.edu> |

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

Date |
Wed, 2 Apr 2008 11:02:50 -0500 |

Thanks to Stas, Jay and Rodrigo for their comments. I think I should explain my question in more detail, since I think there has been some misunderstanding. I want to estimate the following probability model (this comes from my game-theoretic model): Pr(s=1|X)=Pr(p>BX) Pr(s=0|X)=1-Pr(p>BX) where s is a binary variable, X is the vector of observable variables, B is the vector of parameters to be estimated, and p is an unobservable random varibale that is distributed according to F on the interval [0,1]. I want to use MLE to estimate parameters in B. To do this, I should first make an assumption on the distribution of p. For example, I can assume that p is uniformly distributed over [0,1], that is, f(p)=1 if 0<p<1 =0 otherwise. Here is the stata commands that I hoped to do the job: ------------------------- program myunif args lnf theta quietly replace `lnf' =ln(`BX') if $ML_y1==1 quietly replace `lnf' =ln(1-`BX') if $ML_y1==0 end ml model lf myunif (s = x1 x2 x3 x4) ml maximize ------------------------- Note that X=(x1 x2 x3 x4). The problem that I have with this formulation is that the "program myunif" defines a likelihood function based on the assumption that f(p)=1, while the correct specification is {f(p)=1 if 0<p<1 and f(p)=0 otherwise}. I think this problem can be resolved if I can first define the uniform distribution function, U, in stata and then run the following: ------------------------- program myunif args lnf theta quietly replace `lnf' =ln(U(`BX')) if $ML_y1==1 quietly replace `lnf' =ln(1-U(`BX')) if $ML_y1==0 end ml model lf myunif (s = x1 x2 x3 x4) ml maximize ------------------------- I have a similar problem when I assume that p follows a triangular distribution. Any help would be greatly appreciated. Mostafa -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Stas Kolenikov Sent: Tuesday, April 01, 2008 3:54 PM To: statalist@hsphsun2.harvard.edu Subject: Re: st: Likelihood function of uniform distribution 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/ * * 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:*"Verkuilen, Jay" <JVerkuilen@gc.cuny.edu>

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

**Re: st: Likelihood function of uniform distribution***From:*"Stas Kolenikov" <skolenik@gmail.com>

- Prev by Date:
**st: RE: RE: Likelihood function of uniform distribution** - Next by Date:
**Re: st: do editor (resized) pinned to always on top** - Previous by thread:
**Re: st: Likelihood function of uniform distribution** - Next by thread:
**RE: st: Likelihood function of uniform distribution** - Index(es):

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