Announcement

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

  • Plotting -xtmixed- growth curve model

    Hello,

    I am using Stata 15.1 and I want to plot my growth curve model. I wave 5 waves and I want to investigate the effect of age in change of attitude.

    My regression model is:

    xtmixed va1i3 agey agey2 || id:age , cov(unstr) mle

    I want to plot it as in this figure



    I tried it with

    twoway function y=_b[_cons]+_b[age]*x+_b[age*age]*x^2, range(14 26)

    but it doesn’t look so well.


    Do you have an idea about how I have to change my code to get a figure like these?

    Thank you for helping me!

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long id byte(wave val1i3) float(agey agey2)
     423000 1 2 16 256
     423000 3 5 18 324
     423000 5 4 20 400
     423000 7 3 22 484
     423000 9 4 24 576
     828000 1 2 16 256
     828000 3 4 18 324
     828000 5 4 20 400
     828000 7 4 22 484
     828000 9 4 24 576
    1091000 1 1 17 289
    1091000 5 3 21 441
    1133000 1 4 17 289
    1133000 5 4 21 441
    1133000 7 4 23 529
    1133000 9 4 25 625
    1195000 1 1 16 256
    1245000 1 4 16 256
    1377000 1 . 17 289
    1420000 1 2 18 324
    1420000 3 3 19 361
    1420000 5 3 21 441
    1420000 7 4 23 529
    1420000 9 3 25 625
    1433000 1 4 16 256
    1433000 3 5 19 361
    1433000 5 3 21 441
    1433000 7 4 23 529
    1433000 9 4 24 576
    1665000 1 2 14 196
    1665000 3 2 17 289
    1665000 5 3 18 324
    1665000 9 3 23 529
    1875000 1 2 15 225
    1909000 1 4 17 289
    1909000 3 4 19 361
    1909000 5 4 21 441
    1909000 7 4 23 529
    1909000 9 4 25 625
    2078000 1 2 16 256
    2090000 1 3 16 256
    2090000 3 4 18 324
    2163000 1 5 15 225
    2524000 1 3 16 256
    2546000 1 4 17 289
    2546000 3 3 19 361
    2546000 5 4 21 441
    2546000 7 4 23 529
    2546000 9 3 25 625
    2605000 1 1 15 225
    2605000 3 4 17 289
    2605000 5 4 19 361
    2605000 7 4 21 441
    2605000 9 5 23 529
    2690000 1 3 16 256
    2690000 3 3 18 324
    2720000 1 5 14 196
    2720000 3 5 16 256
    2720000 5 5 18 324
    2720000 7 5 21 441
    2720000 9 4 22 484
    3215000 1 1 15 225
    3215000 3 2 17 289
    3255000 1 2 16 256
    3255000 3 1 18 324
    3255000 5 3 20 400
    3255000 7 1 22 484
    3643000 1 4 17 289
    3886000 1 5 17 289
    3886000 3 5 19 361
    3886000 5 3 21 441
    3886000 7 3 23 529
    3886000 9 4 25 625
    4456000 1 4 15 225
    4504000 1 3 15 225
    4504000 3 4 17 289
    4732000 1 3 16 256
    4789000 1 5 16 256
    4789000 3 3 18 324
    4789000 5 3 20 400
    4789000 7 2 22 484
    4849000 1 5 16 256
    4849000 3 4 18 324
    4889000 1 4 14 196
    5085000 1 4 16 256
    5483000 1 4 16 256
    5483000 3 4 18 324
    5483000 5 4 20 400
    5506000 1 5 15 225
    5506000 3 3 17 289
    5506000 5 4 19 361
    5506000 7 4 21 441
    5810000 1 5 17 289
    5810000 3 5 19 361
    5810000 5 5 21 441
    5810000 7 5 23 529
    5810000 9 5 25 625
    5843000 1 3 17 289
    5843000 3 3 19 361
    5843000 5 3 21 441
    end
    label values wave welle_ac1
    label def welle_ac1 1 "1 2008/09", modify
    label def welle_ac1 3 "3 2010/11", modify
    label def welle_ac1 5 "5 2012/13", modify
    label def welle_ac1 7 "7 2014/15", modify
    label def welle_ac1 9 "9 2016/17", modify
    label values val1i3 Variable_label
    label def Variable_label 1 "Stimme voll zu", modify
    label def Variable_label 5 "Stimme überhaupt nicht zu", modify

  • #2
    If your dependent variable is continuous, follow this code. Note: judging by the value labels you assigned, it is not continuous. I'd highly, highly recommend you update your syntax, including using mixed (xtmixed is the old command) and margins afterward. This should do it:

    Code:
    mixed va1i3 c.agey##c.agey || id: agey , cov(unstr) mle
    margins, at(age = (14(1)26))
    marginsplot
    It looks like your dependent variable is a Likert item, where 1 means agree strongly, 2 means agree, 3 means neither agree nor disagree, etc. I would strongly recommend using meologit instead, but you will need to familiarize yourself with logistic models and ordered logistic models first. Also, it sounds like you coded it so that high responses mean disagree. It will probably be better for you to recode high responses to mean strongly agree, and low responses to mean disagree. You can do this in one command:

    Code:
    recode va1i3 (1 = 5) (2 = 4) (3 = 3) (4 = 2) (5 = 1)
    Last edited by Weiwen Ng; 12 Jul 2019, 17:10.
    Please use the code delimiters to show code and results - use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

    Please use the command -dataex- to show a representative sample of data; it is installed already if you have Stata 14.2 or 15.1, else you can install it by typing

    Code:
    ssc install dataex

    Comment

    Working...
    X