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 at the end of May, and its replacement, statalist.org is already up and running.


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

AW: st: AW: xtmelogit variance estimates, conversion to MOR, inserting MORs into xtmelogit estimates, and then replacing them: a tale of two questions


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   AW: st: AW: xtmelogit variance estimates, conversion to MOR, inserting MORs into xtmelogit estimates, and then replacing them: a tale of two questions
Date   Fri, 14 May 2010 17:38:16 +0200

<> 


Admittedly, my example was ill chosen as it only featured one level with a
random coefficient, while you obviously have two levels, but no random
coefficient, just intercepts. Hence the confusion...


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Martin Weiss
Gesendet: Freitag, 14. Mai 2010 17:32
An: statalist@hsphsun2.harvard.edu
Betreff: AW: st: AW: xtmelogit variance estimates, conversion to MOR,
inserting MORs into xtmelogit estimates, and then replacing them: a tale of
two questions


<> 

As I said, look carefully at -mat l e(b)-:


*************
webuse towerlondon, clear
xi: xtmelogit dtlm difficulty i.group || family: || subject:
*replaying
xtmelogit, var
mat l e(b)
nlcom (var_cons_1: (exp([lns1_1_1]_b[_cons]))^2)
nlcom (var_cons_2: (exp([lns2_1_1]_b[_cons]))^2)
*************



HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Jamie Fagg
Gesendet: Freitag, 14. Mai 2010 17:26
An: statalist@hsphsun2.harvard.edu
Betreff: Re: st: AW: xtmelogit variance estimates, conversion to MOR,
inserting MORs into xtmelogit estimates, and then replacing them: a tale of
two questions

Thanks. Sorry about that. So, the first expression works fine and
clearly refers to the variance for neighbourhood - great!

Now to referring to the variance for pid? I tried the expression with
lns1_1_2 but it didn't work. Sorry to be at a bit of a loss about
trying other options, but I'm not sure how the expressions actually
refer to the estimates.



. est restore BYPVarComp2
(results BYPVarComp2 are active now)

. estimates replay BYPVarComp2,var

----------------------------------------------------------------------------
---------------------------------------------------------------
Model BYPVarComp2
----------------------------------------------------------------------------
---------------------------------------------------------------

Mixed-effects logistic regression               Number of obs      =    
10163

--------------------------------------------------------------------------
               |   No. of       Observations per Group       Integration
Group Variable |   Groups    Minimum    Average    Maximum      Points
----------------+---------------------------------------------------------
  constantps~o |     1191          1        8.5         68           7
           pid |     3411          1        3.0          5           7
--------------------------------------------------------------------------

                                               Wald chi2(0)       =        
.
Log likelihood = -3264.1801                     Prob > chi2        =        
.

----------------------------------------------------------------------------
--
      lowse |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
Interval]
-------------+--------------------------------------------------------------
--
      _cons |  -3.025794   .0910382   -33.24   0.000    -3.204226  
-2.847363
----------------------------------------------------------------------------
--

----------------------------------------------------------------------------
--
 Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf.
Interval]
-----------------------------+----------------------------------------------
--
neigh: Identity       |
                 var(_cons) |    .579824   .1686844      .3278398  
 1.025488
-----------------------------+----------------------------------------------
--
pid: Identity                |
                 var(_cons) |    2.55512   .3073848      2.018415  
 3.234537
----------------------------------------------------------------------------
--
LR test vs. logistic regression:     chi2(2) =   431.17   Prob > chi2 =
0.0000

Note: LR test is conservative and provided only for reference.

. disp (exp([lns1_1_1]_b[_cons]))^2
.57982397

. disp (exp([lns1_1_2]_b[_cons]))^2
equation [lns1_1_2] not found
r(303);



On 14 May 2010 16:17, Martin Weiss <martin.weiss1@gmx.de> wrote:
>
> <>
>
> " I restored my estimates
> and ran the following thinking that "disp [lns1_1_1]_b[_cons] ^2""
>
>
> You forgot the "exp" part there... See my earlier -nlcom- call:
>
>
> *************
> (exp([lns1_1_1]_b[_cons]))^2
> *************
>
>
> " The [lns1_1_1]_b[_cons] refers to the standard deviation of the random
> coefficient 'urban'"
>
>
> Crucially, it is the _logarithmic_ standard deviation of the beast you
> described, so you need to undo this via -exp()-...
>
>
>
> " How does 1_1_1 refer to the particular number that I want to retrieve?"
>
> You can -mat l e(b)- to see the matrix containing the point estimators. In
> 11, you have the -coeflegend- option to guide you along, in 10.1 you
follow
> the order in the "Random-effects Parameters" section of the -xtmelogit-
> output, I would say.
>
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Jamie Fagg
> Gesendet: Freitag, 14. Mai 2010 17:08
> An: statalist@hsphsun2.harvard.edu
> Betreff: Re: st: AW: xtmelogit variance estimates, conversion to MOR,
> inserting MORs into xtmelogit estimates, and then replacing them: a tale
of
> two questions
>
> Dear Martin,
>
> Thanks for the reply - this is going to get me there I'm sure. I ran
> your code, and broke it down as far as I could to check that I
> understood the above.
>
> In your example:
>
> The [lns1_1_1]_b[_cons] refers to the standard deviation of the random
> coefficient 'urban', while [lns1_1_2]_b[_cons] refers to the standard
> deviation of the random intercept.
>
> However, I think I may need it breaking it down a bit as I'm not sure
> how to translate your example to my situation. I restored my estimates
> and ran the following thinking that "disp [lns1_1_1]_b[_cons] ^2"
> should give me my variance for neighbourhood (i.e. 0.7614617 - see
> results below). However, it didn't (see further example below)
>
> I don't understand exactly what is being stored from the xtmelogit
> estimates I think and then how your example is using that information.
> My questions are therefore (I think).
> 1) What does 'lns' refer to?
> 2) How does 1_1_1 refer to the particular number that I want to retrieve?
>
> I am happy to read this up myself, but I'm not sure where I would go
> to find it out.
>
> Thanks for your help,
>
> Jamie
>
> ******Start of my further example******
>
> . est restore BYPVarComp2
> (results BYPVarComp2 are active now)
>
> . estimates replay BYPVarComp2
>
>
----------------------------------------------------------------------------
> ---------------------------------------------------------------
> Model BYPVarComp2
>
----------------------------------------------------------------------------
> ---------------------------------------------------------------
>
> Mixed-effects logistic regression               Number of obs      =
> 10163
>
> --------------------------------------------------------------------------
>                |   No. of       Observations per Group       Integration
> Group Variable |   Groups    Minimum    Average    Maximum      Points
> ----------------+---------------------------------------------------------
>   neigh |     1191          1        8.5         68           7
>            pid |     3411          1        3.0          5           7
> --------------------------------------------------------------------------
>
>                                                Wald chi2(0)       =
> .
> Log likelihood = -3264.1801                     Prob > chi2        =
> .
>
>
----------------------------------------------------------------------------
> --
>       lowse |      Coef.   Std. Err.      z    P>|z|     [95% Conf.
> Interval]
>
-------------+--------------------------------------------------------------
> --
>       _cons |  -3.025794   .0910382   -33.24   0.000    -3.204226
> -2.847363
>
----------------------------------------------------------------------------
> --
>
>
----------------------------------------------------------------------------
> --
>  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf.
> Interval]
>
-----------------------------+----------------------------------------------
> --
> neigh: Identity       |
>                   sd(_cons) |   .7614617   .1107635       .572573
>  1.012664
>
-----------------------------+----------------------------------------------
> --
> pid: Identity                |
>                   sd(_cons) |   1.598474   .0961494      1.420709
>  1.798482
>
----------------------------------------------------------------------------
> --
> LR test vs. logistic regression:     chi2(2) =   431.17   Prob > chi2 =
> 0.0000
>
> Note: LR test is conservative and provided only for reference.
>
> . disp [lns1_1_1]_b[_cons] ^2
> .07426462
>
> ******End of my further example******
>
>
>
> On 14 May 2010 15:37, Martin Weiss <martin.weiss1@gmx.de> wrote:
>>
>> <>
>>
>>
>> "... how would I retrieve the estimates for
>> var(_cons) from xtmelogit (I couldn't see them in the list at the end
>> of the help menu)"
>>
>>
>> *************
>> webuse bangladesh, clear
>> xtmelogit c_use urban age child* || district: urban, var
>> nlcom (var_urban: (exp([lns1_1_1]_b[_cons]))^2)
>> nlcom (var_cons: (exp([lns1_1_2]_b[_cons]))^2)
>> *************
>>
>>
>>
>> HTH
>> Martin
>>
>>
>> -----Ursprüngliche Nachricht-----
>> Von: owner-statalist@hsphsun2.harvard.edu
>> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Jamie Fagg
>> Gesendet: Freitag, 14. Mai 2010 16:29
>> An: statalist@hsphsun2.harvard.edu
>> Betreff: st: xtmelogit variance estimates, conversion to MOR, inserting
> MORs
>> into xtmelogit estimates, and then replacing them: a tale of two
questions
>>
>> Dear all,
>>
>> I've just been experimenting with esttab and the associated commands
>> (estadd, estpost etc) and using to tabulate some xtmelogit models that
>> I've fitted in Stata 10. I've got a number of queries.
>>
>> First, considering the variance estimates from the following three
>> level logistic variance components model :
>>
>>   Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf.
>> Interval]
>>
>
-----------------------------+----------------------------------------------
>> --
>> neigh: Identity       |
>>                   var(_cons) |    .579824   .1686844      .3278398
>> 1.025488
>>
>
-----------------------------+----------------------------------------------
>> --
>> pid: Identity                |
>>                   var(_cons) |    2.55512   .3073848      2.018415
>> 3.234537
>>
>> I'd like to use the estimates to make a table which includes the
>> median odds ratio (MOR). Drawing on Sophia Rabe Hesketh and Anders
>> Skrondals (2008) and Ben Jann's helpful examples, I've added the
>> between-individual (pid) MOR and between-neighbourhood (neigh) MOR to
>> the variance components model estimates using the following:
>>
>> estadd scalar bimor =   exp(sqrt(2*(0.58+2.56))*invnormal(3/4)),
>> :BYPVarComp2
>> estadd scalar bnmor = exp(sqrt(2*(0.58))*invnormal(3/4)), :BYPVarComp2
>>
>> I can then display the estimates using esttab
>>
>> esttab BYPVarComp2, stats(bimor bnmor)
>>
>> What I'd like to do now is not have to rely on automatically adding in
>> the variance estimates (0.58 and 2.56 in this case) to these
>> statements. So question 1 is, how would I retrieve the estimates for
>> var(_cons) from xtmelogit (I couldn't see them in the list at the end
>> of the help menu) and place them in the estadd statement?
>>
>> Once I've added the scalars (i.e. bamor or bnmor) to the xtmelogit
>> estimates, I cannot then replace or delete them. So question 2 is, how
>> would I go about replacing them if I make a mistake in the
>> calculations?
>>
>> Thanks for your time,
>>
>> Jamie
>>
>> *
>> *   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/
>>
>>
>> *
>> *   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/
>>
>
>
>
> --
> Dept. of Geography, Queen Mary, University of London
> Mile End Rd
> E1 4NS
>
> Tel: 020 7882 5400
>
> *
> *   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/
>
>
> *
> *   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/
>



--
Dept. of Geography, Queen Mary, University of London
Mile End Rd
E1 4NS

Tel: 020 7882 5400

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


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


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