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: question concerning mlsum for ml with panel-data
From
"Jakusch, Sven-Thorsten" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: question concerning mlsum for ml with panel-data
Date
Fri, 20 Apr 2012 19:04:17 +0200
Dear members of statalist,
sorry for reposting some parts of some text i send some days ago, but i´m afraid it was not detailed enough. Besides, i´m a bit desperate..
I´m struggling since several weeks with a problem concerning the mlsum command in the ml-environment and i have no clue what i did wrong:
I try to perform a panel-data probit likelihood estimation to unravel the preference parameters of investors. The original dataset is similar to the structure in Gould, Pitblado and Sribney (2006) “Maximum Likelihood Estimation with Stata”, p. 110. I intend to generate “sub”-log-likelihood functions at the end of each observation of “Choice” for each security and aggregate the sum of these log-likelihoods at group-level usinf "mlsum".
A sketch of my attempts looks like this (I´m using a stata 10.0 version) with utility_diff=function of(alpha, lambda, gamma))
.....
program define ML_My_problematic_model_1 // define maximum likelihood program for the panel dataset
args todo b lnf //define variables and coefficient vector b
tempvar alpha lambda gamma last lj **some more variables** utility_diff
mleval `alpha' = `b', eq(1)
mleval `lambda' = `b', eq(2)
mleval `gamma' = `b', eq(3) //Variables of interest are alpha, lambda and gamma
quietly { **contains more or less specifications of the model**
by security_ID: gen double `utility_diff'=`utility_alternative_2' -`utility_alternative_1' //here I tried to generate the sub-likelihood functions for each security_ID (in line with Harrison (2008) as mentioned above)
by security_ID: gen byte `last'=_n==_N //construct likelihood for utility difference under iid assumption:
gen double `lj'=.
by security_ID: replace `lj' =(normal(`utility_diff')) if $ML_y1==0
by security_ID: replace `lj' =(normal(-`utility_diff')) if $ML_y1==1
mlsum `lnf' = ln(`lj') if `last'==1 //sum the added likelihood functions at the end of each security_ID
if (`todo'==0 | `lnf'>=.) exit
}
end
.....
My problem is now, that while trying to sum them up with mlsum returns only a likelihood function of 0 or an algorithm that generates an error message, stating that numerical derivatives are flat or not obtainable- no matter what I do. The ml check works fine and indicates no serious issues.
The outputof the program above looks like this:
initial: log likelihood = -<inf> (could not be evaluated)
feasible: log likelihood = 0
rescale: log likelihood = 0
rescale eq: log likelihood = 0
(setting optimization to DFP)
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
Iteration 0: log likelihood = 0
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
Iteration 1: log likelihood = 0
numerical derivatives are approximate
flat or discontinuous region encountered
numerical derivatives are approximate
flat or discontinuous region encountered
. ml display
Number of obs = 1564
Wald chi2(0) = .
Log likelihood = 0 Prob > chi2 = .
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
alpha |
_cons | -.5 . . . . .
-------------+----------------------------------------------------------------
lambda |
_cons | -.5 793.6529 -0.00 0.999 -1556.031 1555.031
-------------+----------------------------------------------------------------
gamma |
_cons | -.5 . . . . .
------------------------------------------------------------------------------
A similar program that i wrote for a two-security-case generates an output for the same dataset like this:
initial: log likelihood = -<inf> (could not be evaluated)
feasible: log likelihood = -1059.786
rescale: log likelihood = -1059.786
rescale eq: log likelihood = -1027.9832
(setting optimization to DFP)
Iteration 0: log likelihood = -1027.9832
Iteration 1: log likelihood = -1027.7447 (backed up)
Iteration 2: log likelihood = -1027.5696
Iteration 3: log likelihood = -1027.4468
Iteration 4: log likelihood = -1026.6417
(switching optimization to Newton-Raphson)
Iteration 5: log likelihood = -1026.6203
Iteration 6: log likelihood = -1026.6203
. ml display
Number of obs = 782
Wald chi2(0) = .
Log likelihood = -1026.6203 Prob > chi2 = .
------------------------------------------------------------------------------
| Coef. Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
alpha |
_cons | .4306489 .0745162 5.78 0.000 .2845999 .576698
-------------+----------------------------------------------------------------
lambda |
_cons | -.6196399 .1814276 -3.42 0.001 -.9752314 -.2640483
-------------+----------------------------------------------------------------
gamma |
_cons | .9426656 .1456149 6.47 0.000 .6572657 1.228065
------------------------------------------------------------------------------
As its the same dataset just with a different ordering ( in the latter case each securities are side-by-side) i tried to align both programs such that the former produces this output- but without success..
Please, can anyone help me and tell me what i did wrong?
I really appreciate some hints!
Thank you very much!
Sven
Sven-Thorsten Jakusch
Lehrstuhl für BWL, insbesondere Finanzen - Prof. Dr. Andreas Hackethal
House of Finance | Grüneburgplatz 1 | 60323 Frankfurt am Main
Tel.: + 49 (0)69 798-33677
*
* 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/