*! version 0.1.1 14Apr2020

Title

givregress -- 2SLS linear regressions by group with weights, clustering, and HDFE

Important: Please run gtools, upgrade to update gtools to
the latest stable version.

Warning: givregress is in beta and meant for testing; use in production NOT recommended. (To enable beta features, define global GTOOLS_BETA = 1.)

Syntax

givregress
depvar
(endogenous=instruments)
[exogenous]
[if] [in]
[weight]
[, by(varlist) absorb(varlist) options]

By default, results are saved into a mata class object named
GtoolsIV. Run mata GtoolsIV.desc() for
details; the name and contents can be modified via mata().
The results can also be saved into variables via gen()
or prefix() (either can be combined with mata(), but not
each other).

Note that extended varlist syntax is not supported. Further,
fweights behave differently that other weighting schemes; that
is, this assumes that the weight refers to the number of available
observations.

Options

Save Results
mata(name, [nob nose]) Specify name of output mata object and whether to save b and se

gen(...) Specify any of b(varlist), se(varlist), and hdfe(varlist). One per covariate is required (hdfe() also requires one for the dependent variable).

prefix(...) Specify any of b(str), se(str), and hdfe(str). A single prefix is allowed.

replace Allow replacing existing variables.

Options
by(varname) Group statistics by variable.

robust Robust SE.

cluster(varlist) One-way or nested cluster SE.

absorb(varlist) Multi-way high-dimensional fixed effects.

hdfetol(real) Tolerance level for HDFE algoritm (default 1e-8).

algorithm(str) Algorithm used to absorb HDFE: CG (conjugate gradient), MAP (alternating projections), SQUAREM (squared extrapolation), IT (Irons and Tuck).

maxiter(int) Maximum number of algorithm iterations (default 100,000). Pass . for unlimited iterations.

tolerance(real) Convergence tolerance (default 1e-8).

traceiter Trace algorithm iterations.

standardize Standardize variables before algorithm.

noconstant Whether to add a constant (cannot be combined with absorb()).

Gtools
compress Try to compress strL to str#.

forcestrl Skip binary variable check and force gtools to read strL variables.

verbose Print info during function execution.

bench[()] Benchmark various steps of the plugin. Optionally specify depth level.

hashmethod(str) Hash method (default, biject, or spooky). Intended for debugging.

oncollision(str) Collision handling (fallback or error). Intended for debugging.

aweights, fweights, and pweights are allowed.

Description

givregress estimates a linear IV model via 2SLS,
optionally weighted, by group, with cluster SE, and/or with multi-way
high-dimensional fixed effects. The results are by default saved
into a mata object (default GtoolsIV). Run mata
GtoolsIV.desc() for details; the following data is stored:

regression info
---------------

string scalar caller
model used; should be "givregress"

real scalar kx
number of (non-absorbed) covariates

real scalar cons
whether a constant was added automagically

real scalar saveb
whether b was stored

real matrix b
J by kx matrix with regression coefficients

real scalar savese
whether se was stored

real matrix se
J by kx matrix with corresponding standard errors

string scalar setype
type of SE computed (homoskedastic, robust, or cluster)

real scalar absorb
whether any FE were absorbed

string colvector absorbvars
variables absorbed as fixed effects

string colvector njabsorb
number of FE to be absorbed for each variaable and by level

string colvector savenjabsorb
whether njabsorb is stored

string colvector clustervars
cluster variables

string colvector njcluster
number of clusters per by level

string colvector savenjcluster
whether njcluster is stored

real scalar by
whether there were any grouping variables

string rowvector byvars
grouping variable names

real scalar J
number of levels defined by grouping variables

class GtoolsByLevels ByLevels
grouping variable levels; see GtoolsIV.ByLevels.desc() for details

variable levels (empty if without -by()-)
-----------------------------------------

real scalar ByLevels.anyvars
1: any by variables; 0: no by variables

real scalar ByLevels.anychar
1: any string by variables; 0: all numeric by variables

string rowvector ByLevels.byvars
by variable names

real scalar ByLevels.kby
number of by variables

real scalar ByLevels.rowbytes
number of bytes in one row of the internal by variable matrix

real scalar ByLevels.J
number of levels

real matrix ByLevels.numx
numeric by variables

string matrix ByLevels.charx
string by variables

real scalar ByLevels.knum
number of numeric by variables

real scalar ByLevels.kchar
number of string by variables

real rowvector ByLevels.lens
> 0: length of string by variables; <= 0: internal code for numeric variables

real rowvector ByLevels.map
map from index to numx and charx

Methods and Formulas

See the
online documentation
for details.

Examples

See the
online documentation
for examples.

Author

Mauricio Caceres

mauricio.caceres.bravo@gmail.com

mcaceresb.github.io

Website

gstats is maintained as part of the [R] gtools project at github.com/mcaceresb/stata-gtools

Acknowledgment

gtools was largely inspired by Sergio Correia's ftools:
https://github.com/sergiocorreia/ftools.

The OSX version of gtools was implemented with invaluable help from @fbelotti;
see https://github.com/mcaceresb/stata-gtools/issues/11.

References

See
online documentation
for the list of references.

Also see

help for
gtools