Bookmark and Share

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]

st: Maximum Likelihood Programming


From   Müller Tobias <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Maximum Likelihood Programming
Date   Thu, 20 Feb 2014 19:35:25 +0000

Hello everybody,
 
I’m a starter in Maximum Likelihood (ML) programming in Stata – so far I was able to write a ML 
evaluator program for the probit/logit models. Here’s the code that I use:
 
clear all

sysuse auto.dta
 
*****************
*** PROBIT ***
*****************
program myprobit
version 11.0
args lnf beta1
quietly replace `lnf' = ln(normal(`beta1')) if $ML_y1 == 1
quietly replace `lnf' = ln(normal(-`beta1')) if $ML_y1 == 0
end
 
ml model lf myprobit (foreign = price)
ml search //* searches for better intial values *//
ml maximize
 
probit foreign price
 
 
***************
*** LOGIT ***
***************
program mylogit_lf 
version 11.0
args lnf xb
quietly replace `lnf' = ln(exp(`xb')/(1+exp(`xb'))) if $ML_y1 == 1
quietly replace `lnf' = ln(1-exp(`xb')/(1+exp(`xb'))) if $ML_y1 == 0
end 
 
ml model lf mylogit_lf (foreign = price)
ml search
ml maximize
 
logit foreign price
 
In a next step I’m trying to do the same for the Multinomial Logit (MNL)! Can anyone give me some advice (preferably code) here? How to code the log-likelihood contributions in case of the MNL? 
 
Thanks in advance, Tobias
 



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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index