Skip to main content
. 2020 Apr 13;17(8):2657. doi: 10.3390/ijerph17082657
Restricted cubic spline curve analyses: R package, version 3.4.4 (http://www.R-project.org).
Code
install.packages(“rms”)
library(rms)
rawdata=read.csv(“D:/R/sleepduration.csv”)
dim(rawdata) attach(rawdata) names(rawdata)
HE_hsCRP_1<-rawdata$HE_hsCRP_
HE_Uacid<-rawdata$HE_Uacid
sleep duration<-rawdata$ts60
f_uni <- ols(HE_hsCRP_1~ rcs(sleep duration)
data=rawdata, x=TRUE)
sleep duration <- seq(0,12,2)
p_uni <- Predict(f_uni, sleep duration = sleep duration)
plot(p_uni,xlab=‘ sleep duration ‘, ylab=‘HS CRP’)
f_uni <- ols(HE_Uacid~ rcs(ts sleep duration),data=rawdata, x=TRUE)
sleep duration <- seq(0,12,2)
p_uni <- Predict(f_uni, sleep duration = sleep duration) plot(p_uni,xlab=‘ sleep duration’, ylab=‘Uacid’)