outreg: Generate Regression Table

Description Usage Arguments Details Value Examples

Description

Generate a regression table in data.frame format from a set of model fit objects. Currently supports lm, glm, survreg, and ivreg model outcomes.

Usage

1
2
3
outreg(fitlist, digits = 3L, alpha = c(0.1, 0.05, 0.01),
  bracket = c("se"), starred = c("coef"), robust = FALSE, small = TRUE,
  constlast = FALSE, norepeat = TRUE, displayed = list(), ...)

Arguments

fitlist

list of regression outcomes

digits

number of dicimal places for real numbers

alpha

vector of significance levels to star

bracket

stats to be in brackets

starred

stats to put stars on

robust

if TRUE, robust standard error is used

small

if TRUE, small sample parameter distribution is used

constlast

if TRUE, intercept is moved to the end of coefficient list

norepeat

if TRUE, repeated variable names are replaced by a empty string

displayed

a list of named logicals to customize the stats to display

...

alternative way to specify which stats to display

Details

Use outreg_stat_list to see the available stats names. The stats names are to be used for specifying bracket, starred, and displayed options.

Statistics to include can be chosen by displayed option or by `...`. For example, outreg(fitlist, displayed = list(pv = TRUE)) is identical with outreg(fitlist pv = TRUE), and p values of coefficients are displayed.

Value

regression table in data.frame format

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
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
fitlist <- list(lm(mpg ~ cyl, data = mtcars),
                lm(mpg ~ cyl + wt + hp, data = mtcars),
                lm(mpg ~ cyl + wt + hp + drat, data = mtcars))
outreg(fitlist)

# with custom regression names
outreg(setNames(fitlist, c('small', 'medium', 'large')))

# star on standard errors, instead of estimate
outreg(fitlist, starred = 'se')

# include other stats
outreg(fitlist, pv = TRUE, tv = TRUE, se = FALSE)


# poisson regression
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
fitlist2 <- list(glm(counts ~ outcome, family = poisson()),
                 glm(counts ~ outcome + treatment, family = poisson()))
outreg(fitlist2)


# logistic regression
fitlist3 <- list(glm(cbind(ncases, ncontrols) ~ agegp,
                     data = esoph, family = binomial()),
                 glm(cbind(ncases, ncontrols) ~ agegp + tobgp + alcgp,
                     data = esoph, family = binomial()),
                 glm(cbind(ncases, ncontrols) ~ agegp + tobgp * alcgp,
                     data = esoph, family = binomial()))
outreg(fitlist3)


# survival regression
library(survival)
fitlist4 <- list(survreg(Surv(time, status) ~ ph.ecog + age,
                         data = lung),
                 survreg(Surv(time, status) ~ ph.ecog + age + strata(sex),
                         data = lung))
outreg(fitlist4)


# tobit regression
fitlist5 <- list(survreg(Surv(durable, durable>0, type='left') ~ 1,
                 data=tobin, dist='gaussian'),
                 survreg(Surv(durable, durable>0, type='left') ~ age + quant,
                 data=tobin, dist='gaussian'))
outreg(fitlist5)


# instrumental variable regression
library(AER)
data("CigarettesSW", package = "AER")
CigarettesSW$rprice <- with(CigarettesSW, price/cpi)
CigarettesSW$rincome <- with(CigarettesSW, income/population/cpi)
CigarettesSW$tdiff <- with(CigarettesSW, (taxs - tax)/cpi)

fitlist6 <- list(OLS = lm(log(packs) ~ log(rprice) + log(rincome),
                          data = CigarettesSW, subset = year == "1995"),
                 IV1 = ivreg(log(packs) ~ log(rprice) + log(rincome) |
                             log(rincome) + tdiff + I(tax/cpi),
                             data = CigarettesSW, subset = year == "1995"),
                 IV2 = ivreg(log(packs) ~ log(rprice) + log(rincome) |
                             log(population) + tdiff + I(tax/cpi),
                             data = CigarettesSW, subset = year == "1995"))
outreg(fitlist6)

kota7/outreg documentation built on May 20, 2019, 1:10 p.m.