Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: mixlogit
From
Ragnhild Røhme fjærtoft <[email protected]>
To
[email protected]
Subject
Re: st: mixlogit
Date
Mon, 23 Sep 2013 20:27:01 +0200
Than you so much for your fast and informative replay. With your
suggestions, I was able to estimate my model.
I noted, however that you, in your syntax "swithched" from year as the
"id" variable to idnr. Can you explain to me the reason for this?
Does your syntax mean that Stata "understand" that it is the same
individuals that are observed on several occations?
Can I also ask you a question regarding the number of Halton
sequences? The default is 50, but would you recomend increasing it?
Best regards
Ragnhild
On Mon, Sep 23, 2013 at 12:51 PM, Arne Risa Hole <[email protected]> wrote:
> Hi Ragnhild,
>
> I think the first problem is related to your id variables - the rest
> of the code looks fine as far as I can see.
>
> Remember that the "group" variable must be a unique id for every
> choice set. You can try the following code:
>
> egen csid = group(idnr year)
>
> mixlogit choice a2male a3male a4male, group(csid) rand(a2 a3 a4) id(idnr)
>
> When running the correlated model it''s not necessary to supply a
> matrix of starting values (though it can speed up the estimation) so
> if you're not sure how to do it you can skip this step.
>
> Hope this helps.
>
> Arne
>
> On 20 September 2013 10:43, Ragnhild Røhme fjærtoft
> <[email protected]> wrote:
>> Hello,
>>
>> I have two problems related to estimating a multinomial logit model
>> with unobserved heterogeneity by the command mixlogit in Stata12 as
>> done in Arne Hole’s paper in The Stata Journal (2007) 7, Number 3.
>>
>> I have an unbalanced data panel covering the years 1999-2007 with
>> doctors as observation units. There is one record for each doctor in
>> the years they are observed. In each year the doctors can chose
>> between four different practice types, defined by the variable
>> job_port which takes on values 1-4 after choice of practice type.
>> Idnr identifies the doctors while year identifies the time of choice.
>> I have only individual-specific variables
>>
>> My first problem relates to the preparation of the dataset for it to
>> be suitable for using with mixlogit. I set choice alternative one as
>> the reference alternative. I get the error message; "At least one
>> group has more than one chosen alternative". I do not get this message
>> when running separate regressions for each year.
>>
>> I do the following;
>>
>> expand 4
>> by idnr year, sort:gen alt=_n
>> gen choice=alt==job_port
>> gen a2=(alt==2)
>> gen a3=(alt==3)
>> gen a4=(alt==4)
>>
>> I then construct variables for each alternative, here exemplified with
>> three explanatory variables age (the doctors age), male (dummy for
>> being male) and married (dummy for being married)
>>
>> gen a2male=a2*male
>> gen a3male=a3*male
>> gen a4male=a4*male
>>
>> gen a2age=a2*age
>> gen a3age=a3*age
>> gen a4age=a4*age
>>
>> gen a2married=a2*married
>> gen a3married=a3*married
>> gen a4married=a4*married
>>
>> I the use the following syntax to run the model
>>
>> mixlogit choice a2male a3male a4male a2age a3age a4age a2married
>> a3married a4married, group(idnr) rand(a2 a3 a4) id(year)
>>
>> My second problem relates to estimation the final coefficients when
>> the random intercepts are correlated
>> After running the model (separate regressions for each year), I type
>> matrix b=b(e)
>> In Hole’s article, the next step is to compute a matrix which in the article is
>> matrix b = b[1,1..5],0,b[1,6]. I struggle to adapt the computation of
>> this matrix to my data.
>>
>> I would highly appreciate answers to my problems.
>>
>> Best regards
>>
>> Ragnhild Røhme Fjærtoft
>>
>> *
>> * For searches and help try:
>> * http://www.stata.com/help.cgi?search
>> * http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/