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 on April 23, and its replacement, statalist.org is already up and running.


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

st: question on nested logit


From   "Data Analytics Corp." <walt@dataanalyticscorp.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: question on nested logit
Date   Mon, 03 Sep 2012 13:09:44 -0400

Hi,

I'm experimenting with the nested logit setup for a coffee demand study I want to do. Here's a sample of the data:

+-----------------------------------------------------------------------------------------------------+
| id choice form flavor size price brandc~e brand FLAVORX FORMX SIZEX |
|-----------------------------------------------------------------------------------------------------|
1. | 1 0 BagGr UnLgt 16 2.25 4 Folgers UNFLAVORED BAGGED MEDIUM | 2. | 1 0 BagWh UnMed 20 3 7 SBUX UNFLAVORED BAGGED LARGE | 3. | 1 0 Can UnDK 18 2.75 6 Classico UNFLAVORED CANNED MEDIUM | 4. | 1 0 Pods Hazel 10 3.1 1 DD FLAVORED PODS SMALL | 5. | 1 0 InstCan Van 24 1.75 8 Store FLAVORED INSTANT LARGE |
|-----------------------------------------------------------------------------------------------------|
6. | 1 0 InstSt Other 4 2.5 5 Peet FLAVORED INSTANT SMALL | 7. | 1 0 Mix UnLgt 12 3.25 3 Maxwell UNFLAVORED MIXES MEDIUM | 8. | 1 1 Liq UnMed 8 1.5 2 Godiva UNFLAVORED LIQUID SMALL | 9. | 2 0 BagGr UnDK 16 2.25 4 Folgers UNFLAVORED BAGGED MEDIUM | 10. | 2 0 BagWh Hazel 20 3 7 SBUX FLAVORED BAGGED LARGE |
+-----------------------------------------------------------------------------------------------------+

The data are read from a text file using a Do File which also creates the nested logit tree:

#delimit ;
insheet using "C:\Temp\coffee.txt", clear;
label drop _all;
nlogitgen FLAVORX = flavor(UNFLAVORED: UnLgt | UnMed | UnDK, FLAVORED: Hazel | Van | Other); nlogitgen FORMX = form(BAGGED: BagGr | BagWh, CANNED: Can, INSTANT: InstCan | InstSt, MIXES: Mix, LIQUID: Liq, PODS: Pods); nlogitgen SIZEX = size(SMALL: 4 | 8 | 10, MEDIUM: 12 | 16 | 18, LARGE: 20 | 24);
nlogittree brand FORMX FLAVORX SIZEX, choice(choice);

Stata returns an error message:

. nlogittree brand FORMX FLAVORX SIZEX, choice(choice);
invalid tree structure; input bottom level first
r(198);

Why? No matter how I arrange FORMX, FLAVORX, and SIZEX, I get an error. I want brand to be at the bottom of the tree and it's specified first, as it should be. Everything seems correct. But obviously I'm missing something. Any help?

I'm using Stata 11 on a Windows PC.

Thanks,

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