Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Fernando Rios Avila <f.rios.a@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: FW: ML for logit/ologit |
Date | Wed, 16 Nov 2011 08:07:12 -0500 |
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/