Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Plotting results after running mixed effects model

    Hi All

    I've run the follwoing mixed effects model with linear splines to look at change in multimorbidity in individuals over time (4 splines for 4 periods: wave1 = 1982-1989, wave2 = 1989-1999, wave3 = 1999-2009 & wave4= 2009-2015):


    Code:
    mkspline wave1 1 wave2 2 wave3 3 wave4 = wavex
    
    tablist wavex wave1 wave2 wave3 wave4, sort(v)
    The mixed effects model (growth curve analysis with linear splines):

    Code:
    mixed score wave1 wave2 wave3 wave4 sex || NSHD_ID: wavex, cov(unstr) mle stddev
    (wavex is coded as 0, 1, 2, 3 & 4)


    The model:

    Computing standard errors:

    Mixed-effects ML regression Number of obs = 18,615
    Group variable: NSHD_ID Number of groups = 3,723

    Obs per group:
    min = 5
    avg = 5.0
    max = 5

    Wald chi2(5) = 2057.52
    Log likelihood = -29275.269 Prob > chi2 = 0.0000

    ------------------------------------------------------------------------------
    score | Coef. Std. Err. z P>|z| [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    wave1 | .4517862 .0221717 20.38 0.000 .4083305 .4952419
    wave2 | .3639538 .0221717 16.42 0.000 .3204981 .4074095
    wave3 | .2409347 .0221717 10.87 0.000 .197479 .2843904
    wave4 | .4963739 .0221717 22.39 0.000 .4529182 .5398296
    |
    sex |
    Female 2547 | .1654415 .0260374 6.35 0.000 .1144092 .2164739
    _cons | .5049936 .0215023 23.49 0.000 .4628498 .5471374
    ------------------------------------------------------------------------------

    ------------------------------------------------------------------------------
    Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
    -----------------------------+------------------------------------------------
    NSHD_ID: Unstructured |
    sd(wavex) | .4243546 .0072879 .4103083 .4388818
    sd(_cons) | .5270375 .0181214 .4926906 .5637788
    corr(wavex,_cons) | -.1251645 .033656 -.1904833 -.0587422
    -----------------------------+------------------------------------------------
    sd(Residual) | .9083197 .0060774 .896486 .9203096
    ------------------------------------------------------------------------------
    LR test vs. linear model: chi2(3) = 7825.50 Prob > chi2 = 0.0000




    I generally use margins & marginsplot to graph results from mixed-effects modelling, but I'm running into issues. So in the interest of time as I need to get a poster ready, I'm trying to use graph tw for this particular model. However, I'm a bit unsure about the details of the syntax. I'm trying to plot a graph which will show two lines (for males & females - males is the reference group in the above model) nut I'm unsure how to correctly specify the range. What I have so far :

    Code:
    tw  (function y=.5049+0.45+0.36+.24+.49*x, range(0 1 2 3 4) color(blue)) ///
        (function y=.5049+0.45+0.36+.24+.49+0.16, range(0 1 2 3 4) color(red)), ///
        name(sex, replace) legend(off)
    Thanks
    /Amal


Working...
X