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 |
"Thomas Murray (Department of Economics)" <t.l.murray@bham.ac.uk> |

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

Subject |
RE: st: FW: ML for logit/ologit |

Date |
Wed, 16 Nov 2011 13:49:52 +0000 |

Great this now seems to be working and gives a point estimate of rho which is exactly what I'm looking for. I now just need to replicate this using the ologit instead! Thanks very much for all of your help. -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Fernando Rios Avila Sent: 16 November 2011 13:07 To: statalist@hsphsun2.harvard.edu Subject: Re: st: FW: ML for logit/ologit I just read you needed it to be between 0 and 3, so this should do gen double `rho'=3* exp(`R')/(1+exp(`R')) Just in case, the program will be bounded to 0-3, but the value you will see in the program as result will not. you will need to use a non linear transformation to obtain the actual value of "rho" Check -nlcom- for that On Wed, Nov 16, 2011 at 7:57 AM, Fernando Rios Avila <f.rios.a@gmail.com> wrote: > Hi Thomas > I cought the bug in your program. > THe key is that because u are using a non linear combination of X u > need to declare it in such a way that you can freely manipulate it on > stata. > Check the following code > > program drop logittest > program define logittest > > args lnf b1 rho > tempvar lng > qui { > gen double `lng' = ln(invlogit(`b1'*(($ML_y2^(1-`rho')-1)/(1-`rho')))) > if $ML_y1==1 > replace `lng' = ln(invlogit(-`b1'*(($ML_y2^(1-`rho')-1)/(1-`rho')))) > if $ML_y1==0 > replace `lnf' = `lng' > } > end > > ml model lf logittest (b1:y x=) (rho:), maximize > > for the rho to be bounded between 0 and 1 you can do the following > > program define logittest > > args lnf b1 R > tempvar lng rho > qui { > gen double `rho'=exp(`R')/(1+exp(`R')) gen double `lng' = > ln(invlogit(`b1'*(($ML_y2^(1-`rho')-1)/(1-`rho')))) > if $ML_y1==1 > replace `lng' = ln(invlogit(-`b1'*(($ML_y2^(1-`rho')-1)/(1-`rho')))) > if $ML_y1==0 > replace `lnf' = `lng' > } > end > > ml model lf logittest (y x=) (), maximize init(b) On Wed, Nov 16, 2011 > at 7:23 AM, Nick Cox <n.j.cox@durham.ac.uk> wrote: >> Two completely separate points are bundled together here. >> >> 1. If your program declares that you are feeding it arguments, then those arguments must be supplied (unless you trap non-supply). >> >> 2. A parameter that must be bounded should be re-parameterised so >> that the bounds are respected. Some usual tricks are collected at >> >> http://www.stata.com/support/faqs/stat/interval-constraints.html >> >> logit(rho/3) is unbounded for 0 < rho < 3. >> >> I recommend very detailed study of the documentation on -ml- and the associated book from Stata Press when writing a first non-trivial -ml- program. >> >> Nick >> n.j.cox@durham.ac.uk >> >> Thomas Murray (Department of Economics) >> >> This makes sense - rho needs to be defined in the program. I need rho to converge to a value that maximises the log likelihood. What I want to do is set a range of possible values for rho (between zero and three specifically) and find a point estimate using ML. Is this possible to define? >> >> Nick Cox >> >> You need to supply the right number of arguments too. Here it looks as if rho is undefined because you are not feeding the program with enough arguments. >> >> >> * >> * 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/ >> > * * 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/ * * 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/

**References**:**st: FW: ML for logit/ologit***From:*"Thomas Murray (Department of Economics)" <t.l.murray@bham.ac.uk>

**Re: st: FW: ML for logit/ologit***From:*Yuval Arbel <yuval.arbel@gmail.com>

**RE: st: FW: ML for logit/ologit***From:*Nick Cox <n.j.cox@durham.ac.uk>

**RE: st: FW: ML for logit/ologit***From:*"Thomas Murray (Department of Economics)" <t.l.murray@bham.ac.uk>

**RE: st: FW: ML for logit/ologit***From:*Nick Cox <n.j.cox@durham.ac.uk>

**RE: st: FW: ML for logit/ologit***From:*"Thomas Murray (Department of Economics)" <t.l.murray@bham.ac.uk>

**RE: st: FW: ML for logit/ologit***From:*Nick Cox <n.j.cox@durham.ac.uk>

**RE: st: FW: ML for logit/ologit***From:*"Thomas Murray (Department of Economics)" <t.l.murray@bham.ac.uk>

**RE: st: FW: ML for logit/ologit***From:*Nick Cox <n.j.cox@durham.ac.uk>

**Re: st: FW: ML for logit/ologit***From:*Fernando Rios Avila <f.rios.a@gmail.com>

**Re: st: FW: ML for logit/ologit***From:*Fernando Rios Avila <f.rios.a@gmail.com>

- Prev by Date:
**Re:Re: st: how to keep the pictures** - Next by Date:
**RE: st: RE: nl-function log4-formula** - Previous by thread:
**Re: st: FW: ML for logit/ologit** - Next by thread:
**Re: st: FW: ML for logit/ologit** - Index(es):