Announcement

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

  • stpm2cr - Problems plotting CIF difference, cause-specific hazard function and sub distribution hazard functions

    Hi all,

    I continue to work with stpm2cr to model cumulative incidence for my study (Mozumder et al, 2016). I've got the stpm2cr model running and have a functional cumulative incidence plot now, so small victories! Where I am struggling now is in getting a plot for CIF difference, for cause-specific hazard functions, and the sub distribution hazard functions. They all seem to use the same general syntax, yet I am clearly doing something wrong because my plotted figures aren't working. Here's the code:

    Code:
    predict cifdiff_CVO, cifdiff1(study_grp 1 study_grp 0) cifdiff2(study_grp 0 study_grp 1) ci
    label variable cifdiff_CVO_c1 "Difference in Cause-Specific Incidence for Composite CV Outcomes"
    label variable cifdiff_CVO_c1_lci "95% Lower Bound: CIF Difference for Composite CVOutcomes"
    label variable cifdiff_CVO_c1_uci "95% Upper Bound: CIF Difference for Composite CV COutcomes"
    label variable cifdiff_CVO_c2 "Difference in Cause-Specific Incidence for Mortality"
    label variable cifdiff_CVO_c2_lci "95% Lower Bound: CIF Difference for Mortality"
    label variable cifdiff_CVO_c2_uci "95% Upper Bound: CIF Difference for Mortality"
    
    twoway (line cifdiff_CVO_c1 figuretime, sort lcolor(red) lwidth(thick)) ///
           (line cifdiff_CVO_c2 figuretime, sort lcolor(blue) lwidth(thick)), ///
           title("Unadjusted Difference in Cumulative Incidence Functions") ///
           xtitle("Months from First Procedure", size(small)) ///
           ytitle("Difference", size (small)) ///  
           xlabel (0 1 12 24 36) ///
           legend(order(1 "Study Group 1" 2 "Study Group 2") size(small))
    -study_grp 0- is the reference group, -study_grp 1- is the exposure group. When I run this, instead of getting a line graph with two curves, I get this garbled mess:

    Click image for larger version

Name:	image_29454.png
Views:	1
Size:	159.2 KB
ID:	1692685
    Any idea what's going wrong with this? I think my error is in the predict syntax, but I don't know for sure. Advice/suggestions are very welcomed.
    Last edited by Sean Hardiman; 08 Dec 2022, 22:41.

  • #2
    Hi all, turns out what was missing was a time variable. By adding -timevar(figuretime)- to the -predict- lines, the graphs worked. -figuretime- was a basic range statement. Hope this helps anyone else looking to work with stpm2cr!

    Comment

    Working...
    X