Bookmark and Share

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, is already up and running.

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

st: AW: Logit maximum likelihood in mata code

From   "Klaus Pforr" <>
To   <>
Subject   st: AW: Logit maximum likelihood in mata code
Date   Fri, 19 Apr 2013 12:45:07 +0200

Dear Nicholas,

I do not understand your code, but your problem is extensively discussed in
this Stata-Press-book:
You find a working mata-code for your problem here.




Dr. Klaus Pforr
GESIS -- Leibniz Institut für Sozialwissenschaft
Postfach 122155
D - 68072 Mannheim
Tel: +49 621 1246 298
Fax: +49 621 1246 100 

-----Ursprüngliche Nachricht-----
[] Im Auftrag von nick bungy
Gesendet: Freitag, 19. April 2013 09:34
Betreff: st: Logit maximum likelihood in mata code

Dear Statalist,
I'm having trouble setting up the optimizer to find the maximum likelihood
of a logit model. I'm still learning the syntax and set up of mata, though
I've tried to follow 'help mf_optimize' as best I can.
Could someone assist in where I am going wrong with the code?
sysuse auto, clear
void logistic(todo, p, y, x, llf, g, H)
b = p[1,1::2]
One =J(rows(x),1,1)
llf = y'*log(One:/One+exp(-(x*b)))+(One-y)'*log(One:/One+exp(-(x*b)))
 S = optimize_init()
 optimize_init_evaluator(S, &logistic())  optimize_init_params(S, 0)
optimize_init_argument(S, 1, y)  optimize_init_argument(S, 2, x)
 p = optimize(S)
Many thanks,
*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index