Bookmark and Share

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: gllamm or xtmixed models?


From   "Antonio Rodriguez Andres" <[email protected]>
To   <[email protected]>
Subject   RE: st: gllamm or xtmixed models?
Date   Tue, 4 Feb 2014 08:19:54 +0200

Many thanks for your clarification. Thousands of apologies for creating confusion, Carlos and Richard.
Antonio

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Alfonso Sánchez-Peñalver
Sent: Tuesday, February 04, 2014 12:22 AM
To: Stata List
Subject: Re: st: gllamm or xtmixed models?

I am sorry if I have added confusion, as Richard and Carlos have pointed out.

Antonio, yes the syntax is correct. I had a different understanding but I tried it with the auto data. So my understanding after trying the command is that with the syntax that you suggested

xtmixed y x1 x2 x3 || country: x2

the coefficient you get on the x2 variable from the main equation is the mean of the slopes, and the estimation will also provide the variance of the slope for x2. Consider the following example:

sysuse auto.dta, clear

xtmixed price mpg length || country:
xtmixed price mpg length || country: length xtmixed price mpg || country: length

The first model assumes that the variance of the slope of length across countries is zero and thus the slope is a fixed parameter, the second model estimates both the mean of the slope on length and its variance across countries. Finally the last model assumes that the mean of the slope of length is zero but that it varies and thus calculates the variance across countries.

Sorry for any prior confusion from my part, and thanks again to Richard and Carlos for pointing it out.

Alfonso Sánchez-Peñalver, PhD

Visiting Assistant Professor
Suffolk University
Senior Instructor
UMass Boston



On Feb 3, 2014, at 5:04 PM, Carlos Avellaneda Suárez <[email protected]> wrote:

> I agree with Richard (to me it wasn't clear enough Antonio's first 
> question to begin with), and I would also suggest to both Alfonso and 
> Antonio to read the Stata Multilevel Mixed-Effects Reference Manual 
> available at http://www.stata.com/manuals13/me.pdf in order to avoid 
> further confusion (in pg. 285 you can read about the -mixed- command).
> And just to stress out what Richard just wrote, the model 
> specification proposed by Antonio is, at least, feasible (if it is 
> correct or not depends on Antonio's data):
> xtmixed depression x1 x2 x3 || country: x2
> 
> Best regards,
> Carlos
> 
> 2014-02-03 Carlos Avellaneda Suárez <[email protected]>:
>> I agree with Richard (to me it wasn't clear enough Antonio's first 
>> question to begin with), and I would also suggest to both Alfonso and 
>> Antonio to read the Stata Multilevel Mixed-Effects Reference Manual 
>> available at http://www.stata.com/manuals13/me.pdf in order to avoid 
>> further confusion (in pg. 285 you can read about the -mixed- 
>> command). And just to stress out what Richard just wrote, the model 
>> specification proposed by Antonio is
>> correct:
>> xtmixed depression x1 x2 x3 || country: x2
>> 
>> Best regards,
>> Carlos
>> 
>> 
>> 2014-02-03 Richard Goldstein <[email protected]>:
>> 
>>> I have been confused by much of this discussion; I suggest looking 
>>> at the help file (for -mixed-) which includes the following example:
>>> 
>>> Random-intercept and random-slope (coefficient) model
>>>        . mixed ln_w grade age c.age#c.age ttl_exp tenure 
>>> c.tenure#c.tenure || id: tenure
>>> 
>>> Rich
>>> 
>>> On 2/3/14, 4:11 PM, Alfonso Sánchez-Peñalver wrote:
>>>> Hola Antonio,
>>>> 
>>>> the short answer is no, because you can’t have a fixed and random 
>>>> slope at the
>>> same time. Including country after the colon indicates that the 
>>> slope on
>>> x2 is a
>>> random variable across countries. Including it in the main equation 
>>> you assume that it is a fixed parameter. It can’t be both.
>>>> 
>>>> Best,
>>>> 
>>>> Alfonso Sánchez-Peñalver, PhD
>>>> 
>>>> Visiting Assistant Professor
>>>> Suffolk University
>>>> Senior Instructor
>>>> UMass Boston
>>>> 
>>>> 
>>>> 
>>>> On Feb 3, 2014, at 2:41 PM, Antonio Rodriguez Andres 
>>>> <[email protected]> wrote:
>>>> 
>>>>> Alfonso
>>>>> 
>>>>> Can I specify the following model in xtmixed
>>>>> 
>>>>> xtmixed depression x1 x2 x3 || country : x2
>>>>> 
>>>>> Is incorrect to assume that the variable x2 (age let us say) vary 
>>>>> across countries (random slope) and at the same time is included 
>>>>> as regressor?
>>>>> 
>>>>> Antonio
>>>>> 
>>>>> -----Original Message-----
>>>>> From: [email protected]
>>>>> [mailto:[email protected]] On Behalf Of Antonio 
>>>>> Rodriguez Andres
>>>>> Sent: Friday, January 31, 2014 11:27 AM
>>>>> To: [email protected]
>>>>> Subject: RE: st: gllamm or xtmixed models?
>>>>> 
>>>>> Alfonso
>>>>> 
>>>>> Thank you for your answer. As far as I understood, as the 
>>>>> observations are clustered within countries. I have to account 
>>>>> this in my model and use a two multilevel model. What I can try is 
>>>>> a fixed effects model with clustering at country level
>>>>> 
>>>>> xtreg dv iv, fe vce (cluster country)
>>>>> 
>>>>> I should also use the xtset command but I do not have a real panel.
>>>>> Usually
>>>>> we declare with xtset id year (both dimensions of the panel data ) 
>>>>> but here it is only a cross section
>>>>> 
>>>>> Can I type
>>>>> 
>>>>> xtset id  country  (1 level and second level)?
>>>>> 
>>>>> 
>>>>> -----Original Message-----
>>>>> From: [email protected]
>>>>> [mailto:[email protected]] On Behalf Of Alfonso 
>>>>> Sánchez-Peñalver
>>>>> Sent: Thursday, January 30, 2014 10:31 PM
>>>>> To: Stata List
>>>>> Subject: Re: st: gllamm or xtmixed models?
>>>>> 
>>>>> Hi again Antonio,
>>>>> 
>>>>> I haven't used -gllamm- (SSC) but my understanding is that you 
>>>>> will also be able to estimate the random effects with it. The 
>>>>> fixed effects can be estimated in two different ways:
>>>>> 
>>>>> 1. Pooled OLS (-regress-) with a dummy variable for each country 
>>>>> and no constant (-nocons- option) 2. -xtreg- with fe option
>>>>> 
>>>>> For the second option you will have to first use -xtset- to 
>>>>> identify which is the level 2 (cluster) variable (country) and the 
>>>>> level 1 variable (the individuals).
>>>>> 
>>>>> As for random slopes, consider the random effects model. The 
>>>>> random effects model assumes that the intercept is a random 
>>>>> variable across countries.
>>>>> What
>>>>> if the intercept is not the only thing that varies across countries?
>>>>> What if
>>>>> the effect (slope) of a certain variable (age let's say) also 
>>>>> varies across countries? You can include that variable in the 
>>>>> random part of the command to let the slope be a random variable 
>>>>> as well. So for example, going back to your syntax, assume that 
>>>>> you believe the coefficient on x2 to be random as well, you can 
>>>>> type:
>>>>> 
>>>>> xtmixed depression x1 x3 || country: x2
>>>>> 
>>>>> Best,
>>>>> 
>>>>> Alfonso Sánchez-Peñalver, PhD
>>>>> 
>>>>> Visiting Assistant Professor
>>>>> Suffolk University
>>>>> Senior Instructor
>>>>> UMass Boston
>>>>> 
>>>>> 
>>>>> 
>>>>> On Jan 30, 2014, at 3:09 PM, Antonio Rodriguez Andres 
>>>>> <[email protected]> wrote:
>>>>> 
>>>>>> Alfonso
>>>>>> 
>>>>>> Thank you for your answer.  On this way, can I estimate the fixed 
>>>>>> effects for each country? What do they mean by random slopes for 
>>>>>> all data?
>>>>>> This can be done using the xtmixed or gllamm command?
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> -----Original Message-----
>>>>>> From: [email protected]
>>>>>> [mailto:[email protected]] On Behalf Of 
>>>>>> Alfonso Sánchez-Peñalver
>>>>>> Sent: Thursday, January 30, 2014 9:58 PM
>>>>>> To: Stata List
>>>>>> Subject: Re: st: gllamm or xtmixed models?
>>>>>> 
>>>>>> Hola Antonio,
>>>>>> 
>>>>>> I believe the correct syntax for the random effects model 
>>>>>> estimated via maximum likelihood would be
>>>>>> 
>>>>>> xtmixed depression x1 x2 x3 || country:
>>>>>> 
>>>>>> Alfonso Sánchez-Peñalver, PhD
>>>>>> 
>>>>>> Visiting Assistant Professor
>>>>>> Suffolk University
>>>>>> Senior Instructor
>>>>>> UMass Boston
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> On Jan 30, 2014, at 2:52 PM, Antonio Rodriguez Andres 
>>>>>> <[email protected]> wrote:
>>>>>> 
>>>>>>> Dear stata users
>>>>>>> 
>>>>>>> I want to estimate multilevel models as I have observations for 
>>>>>>> individuals across countries.  My dependent variable İs a 
>>>>>>> measure of mental health ranging from 0 to 24. I want to use 
>>>>>>> hierarchical linear models with fixed effects and random effects 
>>>>>>> for countries. The correct syntax is:
>>>>>>> 
>>>>>>> xtmixed depression   x1 x2 x3   || i(country)
>>>>>>> 
>>>>>>> Any clue
>>>>>>> 
>>>>>>> Regards
>>>>>>> 
>>>>>>> Antonio
>>> *
>>> *   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index