require(knitr) require(broom) require(MASS) require(pROC) require(rpart) opts_chunk$set(comment = NA, echo=TRUE, prompt=TRUE, collapse=TRUE)
Very often we are asked to summarize model results from multiple fits into a nice table.
The endpoint might be of different types (e.g., survival, case/control, continuous) and there
may be several independent variables that we want to examine univariately or adjusted for certain
variables such as age and sex. Locally at Mayo, the SAS macros %modelsum
, %glmuniv
, and %logisuni
were written to create such summary tables. With the increasing interest in R, we have developed the
function modelsum
to create similar tables within the R environment.
In developing the modelsum
function, the goal was to bring the best features of these macros into an R function.
However, the task was not simply to duplicate all the functionality, but rather to make use of R's strengths
(modeling, method dispersion, flexibility in function definition and output format) and make a tool that fits
the needs of R users. Additionally, the results needed to fit within the general reproducible research framework
so the tables could be displayed within an R markdown report.
This report provides step-by-step directions for using the functions associated with modelsum
.
All functions presented here are available within the arsenal
package. An assumption is made that users
are somewhat familiar with R markdown documents. For those who are new to the topic, a good initial
resource is available at rmarkdown.rstudio.com.
The first step when using the modelsum
function is to load the arsenal
package. All the examples in this report
use a dataset called mockstudy
made available by Paul Novotny which includes a variety of types of variables
(character, numeric, factor, ordered factor, survival) to use as examples.
require(arsenal) data(mockstudy) # load data dim(mockstudy) # look at how many subjects and variables are in the dataset # help(mockstudy) # learn more about the dataset and variables str(mockstudy) # quick look at the data
To create a simple linear regression table (the default), use a formula statement to specify the variables that you want summarized. The example below predicts BMI with the variables sex and age.
tab1 <- modelsum(bmi ~ sex + age, data=mockstudy)
If you want to take a quick look at the table, you can use summary
on your modelsum object and the table will
print out as text in your R console window. If you use summary
without any options you will see a number of
$\ $ statements which translates to "space" in HTML.
If you want a nicer version in your console window then adding the text=TRUE
option.
summary(tab1, text=TRUE)
In order for the report to look nice within an R markdown (knitr) report, you just need to specify
results="asis"
when creating the r chunk. This changes the layout slightly (compresses it) and bolds
the variable names.
summary(tab1)
If you want a data.frame version, simply use as.data.frame
.
as.data.frame(tab1)
The argument adjust
allows the user to indicate that all the variables should be adjusted for these terms. To adjust each model
for age and sex (for instance), we use adjust = ~ age + sex
:
tab2 <- modelsum(alk.phos ~ arm + ps + hgb, adjust= ~age + sex, data=mockstudy) summary(tab2)
To make sure the correct model is run you need to specify "family". The options available right now are : gaussian, binomial, survival, and poisson. If there is enough interest, additional models can be added.
Look at whether there is any evidence that AlkPhos values vary by study arm after adjusting for sex and age (assuming a linear age relationship).
fit <- lm(alk.phos ~ arm + age + sex, data=mockstudy) summary(fit) plot(fit)
The results suggest that the endpoint may need to be transformed. Calculating the Box-Cox transformation suggests a log transformation.
require(MASS) boxcox(fit)
fit2 <- lm(log(alk.phos) ~ arm + age + sex, data=mockstudy) summary(fit2) plot(fit2)
Finally, look to see whether there there is a non-linear relationship with age.
require(splines) fit3 <- lm(log(alk.phos) ~ arm + ns(age, df=2) + sex, data=mockstudy) # test whether there is a difference between models stats::anova(fit2,fit3) # look at functional form of age termplot(fit3, term=2, se=T, rug=T)
In this instance it looks like there isn't enough evidence to say that the relationship is non-linear.
broom
packageThe broom
package makes it easy to extract information from the fit.
tmp <- tidy(fit3) # coefficients, p-values class(tmp) tmp glance(fit3)
ms.logy <- modelsum(log(alk.phos) ~ arm + ps + hgb, data=mockstudy, adjust= ~age + sex, family=gaussian, gaussian.stats=c("estimate","CI.lower.estimate","CI.upper.estimate","p.value")) summary(ms.logy)
boxplot(age ~ mdquality.s, data=mockstudy, ylab=attr(mockstudy$age,'label'), xlab='mdquality.s') fit <- glm(mdquality.s ~ age + sex, data=mockstudy, family=binomial) summary(fit) # create Odd's ratio w/ confidence intervals tmp <- data.frame(summary(fit)$coef) tmp tmp$OR <- round(exp(tmp[,1]),2) tmp$lower.CI <- round(exp(tmp[,1] - 1.96* tmp[,2]),2) tmp$upper.CI <- round(exp(tmp[,1] + 1.96* tmp[,2]),2) names(tmp)[4] <- 'P-value' kable(tmp[,c('OR','lower.CI','upper.CI','P-value')]) # Assess the predictive ability of the model # code using the pROC package require(pROC) pred <- predict(fit, type='response') tmp <- pROC::roc(mockstudy$mdquality.s[!is.na(mockstudy$mdquality.s)]~ pred, plot=TRUE, percent=TRUE) tmp$auc
broom
packageThe broom
package makes it easy to extract information from the fit.
tidy(fit, exp=T, conf.int=T) # coefficients, p-values, conf.intervals glance(fit) # model summary statistics
summary(modelsum(mdquality.s ~ age + bmi, data=mockstudy, adjust=~sex, family=binomial)) fitall <- modelsum(mdquality.s ~ age, data=mockstudy, family=binomial, binomial.stats=c("Nmiss2","OR","p.value")) summary(fitall)
require(survival) # multivariable model with all 3 terms fit <- coxph(Surv(fu.time, fu.stat) ~ age + sex + arm, data=mockstudy) summary(fit) # check proportional hazards assumption fit.z <- cox.zph(fit) fit.z plot(fit.z[1], resid=FALSE) # makes for a cleaner picture in this case abline(h=coef(fit)[1], col='red') # check functional form for age using pspline (penalized spline) # results are returned for the linear and non-linear components fit2 <- coxph(Surv(fu.time, fu.stat) ~ pspline(age) + sex + arm, data=mockstudy) fit2 # plot smoothed age to visualize why significant termplot(fit2, se=T, terms=1) abline(h=0) # The c-statistic comes out in the summary of the fit summary(fit2)$concordance # It can also be calculated using the survConcordance function survConcordance(Surv(fu.time, fu.stat) ~ predict(fit2), data=mockstudy)
broom
packageThe broom
package makes it easy to extract information from the fit.
tidy(fit) # coefficients, p-values glance(fit) # model summary statistics
##Note: You must use quotes when specifying family="survival" ## family=survival will not work summary(modelsum(Surv(fu.time, fu.stat) ~ arm, adjust=~age + sex, data=mockstudy, family="survival")) ##Note: the pspline term is not working yet #summary(modelsum(Surv(fu.time, fu.stat) ~ arm, # adjust=~pspline(age) + sex, data=mockstudy, family='survival'))
Poisson regression is useful when predicting an outcome variable representing counts.
It can also be useful when looking at survival data. Cox models and Poisson models are very closely
related and survival data can be summarized using Poisson regression. If you have overdispersion (see
if the residual deviance is much larger than degrees of freedom), you may want to use quasipoisson()
instead of poisson()
. Some of these diagnostics need to be done outside of modelsum
.
For the first example, use the solder dataset available in the rpart
package. The endpoint skips
has a definite Poisson look.
require(rpart) ##just to get access to solder dataset data(solder) hist(solder$skips) fit <- glm(skips ~ Opening + Solder + Mask , data=solder, family=poisson) stats::anova(fit, test='Chi') summary(fit)
Overdispersion is when the Residual deviance is larger than the degrees of freedom. This can be tested, approximately using the following code. The goal is to have a p-value that is $>0.05$.
1-pchisq(fit$deviance, fit$df.residual)
One possible solution is to use the quasipoisson family instead of the poisson family. This adjusts for the overdispersion.
fit2 <- glm(skips ~ Opening + Solder + Mask, data=solder, family=quasipoisson) summary(fit2)
broom
packageThe broom
package makes it easy to extract information from the fit.
tidy(fit) # coefficients, p-values glance(fit) # model summary statistics
summary(modelsum(skips~Opening + Solder + Mask, data=solder, family="quasipoisson")) summary(modelsum(skips~Opening + Solder + Mask, data=solder, family="poisson"))
This second example uses the survival endpoint available in the mockstudy
dataset. There is a close
relationship between survival and Poisson models, and often it is easier to fit the model using Poisson
regression, especially if you want to present absolute risk.
# add .01 to the follow-up time (.01*1 day) in order to keep everyone in the analysis fit <- glm(fu.stat ~ offset(log(fu.time+.01)) + age + sex + arm, data=mockstudy, family=poisson) summary(fit) 1-pchisq(fit$deviance, fit$df.residual) coef(coxph(Surv(fu.time,fu.stat) ~ age + sex + arm, data=mockstudy)) coef(fit)[-1] # results from the Poisson model can then be described as risk ratios (similar to the hazard ratio) exp(coef(fit)[-1]) # As before, we can model the dispersion which alters the standard error fit2 <- glm(fu.stat ~ offset(log(fu.time+.01)) + age + sex + arm, data=mockstudy, family=quasipoisson) summary(fit2)
broom
packageThe broom
package makes it easy to extract information from the fit.
tidy(fit) ##coefficients, p-values glance(fit) ##model summary statistics
modelsum
Remember that the result from modelsum
is different from the fit
above. The modelsum
summary shows the results for age + offset(log(fu.time+.01))
then sex + offset(log(fu.time+.01))
instead of age + sex + arm + offset(log(fu.time+.01))
.
summary(modelsum(fu.stat ~ age, adjust=~offset(log(fu.time+.01))+ sex + arm, data=mockstudy, family=poisson))
Here are multiple examples showing how to use some of the different options.
There are standard settings for each type of model regarding what information is summarized in the table. This behavior can be modified using the modelsum.control function. In fact, you can save your standard settings and use that for future tables.
mycontrols <- modelsum.control(gaussian.stats=c("estimate","std.error","adj.r.squared","Nmiss"), show.adjust=FALSE, show.intercept=FALSE) tab2 <- modelsum(bmi ~ age, adjust=~sex, data=mockstudy, control=mycontrols) summary(tab2)
You can also change these settings directly in the modelsum call.
tab3 <- modelsum(bmi ~ age, adjust=~sex, data=mockstudy, gaussian.stats=c("estimate","std.error","adj.r.squared","Nmiss"), show.intercept=FALSE, show.adjust=FALSE) summary(tab3)
In the above example, age is shown with a label (Age in Years), but sex is listed "as is". This is because the data was created in SAS and in the SAS dataset, age had a label but sex did not. The label is stored as an attribute within R.
## Look at one variable's label attr(mockstudy$age,'label') ## See all the variables with a label unlist(lapply(mockstudy,'attr','label')) ## or cbind(sapply(mockstudy,attr,'label'))
If you want to add labels to other variables, there are a couple of options. First, you could add labels to the variables in your dataset.
attr(mockstudy$age,'label') <- 'Age, yrs' tab1 <- modelsum(bmi ~ age, adjust=~sex, data=mockstudy) summary(tab1)
You can also use the built-in data.frame
method for labels<-
:
labels(mockstudy) <- c(age = 'Age, yrs') tab1 <- modelsum(bmi ~ age, adjust=~sex, data=mockstudy) summary(tab1)
Another option is to add labels after you have created the table
mylabels <- list(sexFemale = "Female", age ="Age, yrs") summary(tab1, labelTranslations = mylabels)
Alternatively, you can check the variable labels and manipulate them with a function called labels
, which works on the modelsum
object.
labels(tab1) labels(tab1) <- c(sexFemale="Female", age="Baseline Age (yrs)") labels(tab1)
summary(tab1)
summary(modelsum(age~mdquality.s+sex, data=mockstudy), show.intercept=FALSE)
summary(modelsum(mdquality.s ~ age + bmi, data=mockstudy, adjust=~sex, family=binomial), show.adjust=FALSE)
Often one wants to summarize a number of variables. Instead of typing by hand each individual variable,
an alternative approach is to create a formula using the paste
command with the collapse="+"
option.
# create a vector specifying the variable names myvars <- names(mockstudy) # select the 8th through the 12th # paste them together, separated by the + sign RHS <- paste(myvars[8:12], collapse="+") RHS # create a formula using the as.formula function as.formula(paste('mdquality.s ~ ', RHS)) # use the formula in the modelsum function summary(modelsum(as.formula(paste('mdquality.s ~', RHS)), family=binomial, data=mockstudy))
These steps can also be done using the formulize
function.
## The formulize function does the paste and as.formula steps tmp <- formulize('mdquality.s',myvars[8:10]) tmp ## More complex formulas could also be written using formulize tmp2 <- formulize('mdquality.s',c('ps','hgb','sqrt(bmi)')) ## use the formula in the modelsum function summary(modelsum(tmp, data=mockstudy, family=binomial))
Here are two ways to get the same result (limit the analysis to subjects age>50 and in the F: FOLFOX treatment group).
mockstudy
.
This example also selects a subset of variables. The modelsum
function is then applied to this subsetted data.newdata <- subset(mockstudy, subset=age>50 & arm=='F: FOLFOX', select = c(age,sex, bmi:alk.phos)) dim(mockstudy) table(mockstudy$arm) dim(newdata) names(newdata)
summary(modelsum(alk.phos ~ ., data=newdata))
modelsum
to subset the data.summary(modelsum(log(alk.phos) ~ sex + ps + bmi, subset=age>50 & arm=="F: FOLFOX", data=mockstudy)) summary(modelsum(alk.phos ~ ps + bmi, adjust=~sex, subset = age>50 & bmi<24, data=mockstudy)) summary(modelsum(alk.phos ~ ps + bmi, adjust=~sex, subset=1:30, data=mockstudy))
## create a variable combining the levels of mdquality.s and sex with(mockstudy, table(interaction(mdquality.s,sex)))
summary(modelsum(age ~ interaction(mdquality.s,sex), data=mockstudy))
Certain transformations need to be surrounded by I()
so that R knows to treat it as a variable
transformation and not some special model feature. If the transformation includes any of the
symbols / - + ^ *
then surround the new variable by I()
.
summary(modelsum(arm=="F: FOLFOX" ~ I(age/10) + log(bmi) + mdquality.s, data=mockstudy, family=binomial))
mytab <- modelsum(bmi ~ sex + alk.phos + age, data=mockstudy) mytab2 <- mytab[c('age','sex','alk.phos')] summary(mytab2) summary(mytab[c('age','sex')]) summary(mytab[c(3,1)])
modelsum
objects togetherIt is possible to merge two modelsum objects so that they print out together, however you need to pay
attention to the columns that are being displayed. It is sometimes easier to combine two models of the same
family (such as two sets of linear models). Overlapping y-variables will have their x-variables
concatenated, and (if all=TRUE
) non-overlapping y-variables will have their tables printed separately.
## demographics tab1 <- modelsum(bmi ~ sex + age, data=mockstudy) ## lab data tab2 <- modelsum(mdquality.s ~ hgb + alk.phos, data=mockstudy, family=binomial) tab12 <- merge(tab1, tab2, all = TRUE) class(tab12) summary(tab12)
When creating a pdf the tables are automatically numbered and the title appears below the table. In Word and HTML, the titles appear un-numbered and above the table.
t1 <- modelsum(bmi ~ sex + age, data=mockstudy) summary(t1, title='Demographics')
Depending on the report you are writing you have the following options:
Use all values available for each variable
Use only those subjects who have measurements available for all the variables
## look at how many missing values there are for each variable apply(is.na(mockstudy),2,sum)
## Show how many subjects have each variable (non-missing) summary(modelsum(bmi ~ ast + age, data=mockstudy, control=modelsum.control(gaussian.stats=c("N","estimate")))) ## Always list the number of missing values summary(modelsum(bmi ~ ast + age, data=mockstudy, control=modelsum.control(gaussian.stats=c("Nmiss2","estimate")))) ## Only show the missing values if there are some (default) summary(modelsum(bmi ~ ast + age, data=mockstudy, control=modelsum.control(gaussian.stats=c("Nmiss","estimate")))) ## Don't show N at all summary(modelsum(bmi ~ ast + age, data=mockstudy, control=modelsum.control(gaussian.stats=c("estimate"))))
Within modelsum.control function there are 3 options for controlling the number of significant digits shown.
digits: controls the number of digits after the decimal point for continuous values
digits.ratio: controls the number of digits after the decimal point for continuous values
digits.p: controls the number of digits after the decimal point for continuous values
summary(modelsum(bmi ~ sex + age + fu.time, data=mockstudy), digits=4, digits.test=2)
Occasionally it is of interest to fit models using case weights.
The modelsum
function allows you to pass on the weights to the models and it will do the appropriate fit.
mockstudy$agegp <- cut(mockstudy$age, breaks=c(18,50,60,70,90), right=FALSE) ## create weights based on agegp and sex distribution tab1 <- with(mockstudy,table(agegp, sex)) tab1 tab2 <- with(mockstudy, table(agegp, sex, arm)) gpwts <- rep(tab1, length(unique(mockstudy$arm)))/tab2 ## apply weights to subjects index <- with(mockstudy, cbind(as.numeric(agegp), as.numeric(sex), as.numeric(as.factor(arm)))) mockstudy$wts <- gpwts[index] ## show weights by treatment arm group tapply(mockstudy$wts,mockstudy$arm, summary)
mockstudy$newvarA <- as.numeric(mockstudy$arm=='A: IFL') tab1 <- modelsum(newvarA ~ ast + bmi + hgb, data=mockstudy, subset=(arm !='G: IROX'), family=binomial) summary(tab1, title='No Case Weights used') suppressWarnings({ tab2 <- modelsum(newvarA ~ ast + bmi + hgb, data=mockstudy, subset=(arm !='G: IROX'), weights=wts, family=binomial) summary(tab2, title='Case Weights used') })
modelsum
within an Sweave documentFor those users who wish to create tables within an Sweave document, the following code seems to work.
\documentclass{article} \usepackage{longtable} \usepackage{pdfpages} \begin{document} \section{Read in Data} <<echo=TRUE>>= require(arsenal) require(knitr) require(rmarkdown) data(mockstudy) tab1 <- modelsum(bmi~sex+age, data=mockstudy) @ \section{Convert Summary.modelsum to LaTeX} <<echo=TRUE, results='hide', message=FALSE>>= capture.output(summary(tab1), file="Test.md") ## Convert R Markdown Table to LaTeX render("Test.md", pdf_document(keep_tex=TRUE)) @ \includepdf{Test.pdf} \end{document}
modelsum
results to a .CSV fileWhen looking at multiple variables it is sometimes useful to export the results to a csv file.
The as.data.frame
function creates a data frame object that can be exported or further manipulated within R.
summary(tab2, text=T) tmp <- as.data.frame(summary(tab2, text = TRUE)) tmp # write.csv(tmp, '/my/path/here/mymodel.csv')
modelsum
object to a separate Word or HTML file## write to an HTML document write2html(tab2, "~/ibm/trash.html") ## write to a Word document write2word(tab2, "~/ibm/trash.doc", title="My table in Word")
modelsum
in R ShinyThe easiest way to output a modelsum()
object in an R Shiny app is to use the tableOutput()
UI in combination with
the renderTable()
server function and as.data.frame(summary(modelsum()))
:
# A standalone shiny app library(shiny) library(arsenal) data(mockstudy) shinyApp( ui = fluidPage(tableOutput("table")), server = function(input, output) { output$table <- renderTable({ as.data.frame(summary(modelsum(age ~ sex, data = mockstudy), text = "html")) }, sanitize.text.function = function(x) x) } )
This can be especially powerful if you feed the selections from a selectInput(multiple = TRUE)
into formulize()
to make
the table dynamic!
modelsum
in bookdownSince the backbone of modelsum()
is knitr::kable()
, tables still render well in bookdown. However, print.summary.modelsum()
doesn't use
the caption=
argument of kable()
, so some tables may not have a properly numbered caption. To fix this, use the method described
on the bookdown site to give the table a tag/ID.
summary(modelsum(age ~ sex, data = mockstudy), title="(\\#tab:mytableby) Caption here")
You can now use list()
on the left-hand side of modelsum()
to give multiple endpoints.
Note that only one "family" can be specified this way (use merge()
instead if you want multiple families).
summary(modelsum(list(age, hgb) ~ bmi + sex, adjust = ~ arm, data = mockstudy))
To avoid confusion about which table is which endpoint, you can set term.name=TRUE
in summary()
. This takes the labels
for each endpoint and puts them in the top-left of the table.
summary(modelsum(list(age, hgb) ~ bmi + sex, adjust = ~ arm, data = mockstudy), term.name = TRUE)
You can also specify a grouping variable that doesn't get tested (but instead separates results): a strata variable.
summary(modelsum(list(age, hgb) ~ bmi + sex, strata = arm, data = mockstudy))
By putting multiple formulas into a list, you can use multiple sets of adjustors. Use ~ 1
or NULL
for an "unadjusted" model. By using the
adjustment.names=TRUE
argument and giving names to your adjustor sets in the list, you can name the various analyses.
adj.list <- list( Unadjusted = ~ 1, # can also specify NULL here "Adjusted for Arm" = ~ arm ) multi.adjust <- modelsum(list(age, bmi) ~ fu.time + ast, adjust = adj.list, data = mockstudy) summary(multi.adjust, adjustment.names = TRUE) summary(multi.adjust, adjustment.names = TRUE, show.intercept = FALSE, show.adjust = FALSE)
The available summary statistics, by varible type, are:
ordinal
: Ordinal logistic regression modelsNmiss, OR, CI.lower.OR, CI.upper.OR, p.value
estimate, CI.OR, CI.estimate, CI.lower.estimate, CI.upper.estimate,
N, Nmiss2, endpoint, std.error, statistic, logLik, AIC, BIC, edf, deviance, df.residual, p.value.lrt
binomial
,quasibinomial
: Logistic regression models OR, CI.lower.OR, CI.upper.OR, p.value, concordance, Nmiss
estimate, CI.OR, CI.estimate, CI.lower.estimate, CI.upper.estimate,
CI.wald, CI.lower.wald, CI.upper.wald, CI.OR.wald, CI.lower.OR.wald, CI.upper.OR.wald,
N, Nmiss2, Nevents, endpoint, std.error, statistic, logLik, AIC, BIC, null.deviance, deviance, df.residual, df.null, p.value.lrt
gaussian
: Linear regression models estimate, std.error, p.value, adj.r.squared, Nmiss
CI.estimate, CI.lower.estimate, CI.upper.estimate, N, Nmiss2, statistic,
standard.estimate, endpoint, r.squared, AIC, BIC, logLik, statistic.F, p.value.F, p.value.lrt
poisson
, quasipoisson
: Poisson regression models RR, CI.lower.RR, CI.upper.RR, p.value, Nmiss
CI.RR, CI.estimate, CI.lower.estimate, CI.upper.estimate, CI.RR, Nmiss2, std.error,
estimate, statistic, endpoint, AIC, BIC, logLik, dispersion, null.deviance, deviance, df.residual, df.null, p.value.lrt
negbin
: Negative binomial regression models RR, CI.lower.RR, CI.upper.RR, p.value, Nmiss
CI.RR, CI.estimate, CI.lower.estimate, CI.upper.estimate, CI.RR, Nmiss2, std.error, estimate,
statistic, endpoint, AIC, BIC, logLik, dispersion, null.deviance, deviance, df.residual, df.null, theta, SE.theta, p.value.lrt
clog
: Conditional Logistic modelsOR, CI.lower.OR, CI.upper.OR, p.value, concordance, Nmiss
CI.OR, CI.estimate, CI.lower.estimate, CI.upper.estimate, N, Nmiss2, estimate, std.error, endpoint, Nevents, statistic,
r.squared, r.squared.max, logLik, AIC, BIC, statistic.log, p.value.log, statistic.sc, p.value.sc,
statistic.wald, p.value.wald, N, std.error.concordance, p.value.lrt
survival
: Cox modelsHR, CI.lower.HR, CI.upper.HR, p.value, concordance, Nmiss
CI.HR, CI.estimate, CI.lower.estimate, CI.upper.estimate, N, Nmiss2, estimate, std.error, endpoint,
Nevents, statistic, r.squared, r.squared.max, logLik, AIC, BIC, statistic.log, p.value.log, statistic.sc, p.value.sc,
statistic.wald, p.value.wald, N, std.error.concordance, p.value.lrt
The full description of these parameters that can be shown for models include:
N
: a count of the number of observations used in the analysisNmiss
: only show the count of the number of missing values if there are some missing values Nmiss2
: always show a count of the number of missing values for a model endpoint
: dependent variable used in the modelstd.err
: print the standard errorstatistic
: test statisticstatistic.F
: test statistic (F test)p.value
: print the p-valuep.value.lrt
: print the likelihood ratio p-value for the main effect only (not the adjustors)r.squared
: print the model R-square adj.r.squared
: print the model adjusted R-square r.squared.max
: print the model R-squareconcordance
: print the model C statistic (which is the AUC for logistic models)logLik
: print the loglikelihood valuep.value.log
: print the p-value for the overall model likelihood testp.value.wald
: print the p-value for the overall model wald testp.value.sc
: print the p-value for overall model score testAIC
: print the Akaike information criterionBIC
: print the Bayesian information criterionnull.deviance
: null deviancedeviance
: model deviancedf.residual
: degrees of freedom for the residualdf.null
: degrees of freedom for the null modeldispersion
: This is used in Poisson models and is defined as the deviance/df.residualstatistic.sc
: overall model score statisticstatistic.wald
: overall model score statisticstatistic.log
: overall model score statisticstd.error.concordance
: standard error for the C statisticHR
: print the hazard ratio (for survival models), i.e. exp(beta)CI.lower.HR, CI.upper.HR
: print the confidence interval for the HR OR
: print the odd's ratio (for logistic models), i.e. exp(beta)CI.lower.OR, CI.upper.OR
: print the confidence interval for the ORCI.lower.OR.wald, CI.upper.OR.wald
: print the Wald confidence interval for the ORRR
: print the risk ratio (for poisson models), i.e. exp(beta)CI.lower.RR, CI.upper.RR
: print the confidence interval for the RRestimate
: print beta coefficientstandardized.estimate
: print the standardized beta coefficient CI.lower.estimate, CI.upper.estimate
: print the confidence interval for the beta coefficientCI.lower.wald, CI.upper.wald
: print the Wald confidence interval for the beta coefficientedf
: print the effective degrees of freedom.theta
: print the estimate of theta.SE.theta
: print the estimate of theta's standard error.modelsum.control
settingsA quick way to see what arguments are possible to utilize in a function is to use the args()
command. Settings involving the number of digits can be set in modelsum.control
or in summary.modelsum
.
args(modelsum.control)
summary.modelsum
settingsThe summary.modelsum function has options that modify how the table appears (such as adding a title or modifying labels).
args(arsenal:::summary.modelsum)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.