<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/generating-dynamic-nomograms-using-dynnom/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://r-posts.com/generating-dynamic-nomograms-using-dynnom/"> R-posts.com</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p dir="ltr">Nomograms are useful computational tools for model visualisation, graphical assessment of variable importance and the calculation of predicted values.  The nomogram function in the rms package is a popular way of creating (static) nomograms for a variety of regression models. For example, the following code will generate a nomogram from a logistic regression model used to model the probability of survival on the titanic (<a target="_blank" rel="nofollow" href="http://biostat.mc.vanderbilt.edu/wiki/pub/Main/DataSets/titanic.html">http://biostat.mc.vanderbilt.edu/wiki/pub/Main/DataSets/titanic.html</a>)</p>
<pre>
library(PASWR)

data(titanic3)

library(&quot;rms&quot;)

t.data &lt;- datadist(titanic3)

options(datadist = 't.data')

fit &lt;- lrm(formula = survived ~ age + pclass + sex, data = titanic3)

plot(nomogram(fit, fun = function(x)plogis(x)))
</pre>
<p dir="ltr"><img alt="C:UsersAmirDropboxProjectsthesisDynNom paperRBloggerstatic nomogram.jpeg" width="450" src="https://lh3.googleusercontent.com/kA0yQ9hR2tMxbz2_aYwaBs0EDE8cdXKp-nuMU-AMd7yHCivdN-VzOY5smZz8ZGuBnWWm1FA2U6Xy4y1qwNsJPT-xgyT7tMWP0gQan2UFFfu3dDqSg_-nDHJc7Hu0YlGTu9RJsMQOndObWLNvFw"></p>
<p dir="ltr">
This nomogram is a graphical calculator of the probability of surviving the Titanic, based on three explanatory variables, sex, age and passenger class.  The nomogram can become more cumbersome to read and use when higher order interaction terms and smoothers are present in the model. For example, consider the following nomogram of the model containing all possible interactions of the three main effects.</p>
<p dir="ltr"><img width="450" src="https://lh5.googleusercontent.com/YIPYVfM7LadT0HlXMFIPhRk1rV9nufwd8oVDrY8apfOhw2rDpNo_w9MmjBjEr8zTHjJjfLA-ghDjIoynHVUHsfXirSBtolWBP5ZCjA1qp6qb2RVGD3N-91uofz25Zr2cUVYbb73gT1tY48gIfA"></p>
<p dir="ltr">The DynNom package (Jalali, A, Newell, J), built on shiny, allows the creation of dynamic nomograms from any Generalised Linear models or Cox Proportional hazards models.  DynNom supports model objects created by the lm, glm and coxph functions. It also supports models generated using the Ols, Glm, lrm and cph in the rms package which allows the inclusion of smoothing splines. For example, the following R code will build a dynamic nomogram for the corresponding higher order logistic regression model using the DynNom package.</p>
<pre>
fit2 &lt;- glm(survived ~ (age + pclass + sex) ^ 3, titanic3, family = &quot;binomial&quot;)
library(DynNom)
DynNom(fit2, titanic3)
</pre>
<p dir="ltr">The resulting dynamic nomogram allows the prediction of the probability of survival (and corresponding 95% Confidence interval) for any chosen set of values of the explanatory variables.  The shiny tabs display the corresponding predicted values graphically and numerically and the underlying model summary.</p>
<p dir="ltr"> </p>
<p dir="ltr"><img alt="C:UsersAmirDropboxProjectsthesisDynNom paperRBloggerDynNom-titanic.jpg" width="450" src="https://lh6.googleusercontent.com/I9HnHUeH_ivyt3A3qnDpAXRpi4kfym4iXGdIraHY1fWzWyJ1beqMVcvAUUmDHFwjDuHRtxDKGzAh_owdQYL0HMAZ2anCfM8leE5-OZtuLX-D9-0NCP1agSMc8c0usox55-p6c0TxRG1vVgzc0g"></p>
<p dir="ltr">The ability to interact with a model, in terms of the effect of changes in the explanatory variables on the predicted response, is a useful translational tool.  In theory all published model summaries could be accompanied with a hyperlink directing the reader to the corresponding model nomogram.  In order to do this the DNbuilder function within DynNom will generate the necessary ui.R, server.R and global.r files needed to share the nomogram online in any server (e.g.  <a target="_blank" rel="nofollow" href="http://shinyapps.io/">http://shinyapps.io</a>).</p>
<p dir="ltr">For example, the dynamic nomogram created for the titanic dataset, published using the DNbuilder function, is available at <a target="_blank" rel="nofollow" href="https://amir.shinyapps.io/titanic">https://amir.shinyapps.io/titanic</a>.</p>
<p> </p>
<p> </p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://r-posts.com/generating-dynamic-nomograms-using-dynnom/"> R-posts.com</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/nbeRSvFbQf0"></a></div>