Date: Tue, 26 Nov 2002 15:58:48 -0800
Reply-To: Dale McLerran <stringplayer_2@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Dale McLerran <stringplayer_2@YAHOO.COM>
Subject: Re: Need help on nested logit model!!
In-Reply-To: <7a5ed11d.0211251908.89b956@posting.google.com>
Content-Type: text/plain; charset=us-ascii
Le W,
Note my comment at the close of my first reply "I would caution
that the MDC procedure does not allow you to fit models in which
there are multiple instances of the response for each subject..."
My comment and the SAS issued statement "the choice variable must
not contain redundant choices for each decision maker" sound very
much like the same statement. Say that you had data such as the
following, where the individual with ID=1 makes two choices
among the four brands, those two choices being made on two
separate occasions:
brand1 brand2 brand3 brand4 price1 price2 price3 price4 ID occasion
1 0 0 0 3 4 1 2 1 1
0 1 0 0 3 2 1 2 1 2
0 1 0 0 3 4 1 2 2 1
...
You might be tempted to convert these data into the form shown
below for use in the MDC procedure:
ID SELECT BRAND PRICE occasion
1 1 1 3 1
1 0 2 4 1
1 0 3 1 1
1 0 4 2 1
1 0 1 3 2
1 1 2 2 2
1 0 3 2 2
1 0 4 1 2
2 0 1 3 1
2 1 2 4 1
2 0 3 2 1
2 0 4 1 1
...
But if you pass these data into the MDC procedure, you should
expect SAS to scream at you that a decision maker (ID=1) has
made more than one choice, and that this is not allowed by the
MDC procedure. Note that the documentation for the MDC
procedure states right at the beginning of the "Getting Started"
section that "Each individual is allowed to choose one and only
one of the possible alternatives." I suspect that you have
violated this.
And yes, there is a problem with your code as shown below. But
I have said enough already for what has every appearance of
being a student assignment. Until I am convinced otherwise
that this is more than a student assignment, I will not offer
further assistance. Sorry.
Dale
p.s. You provided only a brief sketch of the problem and the
layout of the data. That smacks of Student Assignment. If you
provide more detail about the problem, I might be willing to
reconsider whether it has the appearance of a student assignment.
--- wly <perfectle@HOTMAIL.COM> wrote:
> Hi,Dale,
> thanks a lot!
>
> but i am still a little bit confused about the data for nested logit
> model(nlogit). is that form of nlogit same as one of clogit? because
> everytime when i run my program, the log file indicated that "the
> choice variable must not contain redundant choices for each decision
> maker".
>
> i write the code as follows:
> ---------------------------------------------------------------------
> proc mdc data=test type=nlogit ;
> model decision = price/choice=(brand);
> id id;
> utility u(1,)= price;
> nest level(1)=(2 @ 1,1 3 4 @ 2),
> level(2)=(1 2 @1);
> run;
>
> ------------------------------------------------------------------
>
> anything wrong with my code??
> thanks again!
>
> Le W
>
> -------------------- original MSG ----------------------
> stringplayer_2@YAHOO.COM (Dale McLerran) wrote in message
> news:<20021125172638.80745.qmail@web21109.mail.yahoo.com>...
> > The following datastep will construct a dataset which can be
> > passed into the MDC procedure.
> >
> > data newdata;
> > set olddata;
> > array choices {4} brand1-brand4;
> > array pricebrand {4};
> > id = _n_';
> > do brand=1 to 4;
> > select = choices{brand};
> > price = pricebrand{brand};
> > output;
> > end;
> > keep id select brand price;
> > run;
> >
> > The result will be a dataset which looks like this:
> >
> > ID SELECT BRAND PRICE
> > 1 1 1 3
> > 1 0 2 4
> > 1 0 3 1
> > 1 0 4 2
> > 2 0 1 ...
> > 2 ... 2 ...
> > 2 ... 3 ...
> > 2 ... 4 ...
> >
> >
> > As far as providing you detail as to how to construct the code
> > for the MDC procedure, I prefer to allow students to look at the
> > documentation and puzzle over things for a while, consult with
> > other students as the situation warrants, or confess to their
> > professors that they just don't know how to complete the
> > assignment and would the professor be so kind as to spend a
> > little time clarifying some confusion or suggest what the student
> > might look at to get a better understanding of how to proceed.
> > I will point you to the online PDF documentation for the MDC
> > procedure:
> >
> > http://www.sas.com/rnd/app/papers/mdc.pdf
> >
> > The online PDF documentation for the QLIM procedure is at:
> >
> > http://www.sas.com/rnd/app/papers/qlim.pdf
> >
> >
> > By the way, I was not aware of the (relatively) new MDC or QLIM
> > procedures, and so I searched the SAS web site for these keywords.
> > It took me all of 5 minutes to perform the search and read
> > enough of the documentation to answer the first of your questions.
> > I have fitted my own multinomial discrete choice models in the
> > past, and know enough about the structure of such models that it
> > did not take me long to review the documentation. I would
> > caution that the MDC procedure does not allow you to fit models
> > in which there are multiple instances of the response for each
> > subject, but I don't think that you will be getting into such
> > complexities right away.
> >
> > Dale
> >
> >
> > --- wly <perfectle@HOTMAIL.COM> wrote:
> > > hi,there,
> > > i got a data arranged as the following form:
> > >
> > > brand1 brand2 brand3 brand4 pricebrand1 pricebrand2 pricebrand3
> > > pricebrand4
> > > 1 0 0 0 3 4 1
> 2
> > > 0 . . . . . .
> .
> > > . . . . . . .
> .
> > >
> > > because it seems to me that it's very diffcult to rearrange this
> data
> > > for the form needed in SAS, anybody can tell me how to do that
> and
> > > analysis this daat with PROC MDC or PROC QLIM ?? examples in
> detail
> > > will be deeply appreciated!
> > >
> > > thanks a lot!!
> >
> >
> > =====
> > ---------------------------------------
> > Dale McLerran
> > Fred Hutchinson Cancer Research Center
> > mailto: dmclerra@fhcrc.org
> > Ph: (206) 667-2926
> > Fax: (206) 667-5977
> > ---------------------------------------
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
> > http://mailplus.yahoo.com
=====
---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra@fhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com