Reputation: 87
I have used the 'rms' package to use restricted cubic splines in my cox regression model.
Example of my univariate code
S_HTN<-Surv(data_HTN$time+data_HTN$age, data_HTN$event_HTN)
htn_dd<-datadist(data_HTN)
option(datadist='htn_dd')
HTN_spline<-cph(S_HTN~rcs(centiles,3), data=data_HTN)
I have plotted these via ggplot fine but what I want to know if I can see where the knots are and then use these in other analyses?
Upvotes: 0
Views: 963
Reputation: 1357
You can access the formula of your fitted model along with the knot locations by using the function Function()
, i.e. Function(HTN_spline)
.
However, you can also adjust knot locations manually, with x
, y
and z
being your three desired knots:
HTN_spline <- cph(S_HTN ~ rms::rcs(centiles, c(x, y, z)), data=data_HTN)
Upvotes: 1