8

I am using Rstudio. I have created nomograms using function nomogram from package rms using following code (copied from the example code of the documentation):

library(rms)
n <- 1000    # define sample size
set.seed(17) # so can reproduce the results
age            <- rnorm(n, 50, 10)
blood.pressure <- rnorm(n, 120, 15)
cholesterol    <- rnorm(n, 200, 25)
sex            <- factor(sample(c('female','male'), n,TRUE))


# Specify population model for log odds that Y=1
L <- .4*(sex=='male') + .045*(age-50) +
  (log(cholesterol - 10)-5.2)*(-2*(sex=='female') + 2*(sex=='male'))
# Simulate binary y to have Prob(y=1) = 1/[1+exp(-L)]
y <- ifelse(runif(n) < plogis(L), 1, 0)


ddist <- datadist(age, blood.pressure, cholesterol, sex)
options(datadist='ddist')


f <- lrm(y ~ lsp(age,50)+sex*rcs(cholesterol,4)+blood.pressure)
nom <- nomogram(f, fun=function(x)1/(1+exp(-x)),  # or fun=plogis
    fun.at=c(.001,.01,.05,seq(.1,.9,by=.1),.95,.99,.999),
    funlabel="Risk of Death")
#Instead of fun.at, could have specified fun.lp.at=logit of
#sequence above - faster and slightly more accurate
plot(nom, xfrac=.45)

Result: enter image description here

This code produces a nomogram but there is no line connecting each scale (called isopleth) to help predict the desired variable ("Risk of Death") from the plot. Usually, nomograms have the isopleth for prediction (example from wikipedia). But here, how do I predict the variable value?

EDIT:

From the documentation:

The nomogram does not have lines representing sums, but it has a reference line for reading scoring points (default range 0--100). Once the reader manually totals the points, the predicted values can be read at the bottom.

I don't understand this. It seems that predicting is supposed to be done without the isopleth, from the scale of points. but how? Can someone please elaborate with this example on how I can read the nomograms to predict the desired variable? Thanks a lot!

EDIT 2 (FYI):

In the description of the bounty, I am talking about the isopleth. When starting the bounty, I did not know that nomogram function does not provide isopleth and has points scale instead.

dc95
  • 1,319
  • 1
  • 22
  • 44
  • To get the best quality answers I would recommend to rewrite the question using a built in dataset. http://stackoverflow.com/help/mcve Also, it's strongly preferred to limit yourself to one question per question. One more thing -- it's forbidden to request links to external materials. – Hack-R Jul 09 '16 at 01:00
  • By the way, where did you read that you should be able to use a nomogram object to do a prediction? If that's not what the function is designed to do, then that's not what it's designed to do. You should be able to use your logit regression for prediction though. Also, what you want is called a **parallel-scale** nomogram with **isopleth**. – Hack-R Jul 09 '16 at 01:21
  • @Hack-R I have changed the code to use a built in dataset and removed the 2nd question about predictions. – dc95 Jul 11 '16 at 19:13
  • @Hack-R I have also added link to documentation that confirms that predicting from nomogram can be done. Thanks for your inputs. I think now the downvote should be removed. – dc95 Jul 11 '16 at 20:24

2 Answers2

10

From the documentation, the nomogram is used to manualy obtain prediction:

In the top of the plot (over Total points)

  • you draw a vertical line for each of the variables of your patient (for example age=40, cholesterol=220 ( and sex=male ), blood.pressure=172)
  • then you sum up the three values you read on the Points scale (40+60+3=103) to obtain Total Points.
  • Finally you draw a vertical line on the Total Points scale (103) to read the Risk of death (0.55). enter image description here
HubertL
  • 19,246
  • 3
  • 32
  • 51
  • Is there any way for doing it like `predict` does? Something like (fictional): `predict(nomogram_model, newdata = data, type = "survival")`... I mean, how can I specify some values for each variable and then obtain the *exact* risk of death (or survival at X time)? – jgarces Dec 18 '21 at 19:25
  • 1
    Hi @jgarces, I think you can use the `Predict` function from same package using the `f` model like this : `Predict(f, age=40, cholesterol=220, sex='male', blood.pressure=172,fun=function(x)1/(1+exp(-x)))` – HubertL Jan 10 '22 at 21:45
2

These are regression nomograms, and work in a different way to classic nomograms. A classic nomogram will perform a full calculation. For these nomograms you drop a line from each predictor to the scale at the bottom and add your results.

The only way to have a classic 'isopleth' nomogram working on a regression model would be 1 have just two predictors or 2 have a complex multi- step nomogram.