I am trying to use ols in rms package to fit the restrictive cubic spline of linear regression. But I don't know how to use ggplot to draw the restrictive cubic spline diagram of the regression coefficient? Like the picture:
And anyone can help me and share the code for me? Thank you very much!
library(ggplot2)
library(rms)
set.seed(100)
x1 <- rnorm(30, 100, 20)
x2 <- rnorm(30, 200, 20)
x3 <- rnorm(30, 300, 20)
y <- rnorm(30, 400, 20)
ddist <- datadist(x1,x2,x3)
options(datadist='ddist')
f <- ols(y ~ rcs(x1,3) + x2 + x3 )
anova(f)
ggplot()
