Type: Package
Title: Regression Table for Publication
Version: 0.2.2
Description: Create regression tables for publication. Currently supports 'lm', 'glm', 'survreg', and 'ivreg' outputs.
License: MIT + file LICENSE
Encoding: UTF-8
LazyData: true
Depends: R (≥ 3.0)
Imports: magrittr, reshape2, sandwich, stats, stringr, tidyr, utils
Suggests: AER, survival, testthat
RoxygenNote: 5.0.1
URL: https://github.com/kota7/outreg
BugReports: https://github.com/kota7/outreg/issues
NeedsCompilation: no
Packaged: 2017-03-14 03:08:42 UTC; Kota.Mori
Author: Kota Mori [aut, cre]
Maintainer: Kota Mori <kmori05@gmail.com>
Repository: CRAN
Date/Publication: 2017-03-14 06:58:31

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


Create the Siginicance Stars

Description

Based on the coefficient and standard errors and significance levels, return character vector of stars.

Usage

get_star(pv, alpha, ...)

Arguments

pv

vector of p values

alpha

vector of significance levels

...

not used

Value

character vector


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()