Instrumental-variables regression on a database backend
Description
Estimates a linear IV model via exact sufficient statistics on a database backend. The current implementation supports three exact strategies:
-
strategy = “moments”for models without absorbed fixed effects. -
strategy = “compress”for repeated no-FE design rows. -
strategy = “demean”for one or more absorbed fixed effects.
Multi-way fixed effects use exact alternating projections when there are more than two fixed effects, or when two-way fixed effects are unbalanced or weights are supplied.
Usage
dbivreg(
fml,
conn = NULL,
table = NULL,
data = NULL,
path = NULL,
weights = NULL,
vcov = c("iid", "hc1"),
strategy = c("auto", "moments", "demean", "within", "compress", "mundlak"),
compress_ratio = NULL,
compress_nmax = 1e+06,
cluster = NULL,
ssc = c("full", "nested"),
sql_only = FALSE,
data_only = FALSE,
drop_missings = TRUE,
verbose = getOption("dbreg.verbose", FALSE),
...
)
Arguments
fml
|
A fixest-style IV formula. Use y ~ x1 + x2 | d ~ z for models without absorbed fixed effects, and y ~ x1 + x2 | fe1 + fe2 + fe3 | d ~ z when fixed effects are present. The IV block must always be the final pipe-separated block. Regressors and instruments can include interactions and fixest-style i() terms (see sql_model_matrix()).
|
conn
|
Database connection, or NULL to create an ephemeral DuckDB connection.
|
table, data, path
|
Mutually exclusive data source arguments with precedence table > data > path.
|
weights
|
Optional character string naming an observation-weight column. |
vcov
|
Character string or one-sided clustering formula. Character options are “iid” and “hc1”.
|
strategy
|
Character string selecting the IV backend. Supported values are “auto” (default), “moments”, “demean” (alias “within”), “compress”, and “mundlak”. The latter currently errors because it is not yet implemented for IV. As in dbreg(), “auto” chooses “compress” when the data compress well (see compress_ratio and compress_nmax), and otherwise “moments” (no FE) or “demean” (FE). Since IV compression does not yet support fixed effects, models with FE always use “demean”.
|
compress_ratio, compress_nmax
|
Thresholds (compression ratio and maximum compressed rows) that decide whether strategy = “auto” chooses “compress”. Same defaults and meaning as in dbreg(); see its Acceleration Strategies section.
|
cluster
|
Optional clustering variable, supplied as a one-sided formula or character string. |
ssc
|
Character string controlling the small-sample correction for clustered standard errors. Options are “full” (default) or “nested”. With “nested”, fixed effects nested within the cluster variable are excluded from K, matching the default behavior of fixest::feols. See dbreg() for details.
|
sql_only
|
Logical indicating whether to return only the underlying SQL query. |
data_only
|
Logical indicating whether to return only the aggregated sufficient statistics. |
drop_missings
|
Logical indicating whether incomplete cases should be dropped. |
verbose
|
Logical indicating whether progress messages are printed. |
…
|
Additional unused arguments. |
Value
A list of class “dbivreg” and “dbreg”.