textablr_estout: Output Regression Results as a LaTeX Table

Description Usage Arguments Examples

View source: R/estout.R

Description

Like stata's 'estout', output regression results nicely.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
textablr_estout(
  ...,
  file = "",
  var_labels = NULL,
  var_omits = NULL,
  var_indicates = NULL,
  sumstat_include = sumstat_include_default,
  sumstat_format = sumstat_format_default,
  star_levels = star_level_default,
  beta_digits = 2,
  se_digits = beta_digits,
  cluster_names = NULL
)

Arguments

...

stored regression output

file

output location, if blank only prints to viewer

var_labels

named vector of variable labels. For example, to label the 'educ' variable 'Education' and the 'expr' variable 'Experience' make this 'c("Education" = "educ", "Experience" = "expr")' Note: this sets the order of variables in the table Note: to get multiple line variable labels, just use '\' Note: to get the times symbol for interactions, use 'XINTERACTION' Neither of these will look very good in the gt output...

var_omits

vector of variables to omit

var_indicates

named vector of variables to indicate. This sets of the order of indicator variables in the table

sumstat_include

vector of summary statistics to include. The defaults are 'c("nobs", "adj.r.squared", "Ymean")' Adjust the names by using names in the vector: 'c("Observations" = "nobs", "Adjusted R-Squared" = "adj.r.squared", "Y Mean Value" = "Ymean")' The names of these summary stats match the output of 'broom::glance' when possible

sumstat_format

tibble of digit formatting for summary statistics Copy the default tibble to the clipboard with 'textablr_get_sumstat_format()' function and change digits.

star_levels

vector of cut offs for statistical significance stars. The defaults are 'c(0.10, 0.05, 0.01)'. Make this NULL for no stars at all

beta_digits

3 or 3.1 or 3.14 or 3.146 or 3.1459... default is 2 digts = 3.14

se_digits

3 or 3.1 or 3.14 or 3.146 or 3.1459... default is whatever beta_digits is

cluster_names

named vector for cluster SE variables (one or multi-way clustering)

Examples

 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
# using lm, glm, and felm with `mtcars`
reg1 <- mtcars %>% lfe::felm(data = ., mpg ~ wt | cyl)
reg2 <- mtcars %>% lm(data = ., mpg ~ hp)
reg3 <- mtcars %>% dplyr::filter(gear == 4) %>%
    glm(data = ., vs ~ wt + am, family = binomial(link = "logit"))
reg4 <- mtcars %>% lm(data = ., mpg ~ wt + hp + am + as.factor(cyl))
reg5 <- mtcars %>% lm(data = ., wt ~ hp)
reg6 <- mtcars %>% lfe::felm(data = ., wt ~ hp | cyl + am)

# and a named vector of variable labels (optional)
var_labels <- c("Weight" = "wt", "Horsepower" = "hp")
# when labelling an instrumental variable in felm syntax
# the term should be "`x(fit)`" including the backticks
# if x is instrumented for by some z

# which variables to omit? (optional)
var_omits <- c("(Intercept)")

# which variables to indicate yes no (good for FEs) (optional)
var_indicates <- c("Transmission FE" = "am", "Cylinders FE" = "cyl")

# which summary stats to include?
sumstat_include <- c("nobs", "adj.r.squared", "Ymean")

# textablr_estout(reg1, reg2, reg3, reg4, reg5, reg6,
#   file = "", var_labels = var_labels, var_omits = var_omits,
#   var_indicates = var_indicates, sumstat_include = sumstat_include)

jamesfeigenbaum/textablr documentation built on Oct. 2, 2020, 6:05 p.m.