# Re: AW: st: AW: AW: conditional logit problem

 From Isabelle.Roux@ehess.fr To statalist@hsphsun2.harvard.edu Subject Re: AW: st: AW: AW: conditional logit problem Date Fri, 27 Mar 2009 14:09:22 +0100 (CET)

```Dear Annalisa,

Sorry for adding trivial points. I'm not econometrician and discovered the
difference few time ago...However  I think that you raised an important
Stata question. If I find intersting commands, I will send it to the
Statalist

Best

Dear Isabelle,
>
> many thanks for your e-mail.
> Maybe I didn't express myself very well. I know the difference between the
> nested logit and the conditional logit.
> I was just wondering if there is a "technical" difference in terms of
> stata
> commands and outputs since we get the same problem.
> I am relatively new in estimating in Stata, so probably I don't know the
> possible solutions in terms of commands, but I know the theoretical
> differences across the methods.
>
> Best,
>
> Annalisa
>
>
> --On 27 March 2009 12:35 +0100 Isabelle.Roux@ehess.fr wrote:
>
>> Dear Martin and Annalisa,
>>
>> For me the difference between the conditional mixed model, which is
>> mine,
>> and the nested model, is that the second is "sequential", and the not
>> the
>> first.
>> For example, the typic issue solved thanks to the conditional logit is
>> "explain the transport choices of individuals: take the bus, or the car,
>> or walk". The nested logit explains sequential choices. For example,
>> first
>> choose between the car and the bus, the between the blue car and the red
>> car (or for an economic example: first the firm decide to export or to
>> do
>> a FDI, second the country of the FDI.)
>>
>> Martin, indeed I have the Stata10 version, but only the Stata8 manual !
>> So
>> I will try the "xtmelogit" command, thank you.
>> If Annalisa is economist, (and even if she is not), a very good example
>> of
>> nested logit can be found here:
>> http://www.cepii.fr/anglaisgraph/workpap/summaries/2007/wp07-07.htm
>>
>>> Dear Martin,
>>>
>>> my problem is that I should estimate a nested (mixed) multinomial logit
>>> model. It seems the xtmelogit command does not allow to run multinomial
>>> logit models.
>>> I am estimating a RUM so stata 10 seems more appropriate to my model
>>> than
>>> stata 8, but I cannot sort out the problem and I also received messages
>>> like the one's Isabelle received. I also tried to interact the
>>> variables
>>> like Isabelle is suggesting, but it didn't work.
>>>
>>> Maybe Isabelle's problem is different from mine.
>>> I have been spending several time on the commands, but I didn't find a
>>> solution to get a correct estimate, maybe because I am new to the
>>> nested
>>> logit.
>>> I checked on the Stata manual, Stata help the Cameron and Trivedi's
>>> book
>>> "Microecnometrics using stata", their website and several other
>>> documents, but I could not find a command.
>>> Maybe this is just a problem linked to a nested logit. That's why I am
>>> planning to estimate it by programming myself the ML.
>>>
>>> I replied to Isabelle's message because it seems that the problems are
>>> strictly correlated, but I talked on the base of my experience.
>>>
>>> If you have any suggestions are more than welcome!
>>>
>>> Best,
>>>
>>> Annalisa
>>>
>>>
>>>
>>> --On 27 March 2009 11:39 +0100 Martin Weiss <martin.weiss1@gmx.de>
>>> wrote:
>>>
>>>>
>>>> <>
>>>>
>>>> Annalisa,
>>>>
>>>> what is the difference between your proposal and -xtmelogit-? One
>>>> difference for Isabelle obviously would be that Stata 8 does not
>>>> provide
>>>> her with this commmand, as it was, AFAIK, introduced in Stata 10. But
>>>> she
>>>>
>>>>
>>>>
>>>> HTH
>>>> Martin
>>>>
>>>>
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: owner-statalist@hsphsun2.harvard.edu
>>>> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Annalisa
>>>> Marini Gesendet: Freitag, 27. März 2009 11:35
>>>> An: statalist@hsphsun2.harvard.edu
>>>> Betreff: Re: st: AW: AW: conditional logit problem
>>>>
>>>> Dear Isabelle,
>>>>
>>>> If I am not wrong you have a mixed logit. I am also working on a mixed
>>>> logit by using stata and I think one solution (I am also starting to
>>>> use)
>>>> is that of programming yourself the ML rather than using stata
>>>> commands.
>>>>
>>>> If anyone has other (better and wuicker) suggestions are more than
>>>> welcome  since I have been spending a lot of time on these nested
>>>> logit
>>>> commands!
>>>>
>>>> Many thanks.
>>>>
>>>> Annalisa
>>>>
>>>>
>>>> --On 27 March 2009 11:28 +0100 Isabelle.Roux@ehess.fr wrote:
>>>>
>>>>> Thank you very much Martin, for your very useful help.
>>>>>
>>>>> -First of all I just had a look at "va" and you were right: there is
>>>>> a
>>>>> pb
>>>>> with it because sometimes I have different va for a same firm. So I
>>>>> have
>>>>> to check how I obtained it and to improve that.
>>>>>
>>>>> -Secondly I sought in the STATA8 manual, which explains that
>>>>> individual
>>>>> variables (like va, or sex if the observations were human), have to
>>>>> be
>>>>> multiplied by dummy variables for the choices:
>>>>>
>>>>> it is the beginning of the example's dataset in the manual:
>>>>> id     car        choice     dealer      sex     income
>>>>> 1      American     0           18       male     46
>>>>> 1      Japan        0            8       male     46
>>>>> 1      Europe       1           5        male      46
>>>>>
>>>>> 2      American     0           17       male     26
>>>>> 2      Japan        1           6        male     26
>>>>> 2      Europe       0           2        male      26
>>>>>
>>>>> "car": nationality of the car's manufacturer
>>>>> "dealer": number of dealerships of each nationality in the consumer's
>>>>> city
>>>>>
>>>>> ***
>>>>> gen japan=(car==2)
>>>>> gen europe=(car==3)
>>>>> gen sexeur=sex*japan
>>>>> gen sexjap=sex*jap
>>>>> gen incjap=income*japan
>>>>> gen inceur=income*europe
>>>>> ***
>>>>>
>>>>> and to run :
>>>>>
>>>>> ***
>>>>> clogit choice japan europe sexjap sexeur incjap inceur delaer,
>>>>> grou(id)
>>>>> ***
>>>>>
>>>>>
>>>>> But I am a bit afraid of doing that, because in all I have 66
>>>>> countries,
>>>>> and  7 firm's variables, so, even if I keep only 2 or 3 firm's
>>>>> variables,
>>>>> there will be a lot of dummies in my results.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>
>>>>>> <>
>>>>>>
>>>>>> One thing for Isabelle to consider: When I replace just one value of
>>>>>> va
>>>>>> with
>>>>>> "0" during the -input-, the message does not appear for "va", but
>>>>>> for
>>>>>> "ln(va)". So Isabelle might want to check her data set and maybe
>>>>>> report
>>>>>> -inspect va- to the list...
>>>>>>
>>>>>>
>>>>>>
>>>>>> HTH
>>>>>> Martin
>>>>>>
>>>>>>
>>>>>> -----Ursprüngliche Nachricht-----
>>>>>> Von: owner-statalist@hsphsun2.harvard.edu
>>>>>> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Martin
>>>>>> Weiss Gesendet: Freitag, 27. März 2009 10:10
>>>>>> An: statalist@hsphsun2.harvard.edu
>>>>>> Betreff: st: AW: conditional logit problem
>>>>>>
>>>>>>
>>>>>> <>
>>>>>>
>>>>>> Actually, Stata complains whether you enter "va" or its log into
>>>>>> -clogit-: "
>>>>>> note: ... omitted because of no within-group variance." It would be
>>>>>> weird for the log transform to change the effect of va as the
>>>>>> transform
>>>>>> itself cannot generate any variance within the groups.
>>>>>>
>>>>>> The problem is mentioned in [R]clogit, p. 284.
>>>>>>
>>>>>> *************
>>>>>> clear*
>>>>>> inp double siren   va  str10 country   tax    double  GDP   choice
>>>>>> 17251067     94997     Spain        .35     777000000000       1
>>>>>> 17251067     94997     Brazil       .34     486000000000      0
>>>>>> 17251067     94997     Italy        .38    1330000000000     0
>>>>>> 17251068   28142     Brazil       .34     486000000000       1
>>>>>> 17251068   28142    Spain       .35     777000000000       0
>>>>>> 17251068   28142    Italy        .38    133000000000       0
>>>>>> 17251069     75758    Italy        .38    13300000000       1
>>>>>> 17251069     75758    Spain        .35    777000000000      0
>>>>>> 17251069     75758     Brazil        .34    486000000000      0
>>>>>> end
>>>>>> l, noo sepby(va)
>>>>>> g lntax=log(tax)
>>>>>> g lnGDP=log(GDP)
>>>>>> encode country, gen(newcountry)
>>>>>> drop country
>>>>>> rename newcountry country
>>>>>> * w/o va
>>>>>> clogit choice country lntax lnGDP , group(siren) iter(10) nolog
>>>>>> *with va
>>>>>> clogit choice country lntax lnGDP va, group(siren) iter(10) nolog
>>>>>> g lnva=log(va)
>>>>>> *with ln(va)
>>>>>> clogit choice country lntax lnGDP lnva, group(siren) iter(10) nolog
>>>>>> *************
>>>>>>
>>>>>> Might -asclogit- be a way out for Isabelle?
>>>>>>
>>>>>> HTH
>>>>>> Martin
>>>>>>
>>>>>>
>>>>>> -----Ursprüngliche Nachricht-----
>>>>>> Von: owner-statalist@hsphsun2.harvard.edu
>>>>>> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von
>>>>>> Isabelle.Roux@ehess.fr
>>>>>> Gesendet: Freitag, 27. März 2009 09:42
>>>>>> An: statalist@hsphsun2.harvard.edu
>>>>>> Betreff: st: conditional logit problem
>>>>>>
>>>>>> Dear statalisters,
>>>>>>
>>>>>> I have  a dataset with firms, to which is attributed a number called
>>>>>> "siren", and characteristics of thses firms (exportations, size,
>>>>>> value
>>>>>> added...). I have too the country in which they decide to invest,
>>>>>> and
>>>>>> characteristics of this country (GDP, population, tax rate, labor
>>>>>> costs...)
>>>>>>
>>>>>> So my database looks like this (it is an example with 3 firms which
>>>>>> choose one unique country):
>>>>>> siren	   va	   country     tax	    GDP          choice
>>>>>> 17251067	   94997	   Spain	      .35	    7.77e+11
>>>>>> 1
>>>>>> 17251067	   94997	   Brazil	      .34	    4.86e+11
>>>>>> 0
>>>>>> 17251067	   94997	   Italy        .38    1.33e+12      0
>>>>>>
>>>>>> 3.025e+08   28142	   Brazil	      .34	    4.86e+11       1
>>>>>> 3.025e+08   28142    Spain	      .35	    7.77e+11       0
>>>>>> 3.025e+08   28142    Italy        .38    1.33e+12       0
>>>>>>
>>>>>> 3.026e+08	   75758    Italy        .38    1.33e+12       1
>>>>>> 3.026e+08	   75758    Spain	       .35    7.77e+11       0
>>>>>> 3.026e+08	   75758 	   Brazil	       .34    4.86e+11
>>>>>> 0
>>>>>>
>>>>>>
>>>>>> When I run a conditional logit with only countries'characteristics
>>>>>> as
>>>>>> regressors (***clogit choice country lntax lnGDP, group(siren)**,
>>>>>> where
>>>>>> lntax and lnGDP are the log of tax and GDP), it is OK.
>>>>>> But what I don't understand is this point:
>>>>>>
>>>>>> -When I add value added as a control variable (***clogit choice
>>>>>> country
>>>>>> lntax lnGDP va, group(siren)***), it works, even if the coefficient
>>>>>> for
>>>>>> va is strange.
>>>>>> -When I add the log of value added as a control variable ((***clogit
>>>>>> choice country lntax lnGDP lnva, group(siren)***), STATA refuses to
>>>>>> provide results and write:"outcome does not varies in any group".
>>>>>>
>>>>>> So I wonder why it is ok in a case and not in the other else which
>>>>>> is
>>>>>> very similar, and I don't know what kind of logit to run which
>>>>>> allows
>>>>>> me
>>>>>> to mix the two types of variables.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thank you very much for help,
>>>>>>
>>>>>> Isabelle
>>>>>>
>>>>>>
>>>>>> *
>>>>>> *   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/
>>>>>>
>>>>>>
>>>>>> *
>>>>>> *   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/
>>>>>>
>>>>>>
>>>>>> *
>>>>>> *   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/
>>>>>>
>>>>>
>>>>>
>>>>> *
>>>>> *   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/
>>>>
>>>>
>>>>
>>>> ----------------------
>>>> Annalisa Marini
>>>> Department of Economics
>>>> University of Bristol
>>>> Bristol BS8 1TN
>>>> United Kingdom
>>>>
>>>> e-mail: annalisa.marini@bristol.ac.uk
>>>>
>>>> *
>>>> *   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/
>>>>
>>>>
>>>> *
>>>> *   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/
>>>
>>>
>>>
>>> ----------------------
>>> Annalisa Marini
>>> Department of Economics
>>> University of Bristol
>>> Bristol BS8 1TN
>>> United Kingdom
>>>
>>> e-mail: annalisa.marini@bristol.ac.uk
>>>
>>> *
>>> *   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/
>>>
>>
>>
>> *
>> *   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/
>
>
>
> ----------------------
> Annalisa Marini
> Department of Economics
> University of Bristol
> Bristol BS8 1TN
> United Kingdom
>
> e-mail: annalisa.marini@bristol.ac.uk
>
> *
> *   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/
>

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