Arrange two ggplot-objects over each other; building a nomogram with rms

Dear all,

I have difficulties with two tasks:

# dataframe
# 0=female
# 1=male
df <- data.frame(
  sex=factor(rep(c("0", "1"), each=200)),
  weight=round(c(rnorm(200, mean=55, sd=5),
                 rnorm(200, mean=65, sd=5))),
  height=round(c(rnorm(200, mean=160, sd=10),
                rnorm(200, mean=170, sd=10)))


Create an ggplot-Object showing the predicted "effect" of two variables included in two separate logistic regression analyses.


lm1  <- glm(sex ~ weight, data=df, family="binomial")
lm2  <- glm(sex ~ height, data=df, family="binomial")

# Current version: Plot them next to each other.

p1 <- plot_model(lm1, type="pred", term="weight") 
p2 <- plot_model(lm2, type="pred", term="height") 

# Wanted version: Plot them overlapping over each other (potentially without confidence intervals)


Create a nomogram/3-d surface showing the probability of being male by weight and height.

Problem 1: I do not manage to make the "outcome" axis "logarithmic".
Problem 2: I need to set certain limits for the continuous variables. Is there any default? The nomogram-Code does not work currently.

lm3  <- rms::Glm(sex ~ weight + height, data=df, family="binomial")
plot(nomogram(lm3, weight=seq(40,100,by=2), height=seq(150,200,by=5), fun=plogis, lp="Prob of being male"))
bplot(Predict(lm3, weight=seq(40,100,by=2), height=seq(150,200,by=5)))

Thank you so much!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.