Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: Problems with a conditional logit model using Stata's ml language!

From   Peter Grand <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: Problems with a conditional logit model using Stata's ml language!
Date   Sun, 18 Mar 2012 16:17:15 +0000

Dear Statalisters!

I am trying to estimate a conditional logistic regression model using Stata's ml language.  I want to build a unified model of individual abstention and vote choice and analyze two different motivations for abstention - alienation and indifference. The model has one dependent variable the vote-choice and three equations, one for vote-choice, one for the alienation-threshold and one for the indifference-threshold. (It is exactly this model: ).

My data is in long format, i.e. each datum point is either a political party or abstention and those choices are clustered within individuals. I wrote a d0-evaluator because of the alternative-specific format of the dataset.

However, the evaluator is not able to maximize the log-likelihood function and I have no clue why! Further, I am only a beginner in programming ml evaluators in Stata!

Could anyone please help me with this problem, any suggestions are more than welcomed!

Thank you very much in advance.


Peter Grand
Institute for Advanced Studies
Stumpergasse 56
1060 Vienna

Here is my evaluator:

------------------------------------------------Begin Evaluator------------------------------------------------
program clogit_abstention;
version 11.2 ;
* A d0-evaluator because of the alternative-specific dataset (no closed-form!) ;
args todo b lnf;
tempvar xb temp1 temp2 temp3 sum_Vij sum_Vij_temp sum_Vik P_ij last ll alienation indifference;
mleval `xb'=`b', eq(1) ;
mleval `alienation'=`b', eq(2) ;
mleval `indifference'=`b', eq(3) ;
* Defining the panel/id variable ;
local by $MY_panel ;
quietly {;
gen double `temp1'=exp(`xb');
gen double `temp2'=exp(`alienation');
gen double `temp3'=exp(exp(`indifference')); 
sort `by' ; 
* Generating indicator variable for last observation of a panel ;
by `by': gen byte `last'=(_n==_N) ;
* Calculating deterministic part/representative utility (Train 2003/2009) ;
by `by': gen double `sum_Vij_temp'=sum(`temp1') ;
* The following line makes the sum of V_ij a constant over all obs of an individual ;
by `by': egen double `sum_Vij'=max(`sum_Vij_temp') ;
gen double `sum_Vik'=(`sum_Vij'-`temp1') ;
* If voted for a specific party, i.e. $ML_y1==1, ll becomes (`temp1'/(`temp1'+(`temp3'*`sum_Vik')+`temp2')) ;
by `by' : gen double `P_ij'=(`temp1'/(`temp1'+(`temp3'*`sum_Vik')+`temp2')) ;
by `by' : gen double `ll'=ln(`P_ij') if $ML_y1==1;
* If the individual abstains, i.e. abst==1, ll becomes (1-sum(`temp1'/(`temp1'+(`temp3'*`sum_Vik')+`temp2')) ;  
by `by' : replace `ll'=(1-sum(`P_ij')) if abst==1 ;
* Add up all individual likelihoods at the last observation if individual abstains and at the observation an individual voted for ;
mlsum `lnf'=`ll' if `last'==1 | $ML_y1==1;
 } ;

-------------------------------------------------End Evaluator-------------------------------------------------

Here is the call of the evaluator:

-------------------------------------------------Begin Call-------------------------------------------------

global MY_panel id ; // defining the panel variable ;
ml model d0 clogit_abstention (Eq1: vote_choice_eu=u_pr_eu pid) (Eq2: ees_polsoph_eu) (Eq3: ees_polsoph_eu, nocons);
ml check ;
ml search ;
ml maximize, difficult ;

--------------------------------------------------End Call--------------------------------------------------

And here is the output from Stata:

--------------------------------------------------Begin Output--------------------------------------------------

Stata is going to search for a feasible set of initial values. 
If clogit_abstention is broken, this will not work and you will have to press
Break to stop the search.

initial:       log likelihood =     -<inf>  (could not be evaluated)
searching for feasible values ..............................................................................
> ................................--Break--

---------------------------------------------------End Output---------------------------------------------------

*   For searches and help try:

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