Description Usage Arguments Value Examples
Given a model object (like from stats::lm()
, stats::glm()
, or
lme4::glmer()
) this function makes a table intended for interactive use or
publication. The model coefficients and confidence intervals displayed in the
table have had their inverse link function
applied, therefore they are in the units of the response variable.
1 2 | toffee_tbl(model, conf_level = 0.95, digits = 2,
concat_signif = TRUE, odds_ratio = TRUE, ci_fmt = TRUE, ...)
|
model |
A model object that is compatible with |
conf_level |
The confidence level that will be used for computing the
confidence interval (for example: |
digits |
The number of decimal places that numbers in the table should
be rounded to. For no rounding use |
concat_signif |
If |
odds_ratio |
If |
ci_fmt |
If |
... |
Arguments that will be passed to |
A tibble::tibble()
with the following columns: the
name of the coefficient in the model (Variable
), the value of the
coefficient with inverse of the link function applied (Estimate
or
Odds_Ratio
), the confidence interval for the coefficient (CI
), the
p-value for the estimate, (p_value
), and optionally symbols representing
levels of significance (Significant
).
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 | library(dplyr)
library(toffee)
linear_model <- toffee_forest %>%
lm(Volume ~ Girth + Height + Branches, data = .)
# Basic usage
linear_model %>%
toffee_tbl()
# # A tibble: 4 x 4
# Variable Estimate CI p_value
# <chr> <dbl> <chr> <chr>
# 1 (Intercept) -67.2 [-86.81, -47.59] < 0.01***
# 2 Girth 4.75 [4.23, 5.27] < 0.01***
# 3 Height 0.33 [0.08, 0.59] 0.01*
# 4 Branches 0.46 [-0.03, 0.95] 0.07
# Using the `chars` argument from toffee_signif
linear_model %>%
toffee_tbl(thresholds = 0.01, chars = "*")
# # A tibble: 4 x 4
# Variable Estimate CI p_value
# <chr> <dbl> <chr> <chr>
# 1 (Intercept) -67.2 [-86.81, -47.59] < 0.01*
# 2 Girth 4.75 [4.23, 5.27] < 0.01*
# 3 Height 0.33 [0.08, 0.59] 0.01
# 4 Branches 0.46 [-0.03, 0.95] 0.07
# Separating the significance symbols into their own column
linear_model %>%
toffee_tbl(concat_signif = FALSE)
# # A tibble: 4 x 5
# Variable Estimate CI p_value Significant
# <chr> <dbl> <chr> <chr> <chr>
# 1 (Intercept) -67.2 [-86.81, -47.59] < 0.01 ***
# 2 Girth 4.75 [4.23, 5.27] < 0.01 ***
# 3 Height 0.33 [0.08, 0.59] 0.01 *
# 4 Branches 0.46 [-0.03, 0.95] 0.07 ""
logistic_model <- toffee_forest %>%
glm(Healthy ~ Girth + Height + Branches + Volume, data = .,
family = binomial())
logistic_model %>%
toffee_tbl()
# # A tibble: 5 x 4
# Variable Odds_Ratio CI p_value
# <chr> <dbl> <chr> <chr>
# 1 (Intercept) 0.05 [0, 10626998633.06] 0.81
# 2 Girth 0.75 [0.14, 3.65] 0.72
# 3 Height 0.92 [0.73, 1.14] 0.45
# 4 Branches 2 [1.31, 3.82] 0.01**
# 5 Volume 1.03 [0.75, 1.45] 0.86
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.