Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: nested logit model

Subject   st: RE: nested logit model
Date   Tue, 12 Aug 2003 18:51:16 +0200

Hi there,

I will try to suggest the following ,assuming you have a variable called
J=2,3,4,5 and maybe another one Z=1 for the outside choice

sort newid
qui bysort newid: gen choices=3  (if J==4 | J==5)
qui bysort newid: replace choices=2  (if J==2 | J==3)
qui bysort newid: replace  choices=1  (if Z==1)
lab var choices "Options of Choice"

expand 3

sort newid

qui bysort newid: gen temp=_n
qui bysort newid:gen chosen=(temp==choices)
drop choices
rename temp choices
lab var choices "Options of Choice"
lab def choices 1 "Outside" 2 "S1" 3 "S2"
lab val choices choices

nlogitgen type=choices(Outside:1, Other: 2 3)
nlogittree choices type

/***	If you have  explanatory variables, say educ and sex (as binaries)
then you can hold the "Outside" option as the baseline**/

for var educ sex: for Y in new S1: gen XY=X*(choices==2)
for var educ sex: for Y in new S2: gen XY=X*(choices==3)

/***	Here you need something to hold the content of the constant, try **/

gen consC=(type==2)
xi:nlogit chosen (choices = educS1 sexS1 educS2 sexS2) (type = consC),

I hope you find this helpful. Perhaps you can also check the VALUABLE
instructions posted by Weihua Guan ( at


-----Original Message-----
From: Wei Tan []
Sent: Tuesday, 12 August 2003 17:49
Subject: st: nested logit model


I need to estimate a nested logit model including outside alternatives.

In my model, I have four choices, j=2,...5 and an outside alternatives j=1.

I group the four choices to two group S1={3,2} and S2={5,4}

at the upper layer of nest, I have choice 1, S1 and S2.

I used the following command

nlogit chosen (choice=price) /*
		*/ (type2= x), group(newid)  ivc(choicezero=1)

the nest structure shows

type2                  choice
choicezero            1
S1                       2
S2                       4

the program shows an error message

choicezero not found

I guess that my problem is that I did not specify the model correctly. I 
wonder if someone could help me how to specify the correct model.


MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.

*   For searches and help try:
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index