Hello everyone I have been trying to create an adjusted cubic spline model with overlaid curves. I want to create a spline adjusted for a categorical/binary variable "Disease" that is 0=No, 1=Yes, and I want to overlay the two spline curves for each respective variable. Would appreciate some help. Thank you!.
"Diameter" is the a numerical variable that stands for vessel diameter, "rupture" is a binary variable 0=No and 1=Yes, and "years" is also a numeric variable for years of follow-up. The syntax I use for the unadjusted spline is below,:
************************************************** ********
mkspline spl_diameter=diameter, cubic nknots(3)
mat knots = r(knots)
stset years, failure(rupture==1)
stcox spl_diameter*
xbrcspline spl_diameter, values(10(10)60) ref(0) eform matknots(knots)
sort diameter
levelsof diameter
xbrcspline spl_diameter, values(`r(levels)') ref(0) matknots(knots) eform gen(diameter_splines hratio lb ub) level(95)
************************************************** *********
***Plot Spline***
twoway (line hratio lb ub diameter_splines, lp(1 - -) lc(red blue blue) ) ///
if inrange(diameter,0,58) , ///
scheme(s1mono) legend(off) ///
ylabel(0(10)40, angle(horiz) format(%2.1fc) ) ///
xlabel(0(10)60) ///
ytitle("Hazards Ratio") ///
xtitle("diameter")
************************************************** *********
"Diameter" is the a numerical variable that stands for vessel diameter, "rupture" is a binary variable 0=No and 1=Yes, and "years" is also a numeric variable for years of follow-up. The syntax I use for the unadjusted spline is below,:
************************************************** ********
mkspline spl_diameter=diameter, cubic nknots(3)
mat knots = r(knots)
stset years, failure(rupture==1)
stcox spl_diameter*
xbrcspline spl_diameter, values(10(10)60) ref(0) eform matknots(knots)
sort diameter
levelsof diameter
xbrcspline spl_diameter, values(`r(levels)') ref(0) matknots(knots) eform gen(diameter_splines hratio lb ub) level(95)
************************************************** *********
***Plot Spline***
twoway (line hratio lb ub diameter_splines, lp(1 - -) lc(red blue blue) ) ///
if inrange(diameter,0,58) , ///
scheme(s1mono) legend(off) ///
ylabel(0(10)40, angle(horiz) format(%2.1fc) ) ///
xlabel(0(10)60) ///
ytitle("Hazards Ratio") ///
xtitle("diameter")
************************************************** *********