BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
PamG
Quartz | Level 8

I am given a code in R and have to translate to SAS.  Is there a SAS equivalent of the R-PSPLINE function in SAS?  I could not find any relevant resources online.  Basically I need to translate the following in SAS,

coxph(Surv(time,death)~sex+pspline(age,df=4),data=have)

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

You should think about what the R model is trying to do. It is likely that author of the model chose penalized B splines simply to capture the potential that the survival rate has a potentially complicated relationship with the AGE variable. The specific form of the spline probably doesn't matter. In fact, if it is a good model, it should be robust to changes in the spline family. SAS supports B-splines, PB-splines, thin-plate splines, cubic splines, adaptive regression splines, and more, but in my experience, the form of the splines often has little impact on the predictive model.

 

For an example of two models that illustrate my points, see "Nonparametric regression for binary response data in SAS.' The example shows two completely different (nonparametric) models that give roughly the same predictive model. If they didn't give similar predictions, then one or both models are probably not good.

 

I encourage you to use the EFFECT statement in PROC PHREG to construct a model that uses either the BSPLINE or TPF spline basis. Compare the models' predictions to the R model. In most applications, the goal is to find a good model, not to worry about technical differences between different spline models.

 

 

View solution in original post

11 REPLIES 11
Reeza
Super User
FYI I've moved your post to the stats forum. Check out PROC PHREG with the EFFECT & SPLINE options.
https://communities.sas.com/t5/Statistical-Procedures/How-do-I-plot-a-spline-in-a-Cox-Regression-mod...

I don't see a penalized option though so may need to use TPSPLINE first?

Hopefully someone else has a better answer 🙂
PamG
Quartz | Level 8

Thanks Reeza. 

 

TPSPLINE will not work as I need to use this on survival data.  The only way around I see is to create the variables in data step and then use it in MODEL statement in PROC SURVIVAL.  I was hoping there is an easy way to do it.

PamG
Quartz | Level 8

I meant PROC PHREG.

Reeza
Super User
May not understand the problem correctly, but I was assuming using TPSPLINE to create the variables and then using them in PROC PHREG.
Tom
Super User Tom
Super User

How is what the R package does different than the Penalized B-splines of proc transreg?

 

https://documentation.sas.com/doc/en/statcdc/14.2/statug/statug_transreg_details07.htm

 

Ksharp
Super User
Maybe @Rick_SAS could give you a hand .
PamG
Quartz | Level 8

Upon reading further it seems like it is not implemented in SAS.  Not sure why given it is used so often.

https://bmcmedresmethodol.biomedcentral.com/articles/10.1186/s12874-019-0666-3

Ksharp
Super User

Also calling @StatDave  @lvm  @SteveDenham 

Rick_SAS
SAS Super FREQ

You should think about what the R model is trying to do. It is likely that author of the model chose penalized B splines simply to capture the potential that the survival rate has a potentially complicated relationship with the AGE variable. The specific form of the spline probably doesn't matter. In fact, if it is a good model, it should be robust to changes in the spline family. SAS supports B-splines, PB-splines, thin-plate splines, cubic splines, adaptive regression splines, and more, but in my experience, the form of the splines often has little impact on the predictive model.

 

For an example of two models that illustrate my points, see "Nonparametric regression for binary response data in SAS.' The example shows two completely different (nonparametric) models that give roughly the same predictive model. If they didn't give similar predictions, then one or both models are probably not good.

 

I encourage you to use the EFFECT statement in PROC PHREG to construct a model that uses either the BSPLINE or TPF spline basis. Compare the models' predictions to the R model. In most applications, the goal is to find a good model, not to worry about technical differences between different spline models.

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 11 replies
  • 1384 views
  • 3 likes
  • 5 in conversation