Package 'outreg'

Title: Regression Table for Publication
Description: Create regression tables for publication. Currently supports 'lm', 'glm', 'survreg', and 'ivreg' outputs.
Authors: Kota Mori [aut, cre]
Maintainer: Kota Mori <[email protected]>
License: MIT + file LICENSE
Version: 0.2.2
Built: 2025-01-02 02:55:43 UTC
Source: https://github.com/kota7/outreg

Help Index


Return display name for stats

Description

Return display name for stats

Usage

get_display_names(stats)

Arguments

stats

character vector of stats

Value

character vector of display names


Generate Regression Table

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

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

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)

List of Statictics Available on outreg

Description

Returns all available statistics on outreg. Statistics names can be used for customizing the outputs, e.g., to choose stats to display or to choose stats to put starts.

Usage

outreg_stat_list()

Value

a data.frame that matches stat name and display name

Examples

outreg_stat_list()