singlercs {ggrcs}R Documentation

singlercs

Description

A Function to Draw Restricted Cubic Splines (RCS)

Arguments

data

need a dataframe

fit

You need the fitted model.Must be lrm , ols or coxph.

x

The target variable you wish to fit. It is displayed on the X-axis when plotting.

Details

You can use this function to easily draw a restricted cubic spline.The function draws the graph through ggplot2.RCS fitting requires the use of the rcs function of the RMS package.Can fit cox regression,logistic regression and linear regression models.

Value

a picture

Examples

library(rms)
library(ggplot2)
library(scales)
dt<-smoke
dd<-datadist(dt)
options(datadist='dd')
fit<- cph(Surv(time,status==1) ~ rcs(age,4)+gender, x=TRUE, y=TRUE,data=dt)
###one group
singlercs(data=dt,fit=fit,x="age")
##two groups
singlercs(data=dt,fit=fit,x="age",group="gender")

[Package ggrcs version 0.3.8 Index]