Announcement

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

  • Plot Quadratic Interaction Terms with Binary Variables in Discrete-time Survival Analysis Model using Stata.

    Hello, I have a sample dataset here, and for ease of illustrating my question, I made a little bit of change on it.
    if prsnperd module is never installed, please type the commands below,
    net describe dthaz, from(https://alexisdinno.com/stata)
    net install dthaz.pkg
    net get dthaz.pkg

    use http://www.stata-press.com/data/cgm3r/hip2,clear
    gen time=time1-time0
    bys id: egen t=max(time)
    drop _* time* gap
    order id t
    prsnperd id t fracture
    drop if _period==3|_period==4|_period==11
    drop if _period==14
    drop if _period==15
    drop if _period==16
    drop if _period==21
    drop if _period==22
    drop if _period==23
    drop if _period==9
    drop if _period==12
    drop if _period==1
    drop if _period==2
    bys id: gen time=_n
    drop _* t
    order id time fracture-age
    stset time, failure (fracture)

    The discrete-time survival model that I did is as follows,
    logit fracture c.age i.protect c.age#c.age c.age#i.protect c.age#c.age#i.protect,or

    I want to create a plot of estimated hazard curve regarding the squared term of patient's age multiplied with "protective measures" interacted with time.
    The X axis is time, and Y axis is the estimated hazard rate.
    I saw a graph on a dissertation, which was graphed with Excel sheet, and it is placed in the attached picture. I think it is similar to what I want.
    Click image for larger version

Name:	Quadratic Terms with Time-Estimated Hazard Curve.jpg
Views:	1
Size:	428.2 KB
ID:	1664728











    I don't know if someone can help me to solve this problem with Stata code.
    By the way, before I decided to post my question here, I asked my classmate and they said it seemed that I could use "predict" or "margin" to solve this problem.
    I have no idea about it.
    Last edited by smith Jason; 15 May 2022, 13:57.

  • #2
    Can anybody help? Thank you!

    Comment


    • #3
      I want to create a plot of estimated hazard curve by group. However, due to the inclusion of quadratic interaction terms of age with binary variable "protect",
      I don't know how to use Stata to write code to plot like the attached picture.
      By the way, it is typo,the survival model should be

      logit fracture c.time i.protect c.time#c.time c.time#i.protect c.time#c.time#i.protect,or

      Thank you for your help!
      Last edited by smith Jason; 15 May 2022, 18:34.

      Comment


      • #4
        Can someone say something about this question? Thank you!
        margins, dydx(time) at(time=(1(1)12)) by(instruction)
        marginsplot

        I really don't know if my Stata code above is correct.

        Comment


        • #5
          Can someone help me?

          Comment


          • #6
            Can anybody here help me?
            Thank you very very much!!!

            Comment


            • #7
              Can anybody here help me?

              Comment

              Working...
              X