View source: R/tableRegression.R
tableRegression | R Documentation |
Formats output from the regression model functions: lm
,
glm
, glm.nb
,
coxph
, and Weibull
.
tableRegression(
model,
stats = NULL,
col.names = NULL,
row.names = NULL,
intercept = NULL,
text = c("english", "german"),
text.ci = text,
eps.pvalue = 1e-04,
digits = NULL,
strict = FALSE,
big.mark = "'",
xtable = TRUE,
align = NULL,
caption = NULL,
label = NULL,
vars = NULL,
...
)
model |
Object of class |
stats |
character vector with stats chosen from "estimate", "exp.estimate", "standarderror", "t.value", "ci.95", and "p.value". |
col.names |
Character vector of same length and order as in |
row.names |
Character vector of row names. |
intercept |
Logical vector of length one indicating whether to provide an intercept or not. If intercept is set TRUE, the first line of the summary output is removed. If the model is a binomial regression, intercept is set FALSE. Intercepts are not available for Weibull or Cox models, because they do not provide any intercept value. |
text |
Either "english" (default) or "german" indicating the used language names. |
text.ci |
Either "english", "german" or "none". The language used to
denote confidence interval, see |
eps.pvalue |
If |
digits |
Vector of length |
strict |
Either |
big.mark |
Character vector as in |
xtable |
If TRUE, a Latex table is returned, otherwise a data.frame is returned. |
align |
See |
caption |
See |
label |
See |
vars |
Specify the variables for which regression summaries should be
printed. The argument |
... |
Arguments passed to |
In stats
:
If t.value
is chosen, the
z.value
might be taken, depending on the model.
For lm-models:
ci.95
calculates a confidence interval for the estimate.
For
glm- and coxph-models: ci.95
calculates a confidence interval for the
exp(estimate).
Depending on the value of the xtable
argument, the function
either prints and returns LaTeX code representing the produced table of
coefficients, or it returns the corresponding data frame.
Sina Rueeger with contributions by Sebastian Meyer.
tableOR
, xtable
,
lm
, glm
,
glm.nb
coxph
,
Weibull
.
## Linear model
## ---------------
mod.lm <- lm(Sepal.Length ~ Sepal.Width, data = iris)
mod.lm1 <- lm(Sepal.Length ~ .^2, data = iris)
tableRegression(model = mod.lm)
## strict argument is used to force p-values to have a certain number
## of digits (here 4).
tableRegression(model = mod.lm, digits = c(2, 2, 4), strict = TRUE)
tableRegression(model = mod.lm, digits = c(2, 2, 4), strict = FALSE)
## choosing columns, columns and row naming in german
tableRegression(model = mod.lm1, stats = c("estimate", "t.value", "p.value"),
text = "german")
## adapt row names, plus special format for ci
tableRegression(model = mod.lm, row.names = c("Intercept", "Width Sepal"),
text.ci = "none")
## Poisson model
## (example from ?glm)
## --------------
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
d.AD <- data.frame(treatment, outcome, counts)
mod.glm.pois <- glm(counts ~ outcome + treatment, family=poisson())
tableRegression(model = mod.glm.pois)
## Negative binomial model
## --------------
mod.glm.nb <- glm.nb(Days ~ Sex + Age, data = quine)
tableRegression(model = mod.glm.nb,
caption = paste("NegBin model. Estimated dispersion:",
sprintf("%4.2f ($se=%4.2f$).", mod.glm.nb$theta, mod.glm.nb$SE.theta)),
label = "tab:glm.nb")
## Logistic model
## -------------
dat <- survival::rats
dat$rx <- factor(dat$rx, labels = c(" (A)", " (B)"))
mod.glm.bin <- glm(status ~ litter + rx, family = binomial, data = dat)
tableRegression(model = mod.glm.bin,
stats = c("estimate", "exp.estimate", "ci.95", "t.value", "p.value"),
text = "english", digits = rep(3, 5),
caption = "Here goes the caption.", label = "mod:logit")
## including intercept
tableRegression(model = mod.glm.bin,
stats = c("estimate", "exp.estimate", "ci.95", "t.value", "p.value"),
text = "english", digits = rep(3, 5),
caption = "Here goes the caption.", label = "mod:logit",
intercept = TRUE)
## Cox model
## (example from ?survival::coxph)
## -------------
dat <- list(time = c(4, 3, 1, 1, 2, 2, 3),
status = c(1, 1, 1, 0, 1, 1, 0),
x = c(0, 2, 1, 1, 1, 0, 0),
sex = c(0, 0, 0, 0, 1, 1, 1))
mod.cox <- coxph(Surv(time, status) ~ x, data = dat)
mod.cox1 <- coxph(Surv(time, status) ~ x + factor(sex), data = dat)
mod.cox2 <- coxph(Surv(time, status) ~ x + strata(sex), data = dat)
tableRegression(model = mod.cox)
tableRegression(model = mod.cox1)
tableRegression(model = mod.cox2)
## Weibull
## (example from WeibullReg)
## -------------
data("larynx")
mod.wb <- weibullReg(Surv(time, death) ~ factor(stage) + age,
data = larynx)
tableRegression(model = mod.wb)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.