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: AW: st: gllamm, multilevel conditional logit
From
Jonas Krüger <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: AW: st: gllamm, multilevel conditional logit
Date
Wed, 27 Nov 2013 23:35:31 +0100
As far my knowledge regarding gllamm your structure needs to look like this.
looked up here http://www.biostat.jhsph.edu/~fdominic/teaching/bio656/software/gllamm.manual.pdf
(page 21,24)
for example:
id(level3) id(level2) alt response choice
1 1 0 1 0
1 1 1 1 1
1 1 2 1 0
1 2 0 0 1
1 2 1 0 0
1 2 2 0 0
2 3 0 1 0
2 3 1 1 1
2 3 2 1 0
With your other questions I cant help you.
On Wed, Nov 27, 2013 at 8:48 PM, <[email protected]> wrote:
> This is the data-structure concerning your question. For observation with id == 1 there are 3 lines which equals the number of alternatives.
> ---------------------------
> id alt choice
> ---------------------------
> 1 1 0
> 1 2 0
> 1 3 1
>
> 2 1 0
> 2 2 1
> 2 3 0
> ...
>
> This is in line with the gllamm-help file: "the 'response' labels the original lines of data". If I do specify the hierarchical structure with "i(region) instead of "i(id region)", I would get a 2-level-model. The N on level 1 would equal all observations (lines) and the N on level 2 are the number of regions. The "id"-variable therefore has to be used to take the clustering of the data into account.
>
> With the definition in my example, I estimate a 3-level-model: N on level 1 equals all observations (lines), N on level 2 equals the number of clusters (students) and the N on level 3 is the number of regions
>
>>> i(id region) noconstant ///
>>> nrf(2 2) eq(gam1 gam2 gam1 gam2) ///
>>> expanded(id choice o)
>
> As I have mentioned, I do get the same results when using a single-level model with gllamm and asclogit, respectively. Is this answering your question? What is your comment on my previous questions?
>
>>> Questions:
>>> 1. I am not sure whether I have to include the alternative-specific constant variables (alt2, alt3) in the model, when I also use them in the equation-specification? If I do not, some of the fixed-effects estimates change their direction and are no longer in line with theory and expectations.
>>> 2. I am not sure whether I really need a 3-level model, since the data on the chosen track is clustered within students. Because in gllamm the cluster-option is only available on the highest hierarchy-level, I so far cannot see a solution to estimate a model with clustered-student information on level 1 and region-information on level 2.
>>>
>
> ...
>
>
>
> You are using ID as an real ID and also as the the actual response in your expanded syntax?
>
>
>>> i(id region) noconstant ///
>>> nrf(2 2) eq(gam1 gam2 gam1 gam2) ///
>>> expanded(id choice o)
>
>
> Maybe this is causing trouble.
>
>> On 26.11.2013, at 23:03, <[email protected]> wrote:
>>
>> Thanks for your comment.
>>
>> My expand-syntax is "expanded(id choice o)". "id" is used as identifier for what is called "response" in the help file. My variable "choice" equals 1 if the alternative is selected. In the single-level model I do get identical results with asclogit and gllamm with the mentioned expand-specification. Why do you think the expand-specification is wrong?
>>
>> David
>>
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: [email protected] [mailto:[email protected]] Im Auftrag von Jonas Krueger
>> Gesendet: Dienstag, 26. November 2013 17:19
>> An: [email protected]
>> Betreff: Re: st: gllamm, multilevel conditional logit
>>
>> Hi. From a quick Look i guess your expand Syntax is wrong. Check the help file.
>>
>>> On 25.11.2013, at 16:12, <[email protected]> wrote:
>>>
>>> Dear Users,
>>> I'm using -gllamm expand() link(mlogit)- with Stata13 and getting a result I know is wrong, so I know I'm misunderstanding something with the equation-specification.
>>>
>>> I have data on educational track decision, including alternative-specific and case-constant variables on individual and regional level, and would like to use gllamm to estimate a 3-level discrete choice model with fixed-effects and random effects on individual and region-level. So far I have just found stata-syntax on British election data from Skrondal & Rabe-Hesketh (2004, http://www.gllamm.org/books/readme.html#13.4, Model M23(c)), which comes close to what I would like to do.
>>>
>>> My data is in long form and consists for each student 3 rows for the 3 educational alternatives/modes (track1, track2, track3), from which students had to choose one, as well as a dummy-variable choice, which indicates the chosen track by the student. I use 2 alternative-specific variables (as1, as2) as well as case constant variables for egp-class and math-grades on individual-level and 2 variables on the region-level (reg1, reg2).
>>>
>>> I first fitted single-level models without the variables on the region-level using asclogit and gllamm with the syntax below - the results are identical and in line with theory:
>>>
>>> asclogit choice as1 as2 , casevars(math egp2 egp34 egp567) ///
>>> case(id) alternative(alt) basealternative(1) vce(cluster id) nolog
>>>
>>> gllamm alt as1 as2 ///
>>> alt2Xmath alt2Xegp2 alt2Xegp34 alt2Xegp567 alt2 ///
>>> alt3Xmath alt3Xegp2 alt3Xegp34 alt3Xegp567 alt3 ///
>>> i(id) link(mlogit) expanded(id choice o) noconstant cluster(id) robust init
>>>
>>> The second step would now be to estimate a 3-level conditional logit-model, including fixed-effects for alternative and case-constant variables and a random part on the student and region-level:
>>>
>>> eq gam1: alt2
>>> eq gam2: alt3
>>>
>>> gllamm alt as1 as2 ///
>>> alt2Xreg1 alt2Xreg2 alt2Xmath alt2Xegp2 alt2Xegp34 alt2Xegp567 alt2 ///
>>> alt3Xreg1 alt3Xreg2 alt3Xmath alt3Xegp2 alt3Xegp34 alt3Xegp567 alt3 ///
>>> i(id region) noconstant ///
>>> nrf(2 2) eq(gam1 gam2 gam1 gam2) ///
>>> expanded(id choice o) f(binom) link(mlogit) adapt trace
>>>
>>> Questions:
>>> 1. I am not sure whether I have to include the alternative-specific constant variables (alt2, alt3) in the model, when I also use them in the equation-specification? If I do not, some of the fixed-effects estimates change their direction and are no longer in line with theory and expectations.
>>> 2. I am not sure whether I really need a 3-level model, since the data on the chosen track is clustered within students. Because in gllamm the cluster-option is only available on the highest hierarchy-level, I so far cannot see a solution to estimate a model with clustered-student information on level 1 and a region-information on level 2.
>>>
>>> I would be very thankful for comments on my gllamm-syntax and questions.
>>> Kind regards
>>> David
>>>
>>>
>>>
>>> *
>>> * 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/
>
> *
> * 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/