Learn R Programming

stargazer (version 1.0)

stargazer: stargazer

Description

The stargazer command produces LaTeX code for well-formatted tables that hold regression analysis results from several models side-by-side, as well as summary statistics. It supports model objects from lm, glm, svyglm, gee, gam, polr, survreg, coxph, as well as from the implementation of these in zelig. It also supports the following zelig models for social network analysis: "cloglog.net", "gamma.net", and "logit.net".

Usage

stargazer(  ..., 
            title = "", style = "default", 
            covariate.labels = NULL, dep.var.labels = NULL,
            decimal.mark = NULL, digit.separate = NULL, digit.separator = NULL,
            digits = NULL, digits.extra = NULL, initial.zero = NULL, intercept.top = NULL, 
            model.names = NULL, model.numbers = NULL, 
            notes = NULL, notes.align = NULL, notes.label = NULL, 
            omit = NULL, omit.labels = NULL, omit.yes.no = c("Yes", "No"), 
            ord.intercepts = FALSE, star.char = NULL, star.cutoffs = NULL,
            nobs = TRUE, mean.sd = TRUE, min.max = TRUE, median = FALSE, iqr = FALSE )

Arguments

...
one or more model objects (for regression analysis tables) or data frames (for summary statistics).
title
character string vector with titles for the tables.
style
character string that specifies what style, typically designed to resemble an existing academic journal, should be used in producing the tables. This argument is not case-sensitive. See list of supported st
covariate.labels
a character string vector of labels for covariates in regression tables. A value of NA for any element means that stargazer will print the corresponding variable name. In the default case of NULL, variable names are
dep.var.labels
a character string vector of labels for the dependent variables in regression tables. A value of NA for any element means that stargazer will print the corresponding variable name. In the default case of NULL, variab
decimal.mark
character string that will serve as the decimal mark. For instance, the string "," will represent decimal commas, while "." means tables will use decimal points.
digit.separate
a numerical vector that indicates where digit separators should be placed. The first element of the vector indicates the number of digits (counted from the decimal mark to the left) that will be separated. The second element indicates the number of digits
digit.separator
character string that will serve as the digit (e.g., thousands) separator. Commonly used strings include "," for a comma separator, "" for a single space separator, and "" for no separation.
digits
integer that indicates how many decimal places should be used.
digits.extra
integer indicating the maximum number of additional decimal places to be used if a number, rounded to digits decimal places, is equal to zero.
initial.zero
a logical value indicating whether an initial zero should be printed before the decimal mark if a number is between 0 and 1.
intercept.top
a logical value indicating whether the intercept (or constant) coefficients should be on top, rather than on the bottom, of the table.
model.names
a logical value indicating whether model names should be included in the table.
model.numbers
a logical value indicating whether models should be numbered. No number is used whenever a regression table includes only one model.
notes
a character string vector containing notes to be included below the table.
notes.align
a character string that specifies how notes should be aligned under the table. One of three strings can be used: "l" for left alignment, "r" for right alignment, and "c" for centering. This argument is not case-sensi
notes.label
a character string containing a label for the notes section of the table.
omit
a vector of regular expressions that specifies which of the explanatory variables should be omitted from presentation in the table. This argument might be used, for instance, to exclude fixed effects dummies from being presented. The default value of
omit.labels
a character string vector of labels that correspond to each of the regular expressions in omit, and that will be used in a sub-table that indicates whether variables have been omitted from a given model. omit and omit.label
omit.yes.no
a character string vector of length 2 that contains the 'yes' and 'no' strings to indicate whether, in any specific model, variables were omitted from the table, as specified by "omit".
ord.intercepts
a logical value indicating whether intercepts for models with ordered dependent variables (such as ordered probit, or ordered logit) are included in the table.
star.char
character string to be used as the 'star' to denote statistical significance.
star.cutoffs
a numeric vector with a length of at least 1 and at most {3} that indicates the statistical signficance cutoffs for one, two and three 'stars,' respectively. For elements with NA values, the corresponding 'star' will not be used.
nobs
a logical value that toggles whether the number of observations (N) for each variable is shown in summary statistics tables.
mean.sd
a logical value that toggles whether variable means and standard deviations are shown in summary statistics tables.
min.max
a logical value that toggles whether variable minima and maxima are shown in summary statistics tables.
median
a logical value that toggles whether variable medians are shown in summary statistics tables.
iqr
a logical value that toggles whether the 25th and 75th percentiles for each variable are shown in summary statistics tables. ('iqr' stands for interquartile range.)

Value

  • stargazer uses cat() to output LaTeX code for the table. To allow for further processing of this output, stargazer also returns the same output invisibly as a character string vector. You can include the produced tables in your paper by inserting stargazer output into your publication's TeX source.

Acknowledgments

I would like to thank Erin Baggott, Volha Charnych, John Coglianese, Christopher Lucas, Stephen Pettigrew and Daniel Yew Mao Lim for testing an early version of stargazer. Carl Jacob Liebersohn, and workshop participants have provided useful comments and suggestions. I am also grateful to Stefan Dimitriadis, Cheng Gao, Mallory James, Melissa Kline, Jeniffer Sheehy-Skeffington, Emily Stephen and Beth Truesdale for helping me identify journals on which stargazer's table styles are based.

Details

Arguments with a value of NULL will use the default settings of the requested style.

See Also

Several packages by other authors provide functionality similar to that of stargazer. These include xtable by David B. Dahl and apsrtable by Michael Malecki.

Examples

Run this code
## create summary statistics table based for 'attitude' data frame
stargazer(attitude)

## estimate and report results of 3 OLS models
m1 <- lm(rating ~ complaints + privileges + learning + raises + critical, data=attitude)
m2 <- lm(rating ~ complaints + privileges + learning, data=attitude)
m3 <- lm(rating ~ learning + critical + advance, data=attitude)

stargazer(m1, m2, m3)

Run the code above in your browser using DataLab