How to Create OR plot with reference being OR=1 from rcs logistic regression

652 Views Asked by At

I am trying to create a plot showing odds ratios from a lrm model using spines from the rms package. I've created plots of the log-odds as well as the odds, but for the plot showing odds ratios, the reference starts at an odds ratio of 0 and not an odds ratio of 1.

Here is an illustration of what I have using the cgd dataset in the survival package.

summary(cgd)

dd = datadist(cgd)
options(datadist="dd")
attach(cgd)

fit <- lrm(inherit ~ rcs(age, 4), data=cgd)
fit
summary(fit)
an <- anova(fit)
f1 <- ggplot(Predict(fit), ylab="Log-Odds")+ theme_grey()
f2 <- ggplot(Predict(fit, fun=exp), anova=an, pval = TRUE, ylab="Odds ratio") + theme_grey()

cowplot::plot_grid(f1, f2, nrow = 1, ncol = 2, scale = .9)

These are the plots produced: enter image description here

Am I doing something wrong with my code? What can I do so that the odds ratios start at 1?

1

There are 1 best solutions below

0
Matthijs On

In the first graph, you are plotting the linear predictors (the log odds) of the model.

In the second graph, you are not plotting the odds Ratio, but the odds of the model.

The odds ratio, which is a ratio between the predictor odds for ie age = 10 vs the predictor odds for age age = 11. Basically, you have to divide odds(age=11)/odds(age=10) to get the OR for a 1 point increase in age onto the predictor.

You can try calculating it using the age instead of rcs(age), to see that the OR between age 11 vs 10 = OR age 21 vs 20.