Learn R Programming

DynNom (version 4.0)

DynNom.lrm: Dynamic Nomograms for Logistic Regression Models from the rms package

Description

DynNOm.lrm displays the results of a lrm model object from the rms package as a dynamic nomogram in an 'RStudio' panel or web browser.

Usage

DynNom.lrm(model, data, clevel = 0.95, covariate = c("slider", "numeric"))

Arguments

model
a lrm model object which accepts a variety of transformation functions such as asis, pol, lsp, rcs, catg, scored, strat and matrx defined in rms package.
data
dataframe containing the accompanying data
clevel
confidence level required
covariate
The option to choose the type of covariate(s) input control widget for numeric values. If "slider" (the default) is chosen a shiny application with slider control widgets are used while if "numeric" is chosen numeric values input controls will be displayed.

Value

A dynamic nomogram in a shiny application which recognises all the predictors in the model and uses them to build a sidebar panel. It sets up drop down menus for factors and sliders set at the mean and bounded by the range for covariates.The individual predictions with a relative confidence interval are calculated using the predict function, displaying either graphically as an interactive plot in the Graphical Summary tab or a table in the Numerical Summary tab. A table of model output is also available in the Model Summary tab.

See Also

lrm, predict.lrm, rms

Examples

Run this code
## Not run: 
# # example
# n <- 1000
# set.seed(17)
# age            <- rnorm(n, 50, 10)
# blood.pressure <- rnorm(n, 120, 15)
# cholesterol    <- rnorm(n, 200, 25)
# sex            <- factor(sample(c('female', 'male'), n, TRUE))
# label(age)            <- 'Age'      # label is in Hmisc
# label(cholesterol)    <- 'Total Cholesterol'
# label(blood.pressure) <- 'Systolic Blood Pressure'
# label(sex)            <- 'Sex'
# units(cholesterol)    <- 'mg/dl'
# units(blood.pressure) <- 'mmHg'
# 
# ch <- cut2(cholesterol, g = 40, levels.mean = TRUE)
# 
# d <- data.frame(age = seq(0, 90, by = 10))
# 
# L <- .4 * (sex == 'male') + .045 * (age - 50) +
#   (log(cholesterol - 10) - 5.2) * ( -2 * (sex == 'female') + 2 * (sex == 'male'))
# y <- ifelse(runif(n) < plogis(L), 1, 0)
# cholesterol[1:3] <- NA
# 
# ddist <- datadist(age, blood.pressure, cholesterol, sex)
# options(datadist = 'ddist')
# 
# data = data.frame(y = y, blood.pressure = blood.pressure, sex = sex, age = age,
# cholesterol = cholesterol)
# model <- lrm(y ~ blood.pressure + sex * (age + rcs(cholesterol, 4)),
#              x = TRUE, y = TRUE)
# 
# DynNom.lrm(model, data)
# ## End(Not run)

if (interactive()) {
fit <- lrm(formula = vs ~ wt + disp, data = mtcars)
DynNom.lrm(fit, mtcars, clevel = 0.9)
}

Run the code above in your browser using DataLab