Announcement

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

  • xtgee how to create a linear graph with confidence interval for the adjusted model

    I am running xtgee to assess the association between change in heart dimension (pch_rveda) and time from enrollment (tfe) expecting that the heart will get bigger as time goes by. I like to plot this linear association (test for nonlinearity was not significant) between rveda and tfe using the numbers from adjusted model. I cannot find any command that would do that and my search here was not successful. I apologize if this is very simple question but I have not done this before. I use Stata/SE 16.0.

    Thank you

    . dataex newid date pch_rveda rveda blrveda blage gender racecat site tfe

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte newid int date float pch_rveda double rveda float(blrveda blage) byte gender float(racecat site tfe)
    1 17195          . 18.89 18.89 31.712526 1 0 1         0
    1 17391          .     . 18.89 31.712526 1 0 1  .5366192
    1 17643          .     . 18.89 31.712526 1 0 1 1.2265568
    1 18077          .     . 18.89 31.712526 1 0 1 2.4147854
    1 18281          .     . 18.89 31.712526 1 0 1  2.973307
    1 18465  1.9057735 19.25 18.89 31.712526 1 0 1  3.477068
    1 18742          .     . 18.89 31.712526 1 0 1 4.2354527
    1 18854   23.55744 23.34 18.89 31.712526 1 0 1 4.5420933
    1 18938          .     . 18.89 31.712526 1 0 1  4.772074
    1 19026          .     . 18.89 31.712526 1 0 1  5.013002
    1 19246          .     . 18.89 31.712526 1 0 1  5.615332
    1 19260          .     . 18.89 31.712526 1 0 1  5.653662
    1 19285  17.151936 22.13 18.89 31.712526 1 0 1  5.722109
    1 19296          .     . 18.89 31.712526 1 0 1  5.752222
    1 19297          .     . 18.89 31.712526 1 0 1  5.754961
    1 19428          .     . 18.89 31.712526 1 0 1  6.113619
    1 19456          .     . 18.89 31.712526 1 0 1  6.190279
    1 19457  11.964005 21.15 18.89 31.712526 1 0 1  6.193018
    1 19486          .     . 18.89 31.712526 1 0 1  6.272417
    1 19501          .     . 18.89 31.712526 1 0 1  6.313482
    1 19590          .     . 18.89 31.712526 1 0 1  6.557154
    1 20177   23.92801 23.41 18.89 31.712526 1 0 1   8.16427
    1 21108   3.229225  19.5 18.89 31.712526 1 0 1  10.71321
    2 18018          . 22.46 22.46  23.22245 1 0 1         0
    2 18037          .     . 22.46  23.22245 1 0 1 .05201912
    2 18038          .     . 22.46  23.22245 1 0 1 .05475807
    2 18455          .     . 22.46  23.22245 1 0 1 1.1964417
    2 18770          .     . 22.46  23.22245 1 0 1 2.0588646
    2 19303  13.357084 25.46 22.46  23.22245 1 0 1  3.518139
    2 19470          .     . 22.46  23.22245 1 0 1  3.975359
    2 20079   19.41229 26.82 22.46  23.22245 1 0 1   5.64271
    2 20478  23.152275 27.66 22.46  23.22245 1 0 1  6.735113
    2 20541          .     . 22.46  23.22245 1 0 1  6.907598
    2 21073          .     . 22.46  23.22245 1 0 1  8.364134
    2 21227  28.361536 28.83 22.46  23.22245 1 0 1  8.785763
    2 21738   20.21372    27 22.46  23.22245 1 0 1 10.184807
    3 15985          . 46.81 46.81   57.1499 2 0 1         0
    3 17867          .     . 46.81   57.1499 2 0 1  5.152634
    3 18044  -7.199319 43.44 46.81   57.1499 2 0 1  5.637234
    3 18045          .     . 46.81   57.1499 2 0 1  5.639973
    3 18047          .     . 46.81   57.1499 2 0 1  5.645447
    3 18051          .     . 46.81   57.1499 2 0 1  5.656399
    3 18154          .     . 46.81   57.1499 2 0 1  5.938396
    3 19170          .     . 46.81   57.1499 2 0 1  8.720051
    3 19288          .     . 46.81   57.1499 2 0 1  9.043118
    3 19928  16.513561 54.54 46.81   57.1499 2 0 1 10.795345
    4 18324          . 30.96 30.96  44.72279 2 0 1         0
    4 18358          .     . 30.96  44.72279 2 0 1 .09308624
    4 18368          .     . 30.96  44.72279 2 0 1 .12046432
    4 18784 -18.023252 25.38 30.96  44.72279 2 0 1  1.259411
    4 19421  -4.877258 29.45 30.96  44.72279 2 0 1  3.003422
    4 19960 -12.855294 26.98 30.96  44.72279 2 0 1  4.479122
    4 20576          .     . 30.96  44.72279 2 0 1  6.165638
    4 20583  1.1627936 31.32 30.96  44.72279 2 0 1  6.184803
    4 20703          .     . 30.96  44.72279 2 0 1  6.513348
    4 20898          .     . 30.96  44.72279 2 0 1  7.047226
    4 21112          .     . 30.96  44.72279 2 0 1  7.633125
    4 21143          .     . 30.96  44.72279 2 0 1  7.717999
    4 21507          .     . 30.96  44.72279 2 0 1  8.714577
    4 21627          .     . 30.96  44.72279 2 0 1  9.043121
    4 21636  -7.073641 28.77 30.96  44.72279 2 0 1   9.06776
    4 21693          .     . 30.96  44.72279 2 0 1   9.22382
    4 21747          .     . 30.96  44.72279 2 0 1  9.371662
    5 17801          . 33.87 33.87  26.38193 1 0 1         0
    5 18007          .     . 33.87  26.38193 1 0 1 .56399727
    5 18350          .     . 33.87  26.38193 1 0 1 1.5030804
    5 18508   -7.82403 31.22 33.87  26.38193 1 0 1 1.9356613
    5 18700          .     . 33.87  26.38193 1 0 1 2.4613285
    5 18921          .     . 33.87  26.38193 1 0 1  3.066393
    5 19015          .     . 33.87  26.38193 1 0 1 3.3237514
    5 19106          .     . 33.87  26.38193 1 0 1  3.572897
    5 19227          .     . 33.87  26.38193 1 0 1  3.904177
    5 19316          .     . 33.87  26.38193 1 0 1 4.1478443
    5 19417          .     . 33.87  26.38193 1 0 1  4.424368
    5 19498          .     . 33.87  26.38193 1 0 1 4.6461334
    5 19499          .     . 33.87  26.38193 1 0 1 4.6488724
    5 19589          .     . 33.87  26.38193 1 0 1  4.895279
    5 19666          .     . 33.87  26.38193 1 0 1  5.106092
    5 19750          .     . 33.87  26.38193 1 0 1  5.336073
    5 19757 -4.3105965 32.41 33.87  26.38193 1 0 1  5.355236
    5 19933          .     . 33.87  26.38193 1 0 1  5.837099
    5 20128          .     . 33.87  26.38193 1 0 1  6.370981
    5 20139          .     . 33.87  26.38193 1 0 1  6.401094
    5 20310          .     . 33.87  26.38193 1 0 1  6.869268
    5 20412          .     . 33.87  26.38193 1 0 1  7.148531
    5 20506          .     . 33.87  26.38193 1 0 1  7.405886
    5 20524 -14.083257  29.1 33.87  26.38193 1 0 1  7.455168
    5 20614          .     . 33.87  26.38193 1 0 1  7.701574
    5 20699          .     . 33.87  26.38193 1 0 1  7.934294
    5 20716          .     . 33.87  26.38193 1 0 1  7.980837
    5 20717          .     . 33.87  26.38193 1 0 1  7.983572
    5 20730          .     . 33.87  26.38193 1 0 1  8.019167
    5 20779          .     . 33.87  26.38193 1 0 1  8.153322
    5 20828          .     . 33.87  26.38193 1 0 1  8.287474
    5 20865          .     . 33.87  26.38193 1 0 1  8.388777
    5 20888          .     . 33.87  26.38193 1 0 1  8.451746
    5 20912          .     . 33.87  26.38193 1 0 1  8.517454
    5 21038          .     . 33.87  26.38193 1 0 1  8.862425
    5 21115          .     . 33.87  26.38193 1 0 1  9.073236
    5 21159          .     . 33.87  26.38193 1 0 1  9.193705
    end
    format %tdnn/dd/CCYY date
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 816 observations
    Use the count() option to list more


    Here is the results form the full dataset
    . xtgee pch_rveda blrveda blage gender racecat site tfe, vce(robust)

    Iteration 1: tolerance = 3.4858818
    Iteration 2: tolerance = .03297166
    Iteration 3: tolerance = .00098127
    Iteration 4: tolerance = .00002973
    Iteration 5: tolerance = 9.010e-07

    GEE population-averaged model Number of obs = 236
    Group variable: newid Number of groups = 64
    Link: identity Obs per group:
    Family: Gaussian min = 1
    Correlation: exchangeable avg = 3.7
    max = 16
    Wald chi2(6) = 20.58
    Scale parameter: 300.659 Prob > chi2 = 0.0022

    (Std. Err. adjusted for clustering on newid)

    Robust
    pch_rveda Coef. Std. Err. z P>z [95% Conf. Interval]

    blrveda .020357 .2438373 0.08 0.933 -.4575553 .4982694
    blage -.2007481 .1445924 -1.39 0.165 -.4841439 .0826477
    gender 10.51604 3.931522 2.67 0.007 2.810397 18.22168
    racecat -3.87816 6.476657 -0.60 0.549 -16.57217 8.815854
    site 2.771269 4.190216 0.66 0.508 -5.441404 10.98394
    tfe 1.091036 .3858063 2.83 0.005 .3348693 1.847202
    _cons -10.64515 13.29898 -0.80 0.423 -36.71067 15.42037


    .

  • #2
    Try something like this.
    Code:
    xtgee rveda c.(blrveda blage tfe) i.(site racecat gender) if tfe, i(newid) family(gaussian) link(identity) corr(exchangeable)
    centile tfe, centile(0 20 40 60 80 100)
    margins , at(tfe = (`r(c_1)' `r(c_2)' `r(c_3)' `r(c_4)' `r(c_5)' `r(c_6)'))
    marginsplot , level(50) xlabel(0(2)10, format(%2.0f)) ylabel( , angle(horizontal) nogrid) title("")
    You'll want to use factor-variable notation for your categorical predictors. You'd be better off avoiding fitting regression models of percent change in outcome variable versus baseline value of outcome variable.

    Comment


    • #3
      A million thanks, this works great!!
      The reason I am adjusting for the baseline value of the outcome variable is that patients start with different heart sizes (rveda), a bigger heart may not have much room to grow but a small heart may have a larger increase during followup. So I am interested to know the change in heart size adjusted for it's baseline value. Does this make sense?

      Comment


      • #4
        The problem isn't in adjusting for baseline values. It's the use of percent change in conjunction with that where the pitfall lies (even the use of change scores by itself can be insidiously problematic).

        You might want to google harrell change scores and take a look at what it brings up, for example, this post by him and especially this thread on Cross Validated.

        Comment

        Working...
        X