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

st: -ml- programming for conditional logit


From   Matthew Wibbenmeyer <mwibbenmeyer@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: -ml- programming for conditional logit
Date   Tue, 17 May 2011 14:04:26 -0600

Greetings,

I am working on building a maximum likelihood estimator for
conditional logit, with the hopes that it can be modified to
accommodate the estimate a non-linear utility function using a choice
experiment data set. So far, I have written a method d0 program (see
below) that matches results from the 'canned' conditional logit.
However, I would like to develop a method d2 program that will run
more reliably and efficiently on more complex utility functions.

Would anyone with experience coding d2 method conditional logit
estimators be willing to share their methods for coding the gradient
and Hessian?
Specifically my confusion comes from how to code the vector of
explanatory variables (not the coefficients), which enters into the
formula for the conditional logit gradient function. Greene (1997)
writes the gradient function as:

g = sum_{i=1,n} sum_{j=1,J} d_ij*(x_ij - xbar_i)

where d_ij = 1 if y_i = j and 0 otherwise, and where xbar_i =
sum_{j=1,J} P_ij*x_ij

x_ij is a vector of values for the explanatory variables in a
particular observation, and it is unclear to me how to code this
within my ml estimator.

Thank you for your help,

Matt Wibbenmeyer
USDA Forest Service
Rocky Mountain Research Station
PO Box 7669
200 E. Broadway
Missoula, MT 59807
---------------------------------------------------------------------------------------------
program myclog
args todo b lnf g negH
tempvar denom p b1
mleval `b1' = `b', eq(1)
qui {
egen double `denom' = sum(exp(`b1')), by(obsid)
gen double `p' = exp(`b1')/`denom'
mlsum `lnf' = $ML_y1*log(`p') if $ML_y1==1
if (`todo'==0 | `lnf'>=.) exit
}
end

ml model d0 myclog (Eq1: choice = x1 x2 x3, nocons)
ml search
ml max
---------------------------------------------------------------------------------------------

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


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