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]

Re: st: RE: how to plot growth curves from two separate multilevel models in one graph


From   David Bell <dcbell@iupui.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: RE: how to plot growth curves from two separate multilevel models in one graph
Date   Tue, 3 Aug 2010 10:51:03 -0400

***
The trick is to save e(b) for each model.  Here is an example for a slightly different problem that evaluated the number of growth trajectories.

gen sexLength2 = sexLength*sexLength
fmm sexrisk sexLength sexLength2, components(2) mixtureof(normal)
matrix M2 = e(b)
twoway function y = x* M2[1,1] + x*x* M2[1,2] + M2[1,3], range(sexLength) || ///
       function y = x* M2[1,4] + x*x* M2[1,5] + M2[1,6], range(sexLength)    ///
       name(M2, replace) legend(off)
gen BIC2 = e(ll) - 0.5*e(k)*log(e(N))

fmm sexrisk sexLength sexLength2, components(3) mixtureof(normal)
gen BIC3 = e(ll) - 0.5*e(k)*log(e(N))
matrix M3 = e(b)
twoway function y = x* M3[1,1] + x*x* M3[1,2] + M3[1,3], range(sexLength) || ///
       function y = x* M3[1,4] + x*x* M3[1,5] + M3[1,6], range(sexLength) || ///
       function y = x* M3[1,7] + x*x* M3[1,8] + M3[1,9], range(sexLength)    ///
       name(M3, replace) legend(off)

fmm sexrisk sexLength sexLength2, components(4) mixtureof(normal)
gen BIC4 = e(ll) - 0.5*e(k)*log(e(N))
matrix M4 = e(b)
twoway function y = x* M4[1,1] + x*x* M4[1,2] + M4[1,3], range(sexLength) || ///
       function y = x* M4[1,4] + x*x* M4[1,5] + M4[1,6], range(sexLength) || ///
       function y = x* M4[1,7] + x*x* M4[1,8] + M4[1,9], range(sexLength) || ///
       function y = x* M4[1,10] + x*x* M4[1,11] + M4[1,12], range(sexLength)    ///
       name(M4, replace) legend(off)

graph combine M2 M3 M4, ycommon rows(1) title("Models 2-4 for sex risk") ///
      name(M2_4)

It can be seriously streamlined for your problem.  An exercise left to the reader.

Dave
====================================
David C. Bell
Professor of Sociology
Indiana University Purdue University Indianapolis (IUPUI)
(317) 278-1336
====================================




On Aug 3, 2010, at 6:12 AM, W.O.Johnson wrote:

> Hi Nick, 
> 
> I want to fit two MLM growth models (weight age log_age inverse_age plus covariates) using the xtmixed command in stata to two different samples. Fitting the models is no problem, but I can not find a way to plot the mean constant growth curves for each sample in one graph. The command I am using to produce a growth curve is 'twoway (function weight = _b[_cons] + _b[age]*(x) + _b[log_age]*ln(x) +_b[inverse_age]*1/(x)'. The problem is that as soon as I fit the second model the parameter estimates are changed?? 
> 
> Will 
> 
> 
> 
> 
> -------------------------------------------
> 
> Dr William Johnson
> 
> Research Associate
> Centre for Global Health and Human Development
> School of Sport, Exercise and Health Sciences 
> Loughborough University
> Leicestershire
> LE11 3TU
> United Kingdom
> 
> t: +44 (0) 1509 228159
> e: W.O.Johnson@lboro.ac.uk 
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
> Sent: 02 August 2010 18:05
> To: statalist@hsphsun2.harvard.edu
> Subject: st: RE: how to plot growth curves from two separate multilevel models in one graph
> 
> I imagine that Stata could do this. Given some exact detail on what you
> want to plot, I imagine that a better answer is also possible. 
> 
> Nick 
> n.j.cox@durham.ac.uk 
> 
> W.O.Johnson
> 
> I am running an analysis that requires me to fit multilevel growth
> models to two different samples (I need to use one model for use
> sample). I want to plot the resulting growth curves for each sample in
> one graph, but do not know if Stata can do this. Any advice will be
> gratefully received. 
> 
> 
> *
> *   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