tableRegression {biostatUZH} | R Documentation |
Shows regression output in a desired way.
tableRegression(model, stats = NULL, col.nam = NULL, row.nam = NULL, intercept = NULL, text = "english", text.ci = text, eps.pvalue = 0.0001, digits = NULL, big.mark = "'", xtable = TRUE, align = NULL, caption = NULL, label = NULL, ...)
model |
an object of class |
stats |
character vector with stats, choose from |
col.nam |
character vector, same length and order as in
|
row.nam |
Names of rows, character vector |
intercept |
logical, should intercept be provided or not. If
model is a binomial regression, intercept is set |
text |
Character, german or english, used e.g. for naming the intercept. |
text.ci |
Character, german or english or none, referring to the language used for the
confidence interval, see |
eps.pvalue |
p-values smaller than |
digits |
Vector of length |
big.mark |
Character vector, see |
xtable |
Logical indicating if a LaTeX table should be produced (default) or just a data frame be returned. |
align,caption,label |
see |
... |
Arguments passed to |
In stats
:
If t.value
is choosen, the
z.value
might be taken, depending on the model.
For lm-models: ci.95
calculates a confidence interval
for the estimate.
For glm- anx 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
## Linear model ## --------------- mod.lm <- lm(Sepal.Length ~ Sepal.Width, data = iris) mod.lm1 <- lm(Sepal.Length ~ .^2, data = iris) ## using default style tableRegression(mod.lm) ## choosing columns, plus columns and row naming german tableRegression(mod.lm1, stats = c("estimate", "t.value", "p.value"), text = "german") ## adapt row names, plus special format for ci tableRegression(mod.lm, row.nam = 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(mod.glm.pois) ## Negative binomial model ## -------------- if (require("MASS")) { mod.glm.nb <- glm.nb(Days ~ Sex + Age, data = quine) tableRegression( 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(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(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)) library("survival") mod.cox <- coxph(Surv(time, status) ~ x, dat) mod.cox1 <- coxph(Surv(time, status) ~ x + factor(sex), dat) mod.cox2 <- coxph(Surv(time, status) ~ x + strata(sex), dat) tableRegression(mod.cox) tableRegression(mod.cox1) tableRegression(mod.cox2) ## Weibull ## (example from biostatUZH::WeibullReg) ## ------------- data("larynx") mod.wb <- WeibullReg(Surv(time, death) ~ factor(stage) + age, data=larynx) tableRegression(mod.wb)