JVDeasyas123
JVDeasyas123

Reputation: 273

How to find the value of X at each consecutive increase in odds for a restricted cubic spline on rms?

I am trying to find the value for BMI at each consecutive Odds ratio (1,2,3, etc) for my restricted cubic spline I created using the rms package. I am struggling to find a way to do this. I am aware that the summary function can be used to find the effect from the lower to upper interquartile range (or any specified range), however, I would like to find the value on my X-axis at (for example) at the intersection at odds of 2.0, as well as the 95%CI at that point. Does anyone have any experience or insight on accomplishing this?

library(rms)

ddist <- datadist(df)
options(datadist='ddist')

k <- with(df, quantile(X, c(.05, 0.25, 0.50, .75, .95)))
k

ddist$limits["Adjust to","X"] <- 24.37

spline_model <- lrm(Y ~ rcs(X, k), data=df)  

summary(spline_model)

dataplot <- Predict(spline_model, BMI_NUM, ref.zero=TRUE, fun=exp)

Below is the output for summary

 Factor      Low    High   Diff.  Effect  S.E.    Lower 0.95 Upper 0.95
 BMI_NUM     21.239 28.147 6.9084 0.19187 0.10947 -0.022679  0.40642   
  Odds Ratio 21.239 28.147 6.9084 1.21150      NA  0.977580  1.50140 

enter image description here

Upvotes: 0

Views: 500

Answers (1)

JVDeasyas123
JVDeasyas123

Reputation: 273

I figured out what I was looking for.

All that I needed to do was run print(dataplot) and it produced a dataframe of my continuous variable, Odds Ratio, and upper/lower 95% Confidence interval.

I then just wrote it to a csv write.csv(dataplot,"Spline_values.csv") and that was all that I needed. Thanks!

Upvotes: 0

Related Questions