I'd like to investigate the nonlinear relationship between independent and dependent variables. I've done this with the RMS package.
library(rms)
test_model <- ols(BMD_ALL ~ rcs(BMI, 4)+gender+age,data=test,x=TRUE, y=TRUE)
enter image description here I want to further find the inflection point, but I failed as f(lower) * f(upper) > 0
f <- Function(test_model)
uniroot_out <- uniroot(f = f, # Find root
interval = c(20, 35))
uniroot_out
What should I do?