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]

From |
"Visintainer, Paul" <Paul.Visintainer@baystatehealth.org> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: Fwd: help with xtmixed and margins |

Date |
Mon, 24 Sep 2012 14:44:32 -0400 |

Jim, The first thing to note is that, in your t-test command, you are using standard errors rather than standard deviations. Because the -margins- command is based on the prior estimation command, it outputs standard errors. Secondly, -margins- is a powerful, but complex command. I strongly recommend spending a lot time with the help file and its examples. (My printed copy is well-worn.) Also, -margins- has options to run the types of tests you want to do -- either with options or with related commands: e.g., -contrast- and -pwcompare-. I would also recommend getting some of the books on Stata programming (e.g., Sophie Rabe-Hesketh series on multilevel models and Michael Mitchell's book on visualizing regression models are very helpful. There are several other great texts at the Stata bookstore). These have a multitude of useful examples and commands. Paul -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of James prince Sent: Monday, September 24, 2012 1:10 PM To: statalist@hsphsun2.harvard.edu Subject: Re: st: Fwd: help with xtmixed and margins I did not get a reply on my post from last week. So let me ask a simpler question. After a simple XTMIXED (intercept model and no interaction terms), what is the difference between: margins overweight, over( month) and margins, over( month overweight) They yield different results. Thank you, Jim On Fri, Sep 21, 2012 at 8:32 AM, James prince <jsprince26@gmail.com> wrote: > 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/ * * 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/ ---------------------------------------------------------------------- Please view our annual report at http://baystatehealth.org/annualreport CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may contain confidential and privileged information for the use of the designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its contents is prohibited. If you have received this communication in error, please reply to the sender immediately or by telephone at 413-794-0000 and destroy all copies of this communication and any attachments. For further information regarding Baystate Health's privacy policy, please visit our Internet site at http://baystatehealth.org. * * 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/

**Follow-Ups**:**Re: st: Fwd: help with xtmixed and margins***From:*James prince <jsprince26@gmail.com>

**st: Xtabond or dummy variables***From:*Ayman Farahat <ayman.farahat@yahoo.com>

**References**:**Re: st: Fwd: help with xtmixed and margins***From:*James prince <jsprince26@gmail.com>

- Prev by Date:
**Re: st: Fwd: help with xtmixed and margins** - Next by Date:
**st: wealth score using principal component analysis (PCA)** - Previous by thread:
**Re: st: Fwd: help with xtmixed and margins** - Next by thread:
**st: Xtabond or dummy variables** - Index(es):