Announcement

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

  • Survival analysis using parametric g-computation

    Hello, I am trying to use parametric g-computation to analyze probability of transitioning into adulthood at each age. Anyways after duplicating the observations, create a treatment and control for each unit, when plotting the graph I have that the lines are basically overlapped. I leave the code I did:
    bysort id (eta): gen start_age = eta if working == 1 & (working[_n-1] == 0 & working[_n] == 1)
    by id: egen a_transition = min(start_age)
    bysort studio (eta): sum a_transition
    gen time=0
    replace time = anno - 2000
    sort id time

    gen treatment=0 if studio==4
    replace treatment=1 if studio== 5

    gen dtrans=0
    replace dtrans=1 if a_transition!=.| working==1

    expand 2, gen(interv)
    replace treatment=interv

    predict ptrans_k, pr
    gen pchild = 1-ptrans_k

    sort id time
    gen _t = eta
    sort id interv eta
    by id: gen pkid = pchild[1] if _n==1
    by id: replace pkid = pkid[1]

    sort id interv eta
    bysort id interv: replace pkid = pchild*pkid
    by interv, sort: summarize pkid if eta <= 45

    bysort interv : egen meanS = mean(pkid) if eta<=45
    bys interv: summarize meanS

    bysort interv eta : egen meanS_t = mean(pkid)
    bys interv (eta): sum meanS_t

    separate meanS_t, by(interv)

    twoway (line meanS_t0 eta, sort) (line meanS_t1 eta, sort) , ylabel(0(0.05)0.3) xlabel(15(2)50) ytitle("Child probability") xtitle("eta") legend(label(1 "A=0") label(2 "A=1"))


    Anybody has an idea of why this may happen given the code?
    Thanks in advance.



  • #2
    I find your post confusing but one or both of the following two user-written routines might help: -stgest- and -gformula-; use -search- to find and install

    Comment


    • #3
      Originally posted by Rich Goldstein View Post
      I find your post confusing but one or both of the following two user-written routines might help: -stgest- and -gformula-; use -search- to find and install
      Thanks, I have tried to use -gformula- before but i did not quite understand what to put into the command, in particular the option equation().

      Do you find the post confusing or the code?
      Last edited by Giorgio Nocerino; 23 Jun 2024, 05:57.

      Comment


      • #4
        since I could not completely follow the post, I did not try to follow the code (in the future, please do as the FAQ requests and post code within CODE blocks for easier reading)

        Comment

        Working...
        X