Hello - I am trying to figure out what the functional form of a fitted spline effect is. I have it working for Truncated Power Function splines and for Natural Cubic splines in GLMSELECT. But in PHREG it works only for Truncated Power Function splines and I fail to understand why Natural Cubic splines don't work. Below I include selected code to illustrate what I try to do. A full program is attached, and includes code for GLMSELECT and PHREG with TPF. First I simulate time to event data, with a covariate X that has a non-linear relation with the hazard: data sim2;
call streaminit(9823759);
do n = 1 to 10000;
x = rand('Uniform');
h = (0.6 + 0.5 * cos(2 * Constant('Pi') * x))/12;
ObsMonths = rand('Exponential') / h;
if ObsMonths > 12 then do;
Event = 0;
ObsMonths = 12;
end;
else Event = 1;
output;
end;
run; Next, I fit a Cox model with a Natural Cubic regression spline for X: *** This model uses the NATURALCUBIC basis with 5 knots. From the output datasets KNOTS, SPLINES
and ESTIMATES, the model formula is derived and checked against the predicted values in output
dataset MODELPREDICT;
proc phreg data=sim2;
effect spl = spline(x /naturalcubic details knotmethod=percentilelist(5 27.5 50 72.5 95));
model ObsMonths * Event(0) = spl;
output out=ModelPredict xbeta=xbeta;
ods output SplineKnots=knots TPFsplineDetails=splines ParameterEstimates=Estimates;
run; The output that I get is: My understanding is that XBETA in the output dataset is equal to the sum-product of the parameter estimates shown above times a natural-cubic basis function evaluated in the X value for the observation. The formula is shown below. NC is a function that is defined in the attached program. 0*nc("0.046248 0.275256 0.501562 0.726796 0.950887", 1, x)
+ -1.025583892*nc("0.046248 0.275256 0.501562 0.726796 0.950887", 2, x)
+ -35.97951988*nc("0.046248 0.275256 0.501562 0.726796 0.950887", 3, x)
+ 112.92039008*nc("0.046248 0.275256 0.501562 0.726796 0.950887", 4, x)
+ -113.9204329*nc("0.046248 0.275256 0.501562 0.726796 0.950887", 5, x) As already stated above, this approach works for Truncated Power Function splines and for Natural Cubic splines in GLMSELECT. It also works for Truncated Power Function splines in PHREG. But it does not work for Natural Cubic splines in PHREG and don't see why not 😞 Any suggestions? Do check out the complete program that is attached. Thanks, Bart
... View more