Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down at the end of May, 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 10:46:22 +0000 |

I have run the set trace and it is clear there is a problem with the including an argument within the squared term (I've pasted the relevant part below). I am sure this is the bug but I do not know why Stata doesn't like it. I am confident all the quotations are correct in the program. Many Thanks, Tom - mata: Mopt_search() ------------------------------------------------------------------------------------------------ begin logittest --- - version 12.0 - args lnf b1 b2 x mu - tempvar lng - qui { - gen double `lng' = ln(invlogit(`b1'*((`x'^(1-`rho')-1)/(1-`rho')))) if $ML_y1==1 = gen double __000007 = ln(invlogit(__000006*((^(1-)-1)/(1-)))) if educ1==1 unknown function ^() replace `lng' = ln(invlogit(-`b1'*((`x'^(1-`rho')-1)/(1-`rho')))) if $ML_y1==0 replace `lnf' = `lng' -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: 16 November 2011 10:17 To: 'statalist@hsphsun2.harvard.edu' Subject: RE: st: FW: ML for logit/ologit I don't think the example calls for such a sweeping generalization. People write programs to maximise non-linear functions in Stata [sic] all the time. There is a bug in Thomas' code. I can't spot it and there is a lingering doubt about use of quotation marks from previous posts. Using -set trace- might help him find where it is. Nick n.j.cox@durham.ac.uk Yuval Arbel Several years ago I came across the same problem with estimation of non-linear functions in STATA. The solution I found is to use MATLAB for these objectives of non-linear functions. I believe that compared to STATA, MATLAB will give you a much better flexibility to define non-linear functions. 2011/11/16 Thomas Murray (Department of Economics) <t.l.murray@bham.ac.uk>: > Does anyone have any advice about the problem described below? Thomas Murray (Department of Economics) > I need to use the ML function to create a program for an ordered logit log likelihood function. Before writing the code for the ologit model I've been trying to practice with a computationally simpler logit regression. This is what I've written so far: > > program define logit2_lf > version 10.1 > args lnf xb > tempvar lnlj > qui { > gen double `lnlj' = ln(invlogit( `xb')) if $ML_y1 == 1 replace `lnlj' > = ln(invlogit(-`xb')) if $ML_y1 == 0 replace `lnf' = `lnlj' > } > end > > However, the model I wish to estimate is not simply y = a + bx. > > I want to estimate the following: y = a + b((x^(1-ρ)-1)/(1-ρ)) > > where ρ is a parameter to be determined. > > I have been trying to incorporate this into the logit code above (by replacing the xb function) along the lines of: > > program drop logittest > program define logittest > version 12.0 > args lnf b1 x rho > tempvar lng > qui { > gen double `lng' = ln(invlogit(`b1'*((`x'^(1-`rho')-1)/(1-`rho')))) if $ML_y1==1 replace `lng' = ln(invlogit(-`b1'*((`x'^(1-`rho')-1)/(1-`rho')))) if $ML_y1==0 replace `lnf' = `lng' > } > end > > ml model lf logittest ( y = x) > ml max > > However I get the error 'unknown function ^()' - it doesn't like my attempted manipulation of x using powers. > > My question - is it possible to impose this particular form of x into a logit (or ordered logit) function? Am I just making a computational mistake in my programming language? * * 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/

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

**Re: st: FW: ML for logit/ologit***From:*brendan.halpin@ul.ie (Brendan Halpin)

**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>

- Prev by Date:
**Re: st: Combining strings by group** - Next by Date:
**RE: st: Multinomial Logit Model - Cramer Ridder Test** - Previous by thread:
**RE: st: FW: ML for logit/ologit** - Next by thread:
**Re: st: FW: ML for logit/ologit** - Index(es):