| Type: | Package |
| Title: | Beautiful Regression Tables for Modern Econometrics Packages |
| Version: | 0.1.0 |
| Date: | 2026-06-30 |
| 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. |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| Imports: | stats |
| Suggests: | fixest (≥ 0.11.0), alpaca, plm, sandwich, wooldridge, stargazer, knitr, rmarkdown, testthat (≥ 3.0.0) |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-07-09 12:50:53 UTC; tzylkin |
| Author: | Tom Zylkin [aut, cre] |
| Maintainer: | Tom Zylkin <tzylkin@richmond.edu> |
| Repository: | CRAN |
| Date/Publication: | 2026-07-17 14:20:02 UTC |
Cluster-robust variance-covariance matrix for alpaca feglm
Description
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.
Usage
alpaca_vcovCL(mod, cluster)
Arguments
mod |
A fitted |
cluster |
A one-sided formula identifying the clustering variable(s).
Use |
Value
A square diagonal matrix of class "vcovAlpacaCL" with a
"cluster" attribute containing the cluster formula.
Examples
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")
}
Heteroskedasticity-robust variance-covariance matrix for alpaca feglm
Description
Wraps summary(mod, type = "sandwich") and returns a diagonal
variance-covariance matrix that stargazer recognises and
labels as "heteroskedasticity-robust standard errors".
Usage
alpaca_vcovSandwich(mod)
Arguments
mod |
A fitted |
Value
A square diagonal matrix of class "vcovAlpacaSandwich" with
squared sandwich standard errors on the diagonal.
Examples
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")
}
Extract a standardised model record from a regression object
Description
Internal S3 generic consumed by format_table. Not intended
for direct use.
Usage
extract_model(model, vcov_override = NULL, se_override = NULL, ...)
Arguments
model |
A fitted model object. |
vcov_override |
A pre-computed variance-covariance matrix, or
|
se_override |
A named numeric vector of standard errors, or
|
... |
Currently unused. |
Value
A named list (model record) with the following fields:
- coef_names
Character vector of coefficient display names.
- coefs
Numeric vector of coefficient estimates.
- se
Numeric vector of standard errors.
- tstat
Numeric vector of t- or z-statistics.
- pval
Numeric vector of two-sided p-values.
- nobs
Integer; number of observations.
- fit
Named list of fit statistics (R-squared, F-statistic, log-likelihood, etc.; content varies by model type).
- fixed_effects
Character vector of fixed-effect variable names;
character(0)if none.- reports_fe
Logical;
TRUEfor models that absorb fixed effects.- se_label
Character; human-readable description of the SE type for use in the table note.
- model_label
Character; estimator name for the column header (e.g.
"OLS","Logit","FE").- dep_var
Character; dependent variable name extracted from the model formula.
Assemble table data from a list of model records
Description
Internal; called by stargazer.
Usage
format_table(
records,
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("*", "**", "***"),
no.space = FALSE,
obs.label = "Observations"
)
Arguments
records |
List of model_record objects from |
covariate.labels |
Character vector of display names for covariates,
applied positionally after |
coef.rename |
Named character vector mapping raw coefficient names to
display names before the union is computed (e.g.
|
omit |
Character vector of regex patterns; matching covariates are dropped. |
keep |
Character vector of regex patterns; only matching covariates
are kept (applied after |
omit.stat |
Character vector of stat identifiers to suppress. |
digits |
Integer; decimal places for coefficients and SEs. |
star.cutoffs |
Numeric vector of p-value thresholds (ascending). |
star.char |
Character vector of star strings. |
no.space |
Logical; suppress blank spacer rows. |
obs.label |
Character; label for the Observations row. Default
|
Render a table_data object as a plain-text string
Description
Internal; called by stargazer when type = "text".
Usage
render_ascii(
table_data,
title = "",
dep.var.caption = "Dependent variable:",
column.labels = NULL,
notes = NULL,
notes.append = TRUE
)
Arguments
table_data |
List returned by |
title |
Table title string. |
dep.var.caption |
Caption above the dependent-variable line. |
column.labels |
Optional character vector of column labels. |
notes |
Additional note strings. |
notes.append |
Logical; if |
Render a table_data object as an HTML string
Description
Internal; called by stargazer.
Usage
render_html(
table_data,
title = "",
dep.var.caption = "Dependent variable:",
column.labels = NULL,
notes = NULL,
notes.append = TRUE,
notes.label = "Note:"
)
Arguments
table_data |
List returned by |
title |
Table caption string. |
dep.var.caption |
Caption above the dependent-variable line. |
column.labels |
Optional character vector of column labels (overrides model_labels in the header). |
notes |
Additional note strings appended after the SE note. |
notes.append |
Logical; if |
notes.label |
Label preceding the note text. |
Render a table_data object as a LaTeX string
Description
Internal; called by stargazer.
Usage
render_latex(
table_data,
title = "",
label = "",
dep.var.caption = "\\textit{Dependent variable:}",
column.labels = NULL,
font.size = NULL,
notes = NULL,
notes.append = TRUE,
notes.align = "l",
notes.label = "\\textit{Note:} ",
style = "stargazer2"
)
Arguments
table_data |
List returned by |
title |
Table caption string. |
label |
LaTeX label string ( |
dep.var.caption |
Caption above the dependent-variable line (empty string suppresses the row entirely). |
column.labels |
Optional character vector of column labels. |
font.size |
LaTeX font-size command (e.g. |
notes |
Additional note strings appended after the SE note. |
notes.append |
Logical; if |
notes.align |
Alignment of the notes cell. |
notes.label |
Label preceding the note text. |
style |
One of |
Produce Publication-Quality Regression Tables
Description
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.
Usage
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
)
Arguments
... |
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. |
Value
The rendered table as a single character string, returned
invisibly. Also printed to the console unless out is specified.
Examples
m1 <- lm(mpg ~ cyl + hp, mtcars)
m2 <- lm(mpg ~ cyl + hp + wt, mtcars)
stargazer(m1, m2, type = "text")
stargazer(m1, m2, type = "latex")
Render a summary statistics table
Description
Internal; called by stargazer when its first argument is a
data.frame or matrix.
Usage
stargazer_summary(
data,
type,
title = "",
label = "",
font.size = NULL,
covariate.labels = NULL,
omit = NULL,
keep = NULL,
digits = 3L,
summary.stat = NULL,
median = FALSE,
notes = NULL,
notes.append = TRUE,
notes.align = "l",
notes.label = "",
out = NULL
)