etab: Scientific-like table for model summary

etabR Documentation

Scientific-like table for model summary

Description

This function produces a data frame with model summaries. The organization of the table resembles final format used in publications.

Usage

etab(
  model,
  digits = 4,
  hc = FALSE,
  hc.type = c("hc3", "hc0", "hc1", "hc2", "hc4")
)

Arguments

model

an output of lm, glm, multinom functions, or a tidy summary of those objects. It can also be a list (named or not) with combinations of outputs of lm, glm, multinom, or a tidy summary of such list produced by tidye

digits

integer, the number of significant digitis to use

hc

boolean, if TRUE robust standard errors (heteroskedasticity corrected) are returned

hc.type

a string with the method to compute the standard errors (see hccm)

Examples

library(magrittr)

set.seed(77)
data = tibble::data_frame(
      n = 300,
      x1   = rnorm(n,3,1),
      x2   = rexp(n),
      cat1 = sample(c(0,1), n, replace=TRUE),
      cat2 = sample(letters[1:4], n, replace=TRUE),
      y    = -10*x1*cat1 + 10*x2*(3*(cat2=='a')
             -3*(cat2=='b') +1*(cat2=='c') -1*(cat2=='d')) + 
              rnorm(n,0,10), 
      y.bin = ifelse(y < mean(y), 0, 1),
      y.mul = 1+ifelse( - x1 - x2 + rnorm(n,sd=10) < 0, 0,
                 ifelse( - 2*x2 + rnorm(n,sd=10) < 0, 1, 2)),
       )
formula1    = y ~ x1
formula2    = y ~ x1 + x2
formula3    = y ~ x1*cat1 + x2*cat2
formula4bin = y.bin ~ x1+x2*cat2
formula5mul = y.mul ~ x1 + x2
model.g1    = lm(formula1, data)
model.g2    = lm(formula2, data)
model.g3    = lm(formula3, data)
model.bin   = glm(formula4bin, data=data, family='binomial')
model.mul   = nnet::multinom(formula5mul, data)

model.mul %>% tidye %>%                         etab
list(model.g1,model.g3) %>% tidye %>%           etab
list(model.g1,model.g2, model.g3) %>% tidye %>% etab
list(model.mul, model.g3) %>% tidye %>%         etab
model.g3%>% tidye%>%                            etab

model.mul %>%                          etab
list(model.g1,model.g3) %>%            etab
list(model.g1,model.g2, model.g3) %>%  etab
list(model.mul, model.g3) %>%          etab
model.g3%>%                            etab


DiogoFerrari/edar documentation built on May 8, 2022, 8:26 a.m.