Description Usage Arguments Details Value Author(s) See Also Examples
Shows regression output in a desired way.
1 2 3 4 5 |
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | ## 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.