Learn R Programming

DynNom (version 4.0)

DNbuilder: Shiny code for Dynamic Nomograms

Description

DNbuilder is a generic function to build dynamic nomograms and provide the required scripts for deploying them on a server on the web such as the http://shinyapps.io. DNbuilder supports lm, glm, coxph model objects.

Usage

DNbuilder(model, data, clevel = 0.95, covariate = c("slider", "numeric"), ptype = c("st", "1-st"))

Arguments

model
an lm, glm or coxph model object
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.
ptype
This plot type option relates to coxph objects only. If "st" (the default) is chosen, a plot of the estimated survivor function, S(t), is displayed. If "1-st" is chosen a plot of 1- S(t) is displayed.

Value

A new folder in the current working directory called DynNomapp which contains all the required scripts to deploy this dynamic nomogram on a server on the web such as the http://shinyapps.io. This folder includes ui.R, server.R and global.R script files needed to build the application and dataset.rds which is the accompanying dataset and a user guide text file called README.txt which explains how to deploy the app using all these objects.

References

Banks, J. 2006. Nomograms. Encyclopedia of Statistical Sciences. 8. Easy web applications in R. http://shiny.rstudio.com

See Also

lm, glm, coxph, DynNom, DynNom.lm, DynNom.glm, DynNom.coxph

Examples

Run this code
## Not run: 
# # simple linear regression models
# model1 <- lm(uptake ~ Plant + conc + Plant * conc, data = CO2)
# DNbuilder(model1, CO2)
# 
# # Generalized regression models
# data1 =as.data.frame(Titanic)
# model2 <- glm(Survived ~ Age + Class + Sex, data = data1, weights = Freq,
#               family = binomial("probit"))
# DNbuilder(model2, data1, clevel = 0.9)
# 
# # a proportional hazard model
# data.kidney <- kidney
# # always make sure that the categorical variables are in a factor class
# data.kidney$sex <- as.factor(data.kidney$sex)
# levels(data.kidney$sex) <- c("male", "female")
# 
# model3 <- coxph(Surv(time, status) ~ age + sex + disease, data.kidney)
# DNbuilder(model3, data.kidney)
# DNbuilder(model3, data.kidney, ptype = "1-st")
# ## End(Not run)

if (interactive()) {
# a poisson regression model
model4 <- glm(event ~ mag + station + dist + accel, data = attenu, family = poisson)
DynNom(model4, attenu, covariate = "numeric")
}

Run the code above in your browser using DataLab