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]

st: Fwd: help with xtmixed and margins


From   James prince <[email protected]>
To   [email protected]
Subject   st: Fwd: help with xtmixed and margins
Date   Fri, 21 Sep 2012 08:32:01 -0500

Hi,

I am new to Stata XTMIXED command and having some trouble. I hope
someone could help.
I am using the command MARGINS to predict the fitted means for what I
thought was a simple mixed model (random intercept only).
I have longitudinal data on children collected a 3, 6, 9, 12 and 24 months.
I’m interested in the relationship between a physical activity score
(score) and weight (dichotomized as overweight, yes, no).
I’m treating “month” as discrete, and will like to test if the mean
fitted score differs between by overweight status within month.
Here is what I did:

. noi xtmixed score i.overweight i.race i.month  bwt bln i.nedu
i.gender || id:,mle

<...>

  I then use MARGINS with POST:
. margins overweight,over( month) post

Predictive margins                                Number of obs   =       1748

Expression   : Linear prediction, fixed portion, predict()
over         : month

----------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95%
Conf. Interval]
-----------------+----------------------------------------------------------------
month#overweight |
            3 0  |   100.9859   .4955637   203.78   0.000     100.0146
   101.9572
            3 1  |   99.36709   .6820952   145.68   0.000     98.03021
   100.704
            6 0  |   103.8597   .5121105   202.81   0.000     102.8559
    104.8634
            6 1  |   102.2409   .6479719   157.79   0.000     100.9709
  103.5109
            9 0  |   97.75468   .5267714   185.57   0.000     96.72223
  98.78714
            9 1  |   96.13588    .636223   151.10   0.000     94.88891
  97.38285
           12 0  |   102.2707   .5738975   178.20   0.000     101.1458
  103.3955
           12 1  |   100.6519   .6700738   150.21   0.000     99.33853
  101.9652
----------------------------------------------------------------------------------

And then TEST to test difference at each month. For example at 3 months:
. test 3.month#0.overweight= 3.month#1.overweight

 ( 1)  3bn.month#0bn.overweight - 3bn.month#1.overweight = 0

           chi2(  1) =    7.05
         Prob > chi2 =    0.0079

However, when I do a t-test using the values form margin, a very
different answer is observed:

. ttesti 373 100.9859 9.5709248 96 99.36709 6.6831408

Two-sample t test with equal variances
------------------------------------------------------------------------------
         |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       x |     373    100.9859    .4955637    9.570925    100.0114    101.9604
       y |      96    99.36709    .6820952    6.683141    98.01296    100.7212
---------+--------------------------------------------------------------------
combined |     469    100.6545    .4189191    9.072283    99.83135    101.4777
---------+--------------------------------------------------------------------
    diff |             1.61881    1.036685                -.418334    3.655954
------------------------------------------------------------------------------
    diff = mean(x) - mean(y)                                      t =   1.5615
Ho: diff = 0                                     degrees of freedom =      467

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.9405         Pr(|T| > |t|) = 0.1191          Pr(T > t) = 0.0595


So, I have two questions:
1. How can I compare the adjusted scores by overweight status for each month?
2. What is the difference between these two MARGIN commands? They
yield different results:

. margins overweight, over( month)
and
. margins, over( month overweight)

Thank you,
James.

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index