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

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

From |
Joe Canner <[email protected]> |

To |
"[email protected]" <[email protected]> |

Subject |
RE: st: RE: RE: Maximum Likelihood |

Date |
Wed, 2 Apr 2014 14:13:05 +0000 |

Maarten, Thanks for the clarification; it makes sense that the culprit would be binary representation of floating point numbers rather than the algorithm itself. It's worth noting that the inaccuracy does not kick in until x gets larger than 7 or so. It's not clear in Hitomi's case whether that will be a problem or not. Moreover, he is actually doing 1-normal(-x)^131 so between negating x and taking the 131st power it's hard to say what the net result will be accuracy-wise. Regards, Joe -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Maarten Buis Sent: Wednesday, April 02, 2014 8:46 AM To: [email protected] Subject: Re: st: RE: RE: Maximum Likelihood On Wed, Apr 2, 2014 at 2:27 PM, Joe Canner wrote: > Tim, I thought the same thing at first about the function names. Apparently, these are outdated versions which are undocumented but still work. For example, normprob() was replaced by normal(). Perhaps the new version solves the accuracy problem that Bill Gould warned about. Not likely, the article (http://www.stata-journal.com/article.html?article=pr0025) already uses the newer names for these functions. Also, it seems more like a problem that is inherrit with the way computers handle numbers, so Stata cannot "solve" this issue. For example, I was able to _exactly_ reproduce the first anamolous example in R (useful whenever someone comes up and claims that Stata is imprecise and R is not). -- Maarten > > Hitomi, see my response on statalist.org regarding a syntax error that may be causing your problem. > > Regards, > Joe Canner > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On Behalf Of Timothy Mak > Sent: Wednesday, April 02, 2014 5:41 AM > To: [email protected] > Subject: st: RE: Maximum Likelihood > > Hi, > > I see a number of strange codings in your codes below: > > 1. I did "search normprob" and "search binorm". Apparently, Stata doesn't have these functions. I suspect this is what Stata is complaining. Perhaps you want "binormal()" and "normal()" instead??? Try typing > > help functions > > to see what are acceptable Stata functions > > 2. Try not to use too many ^ if you can. E.g. ln(x^y) = y*ln(x). e.g. if you type, > > di ln(10^1000) > > you get a missing, but if you type > > di 1000 * ln(10) > > that's ok. > > That's all I can spot now. > > Tim > > -----Original Message----- > From: [email protected] [mailto:[email protected]] On Behalf Of Hitomi Amaya > Sent: 02 April 2014 02:53 > To: [email protected] > Subject: st: Maximum Likelihood > > Hello, > > I defined the following maximum likelihood program for bivariate probit > model. > STATA gave me an error "unknown function 1-()". > I found William Gould of Stata corp mentioning: > "Never code 1-normprob(z). Code instead normprob(-z), which is far more > accurate." > to Deborah who raised a similar question on this STATA list. > > However, as you can see in my code below, I have 1-(normprob(z)^131) instead > of 1-normprob(z). > I cannot easily convert it into a form without using 1-(...). > > I read "Maximum Likelihood Estimation with Stata", but I couldn't find a > solution. > I would very much appreciate it if anyone could come up with a solution to > this problem. > > There is my code (which is a modification of the code written by Antoine, > also found on the STATA list): > > program define mybiprobt > args lnf theta1 theta2 theta3 > tempvar TH > quietly gen double > `TH'=((exp(`theta3')-exp(-`theta3'))/(exp(`theta3')+exp(-`theta3'))) > quietly replace > `lnf'=(ln(binorm(-`theta1',-`theta2',`TH'))-ln((1-(normprob(-'theta2'))^131)^(1/48))) > if $ML_y1==0 & $ML_y2==0 > quietly replace > `lnf'=(ln(binorm(-`theta1',`theta2',-`TH'))-ln((1-(normprob(-'theta2'))^131)^(1/48))) > if $ML_y1==0 & $ML_y2==1 > quietly replace > `lnf'=(ln(binorm(`theta1',-`theta2',-`TH'))-ln((1-(normprob(-'theta2'))^131)^(1/48))) > if $ML_y1==1 & $ML_y2==0 > quietly replace > `lnf'=(ln(normprob(`theta2')-binorm(-`theta1',`theta2',-`TH'))-ln((1-(normprob(-'theta2'))^131)^(1/48))) > if $ML_y1==1 & $ML_y2==1 > end > > Thank you. > Hitomi Amaya > > > > > -- > View this message in context: http://statalist.1588530.n2.nabble.com/Maximum-Likelihood-tp7580502.html > Sent from the Statalist mailing list archive at Nabble.com. > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ -- --------------------------------- Maarten L. Buis WZB Reichpietschufer 50 10785 Berlin Germany http://www.maartenbuis.nl --------------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Maximum Likelihood***From:*Hitomi Amaya <[email protected]>

**st: RE: Maximum Likelihood***From:*Timothy Mak <[email protected]>

**st: RE: RE: Maximum Likelihood***From:*Joe Canner <[email protected]>

**Re: st: RE: RE: Maximum Likelihood***From:*Maarten Buis <[email protected]>

- Prev by Date:
**Re: st: RE: RE: Maximum Likelihood** - Next by Date:
**st: SAS PROC GLIMMIX vs. Stata generalized linear mixed model commands** - Previous by thread:
**Re: st: RE: RE: Maximum Likelihood** - Next by thread:
**st: return null Mata** - Index(es):