| Title: | Beautiful Regression Tables for Modern Econometrics Packages |
|---|---|
| Description: | Produces publication-quality LaTeX, ASCII, and HTML regression tables. Designed as a drop-in replacement for the 'stargazer' package for 'lm' and 'glm' models, with added native support for 'fixest', 'plm', and 'alpaca' objects including automatic fixed-effect and random-effect indicator rows and SE-type detection. Standard errors can be supplied as variance-covariance matrices, numeric vectors, or auto-extracted from supported model objects. Follows the interface of Hlavac (2022) <https://CRAN.R-project.org/package=stargazer>. |
| Authors: | Tom Zylkin [aut, cre] |
| Maintainer: | Tom Zylkin <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.0 |
| Built: | 2026-07-17 18:46:38 UTC |
| Source: | https://github.com/cran/stargazer2 |
Wraps summary(mod, type = "clustered", cluster = cluster) and
returns a diagonal variance-covariance matrix that stargazer
recognises and labels with the appropriate "clustered by ..." description.
alpaca_vcovCL(mod, cluster)alpaca_vcovCL(mod, cluster)
mod |
A fitted |
cluster |
A one-sided formula identifying the clustering variable(s).
Use |
A square diagonal matrix of class "vcovAlpacaCL" with a
"cluster" attribute containing the cluster formula.
if (requireNamespace("alpaca", quietly = TRUE)) { d <- data.frame( y = rbinom(200, 1, 0.5), x1 = rnorm(200), grp = factor(rep(1:10, 20)) ) mod <- alpaca::feglm(y ~ x1 | grp, d, binomial("logit")) V <- alpaca_vcovCL(mod, cluster = ~grp) stargazer(mod, vcov = list(V), type = "text") }if (requireNamespace("alpaca", quietly = TRUE)) { d <- data.frame( y = rbinom(200, 1, 0.5), x1 = rnorm(200), grp = factor(rep(1:10, 20)) ) mod <- alpaca::feglm(y ~ x1 | grp, d, binomial("logit")) V <- alpaca_vcovCL(mod, cluster = ~grp) stargazer(mod, vcov = list(V), type = "text") }
Wraps summary(mod, type = "sandwich") and returns a diagonal
variance-covariance matrix that stargazer recognises and
labels as "heteroskedasticity-robust standard errors".
alpaca_vcovSandwich(mod)alpaca_vcovSandwich(mod)
mod |
A fitted |
A square diagonal matrix of class "vcovAlpacaSandwich" with
squared sandwich standard errors on the diagonal.
if (requireNamespace("alpaca", quietly = TRUE)) { d <- data.frame( y = rbinom(200, 1, 0.5), x1 = rnorm(200), grp = factor(rep(1:10, 20)) ) mod <- alpaca::feglm(y ~ x1 | grp, d, binomial("logit")) V <- alpaca_vcovSandwich(mod) stargazer(mod, vcov = list(V), type = "text") }if (requireNamespace("alpaca", quietly = TRUE)) { d <- data.frame( y = rbinom(200, 1, 0.5), x1 = rnorm(200), grp = factor(rep(1:10, 20)) ) mod <- alpaca::feglm(y ~ x1 | grp, d, binomial("logit")) V <- alpaca_vcovSandwich(mod) stargazer(mod, vcov = list(V), type = "text") }
Produces publication-quality regression tables, following the interface of the stargazer package, with native support for modern econometrics packages including fixest and alpaca. Outputs LaTeX, plain-text (ASCII), and HTML tables.
stargazer( ..., type = "latex", title = "", label = "", dep.var.labels = NULL, dep.var.caption = NULL, column.labels = NULL, column.separate = NULL, covariate.labels = NULL, coef.rename = NULL, omit = NULL, keep = NULL, omit.stat = NULL, digits = 3L, star.cutoffs = c(0.1, 0.05, 0.01), star.char = c("*", "**", "***"), notes = NULL, notes.append = TRUE, notes.align = NULL, notes.label = NULL, font.size = NULL, no.space = FALSE, style = "stargazer2", obs.label = NULL, summary.stat = NULL, median = FALSE, vcov = NULL, se = NULL, se_label = NULL, out = NULL )stargazer( ..., type = "latex", title = "", label = "", dep.var.labels = NULL, dep.var.caption = NULL, column.labels = NULL, column.separate = NULL, covariate.labels = NULL, coef.rename = NULL, omit = NULL, keep = NULL, omit.stat = NULL, digits = 3L, star.cutoffs = c(0.1, 0.05, 0.01), star.char = c("*", "**", "***"), notes = NULL, notes.append = TRUE, notes.align = NULL, notes.label = NULL, font.size = NULL, no.space = FALSE, style = "stargazer2", obs.label = NULL, summary.stat = NULL, median = FALSE, vcov = NULL, se = NULL, se_label = NULL, out = NULL )
... |
One or more fitted model objects. Supported classes:
|
type |
Character; output format. One of |
title |
Character; table caption. |
label |
Character; LaTeX cross-reference label (used with
|
dep.var.labels |
Character vector; custom labels for the dependent variable(s). Applied in column order. |
dep.var.caption |
Character; caption text above the dep-var row.
Default: |
column.labels |
Character vector; custom column header labels. Overrides the auto-detected model-type labels. |
column.separate |
Integer vector; controls how many consecutive
columns share each |
covariate.labels |
Character vector; display names for covariates,
applied positionally after |
coef.rename |
Named character vector mapping raw coefficient names to
new display names before the column union is computed. Names are the
existing coefficient names; values are the replacement names. Useful for
aligning TWFE event-study year indicators with relative-time labels from
other estimators, e.g.
|
omit |
Character vector; regex patterns — covariates whose names match any pattern are excluded from the table. |
keep |
Character vector; regex patterns — only covariates whose
names match are included (applied after |
omit.stat |
Character vector; stat identifiers to suppress.
Recognised values: |
digits |
Integer; number of decimal places for coefficients, SEs,
and most fit statistics. Default: |
star.cutoffs |
Numeric vector of length 3; p-value thresholds for
one, two, and three stars. Default: |
star.char |
Character vector of length 3; star symbols. Default:
|
notes |
Character vector; additional table notes appended after the SE-type note. |
notes.append |
Logical; if |
notes.align |
Character; cell alignment for the note row in LaTeX
( |
notes.label |
Character; text preceding the note. Default:
|
font.size |
Character; LaTeX font-size command (e.g.
|
no.space |
Logical; suppress blank spacer rows in the table body.
Only affects |
style |
Character; table formatting style. Controls overall layout, rule style, notes format, and significance-note wording.
|
obs.label |
Character; overrides the label for the Observations row.
Defaults to the style preset ( |
summary.stat |
Character vector; which summary statistics to include
when |
median |
Logical; if |
vcov |
List of variance-covariance matrices (one per model, or
|
se |
List of numeric vectors of standard errors (one per model,
or |
se_label |
Character vector (one per model, or a single string
applied to all) overriding the auto-detected SE-type description used
in the table note. Useful when supplying a |
out |
Character; file path. If provided, output is written to the file (appending the appropriate extension if absent). The table string is also returned invisibly. |
The rendered table as a single character string, returned
invisibly. Also printed to the console unless out is specified.
m1 <- lm(mpg ~ cyl + hp, mtcars) m2 <- lm(mpg ~ cyl + hp + wt, mtcars) stargazer(m1, m2, type = "text") stargazer(m1, m2, type = "latex")m1 <- lm(mpg ~ cyl + hp, mtcars) m2 <- lm(mpg ~ cyl + hp + wt, mtcars) stargazer(m1, m2, type = "text") stargazer(m1, m2, type = "latex")