*! version 3.9 of help file 14Feb2024 for -bivariate.ado- Version 3.9, 14Feb2024

help for bivariateVersion 3.9, 14Feb2024

Title

bivariate - Bivariate correlations of a dependent variable with each independent/explanatory variable

Syntax

bivariate depvar indepvars [if] [in] [weight]
[using(filename)]
[, options]

format[(%fmt)] Display format
for all bivariate tables.
Invoking format without specifying a specific format selects format %9.3f.
Default format is %11.5f for all tables except that produced by
the inspect option, which has a default format of %8.0f.

Tabstat options
tabstat[(statlist)] Provide univariate summary statistics
on dependent and all independent variables using
casewise deletion.
Optionally choose which tabstat statistics to display by specifying
statlist.
See here for a list of available statistics.

Inspect options
inspect[(N_list)] Produce a table of the counts
of observations that are 0, positive, negative, unique, etc..
If N_list is omitted, the default is to provide all the counts produced
by Stata's inspect command.
Optionally choose which inspect statistics to display by specifying
N_list.
See here for a list of available counts.

Groupstat options
group(categorical_variable)

Use Stata's discrim_lda command and its postestimation command estat grsummarize
to construct a table of summary statistics for every value of the specified
categorical_variable. The bivariate correlation coefficients are calculated for the entire sample,
just as they would be without the group option.

groupstats(statlist)

Specify the summary statistics to be computed for each variable and each
value of categorical_variable. The available options are listed
here.

nowide Specify that the returned matrix of groups statistics be in
long format. The default is wide format. This option applies only
to the display and return of results from the group option.

Covariance and correlate options
correlate Report a table of correlation coefficients between
every pair of independent variables.

covariance Report a table of covariances between
every pair of independent variables.

Fixed effect options
demean Extract from the dependent variable depvar and all the
independent variables indepvars the fixed-effects defined by the option
absorb(fe_vars). Requires the absorb(fe_vars) option.
To use the option demean, the user must have installed hdfe, which is available
here.

fer2 Add a column to the results table to display the R^2 from a
regression of each independent variable on the fixed effect variables fe_vars
specified by the absorb(fe_vars) option. Requires the absorb(fe_vars) option.
To use the option fer2, the user must have installed reghdfe, which is available
here.

absorb(fe_vars) To be used in combination with either or both the options fer2 or demean,
the option absorb(fe_vars) is used to identify the categorical variables used as "fixed-effects"
in an estimation with dependent variable depvar and explanatory variables indepvars.

timeit reports the time required to invoke either fer2 or demean.

Esoteric options
novif Suppresses the computation and display
of the "Variance Inflation Factor." Unless suppressed,
the last column of the output presents the VIF score
from Stata's estat vif command.

uncentered Specifies that the VIF should be
"uncentered." See estat vif for details. This option is
not compatible with the option novif

list Specifies that all factor-variable operators
be stripped from variables in indepvars.
As a result, bivariate does not expand these variables in the output.
Time-series variables are not affected by this option.

obsgain Requests an additional column of output
which gives the number of additional observations that would be gained
by omitting each variable from indepvars. Specifying obsgain
automatically invokes the option list.

rownames(eqname|varname)

For dummy variables
in the independent variables list,
appends the value label of the larger value of the dummy as either
the prefix (eqname) or the suffix (varname) of the row label

matrix(matrixname) Specifies the name of the matrix of
bivariate statistics returned as r(matrixname).
Default is to return the matrix in r(bivariate)

rmcoll Remove collinear variables from the expanded list of
independent variables. This option is invoked automatically by
the option group(varname)}.

esample(newvarname [, replace])

Generates a new
variable named newvarname which is an indicator variable
equal to 1.0 for observations in the analysis sample
and zero otherwise.

depvar(varname) Specifies which of the variables listed after
the bivariate command is the dependent variable. Default is the first
listed variable.

nodummies Suppresses the two columns in the results table
which otherwise would display the means
of depvar for each of the two values of each dummy variable.

Reporting options
post Post the row vector of bivariate correlation coefficients
and the (diagonal) matrix of the variances of those correlations
to Stata's ereturn space as e(b) and e(V), so that
the correlation coefficients and their standard errors
can be stored with estimates store and subsequently
displayed by estimates table, etc.

using(filename) Write bivariate's output tables directly
to the MS Word or TeX file named filename using frmttable.
To write to an MS Word file, the named filename must end with the extension ".doc",
not the newer MS Word extension ".docx".
frmttable can be installed from Stata Journal's site
here.
By default, if the using(filename) option is not specified,
bivariate displays a clickable frmttable command after every table
displayed in the results window. See help for frmttable
for more information on how to customize the MS Word or TeX output.

addtable The bivariate tables are added to an existing
MS Word or TeX file specified by using(filename).

replace The MS Word or TeX file specified by using(filename)
can overwrite an existing file with the same name.

addnote(string) Add a text string as a note at the bottom of each
table bivariate writes to the MS Word or Tex file.
Requires the user to have installed frmttable and to specify the
using(filename) option.

tbivariate(string) Replace the default title on the bivariate
results table written to disc.
Requires the user to have installed frmttable and to specify the
using(filename) option.

ttabstat(string) Replace the default title on the tabstat
results table written to disc.
Requires the user to have installed frmttable and to specify the
using(filename) and the tabstat options.

tco(string) Replace the default title on the correlate
or covariance results table written to disc.
Requires the user to have installed frmttable and to specify the
using(filename) and either the correlate
or the covariance option.

tinspect(string) Replace the default title on the inspect
results table written to disc.
Requires the user to have installed frmttable and to specify the
using(filename) and the inspect options.

tgrouptab(string) Replace the default title on the group
results table written to disc.
Requires the user to have installed frmttable and to specify the
using(filename) and the group options.

tex Write a TeX file instead of MS Word file to disk.
Requires the user to have installed frmttable and to specify the
using(filename) option.

indepvars may include factor and time-series variables.
At least one explanatory variable is required.

by is allowed, but only the
results
from the last by group are returned or posted.
Alternatively, some of the functionality of by is available with the option
group(categorical_variable).

weights are in beta, to be used with care; see weight.

Description

bivariate produces a table of bivariate Pearson correlation coefficients
between a dependent variable and each of a set of independent variables.
As in the syntax for regress and most other Stata estimation commmands,
the first variable listed after the bivariate commmand is assumed to be the
dependent variable. This default can be overridden using the option
depvar(varname) to specify another variable as the dependent variable.
All calculations are performed on the subset of observations not missing for any of the variables
in the analysis (i.e. casewise or listwise deletion).
Also see the discussion of listwise deletion in the help for missing values.

Unless it is suppressed by the option novif, the last column of the output presents the
variance inflation factor
(VIF) for each of the independent or explanatory variables as computed by Stata's estat vif command.
For variables which regress would omit from the right-hand-side variables
due to multicollinearity, the VIF value is undefined because it would be infinitely large.
With the option rmcoll, bivariate suppresses all information on such
multicollinear variables.

If the tabstat or tabstat(statlist) option is chosen, bivariate executes Stata's tabstat
command to generate a table of descriptive statistics estimated on all variables in the analysis.
Statistics are estimated over the observations which are non-missing on all of the variables
in the analysis as well as non-missing on the variables specified in the options
group(varname) and/or absorb(fe_vars), if any.

With the group(varname) option, after presenting the results table on the entire sample,
bivariate groups the observations by categories of the grouping variable
varname and displays the summary statistics for each category in a separate columen.

bivariate accepts factor variables within the list of
independent variables, indepvars.
Unless the obsgain or list option is
specified, bivariate expands factor variables into a set of K dummy variables
so that the correlation of each with the dependent variable is separately revealed.
The VIF column of the table of bivariate results will display a missing value
for the VIF of the dummy variable that Stata would drop in a regression on the entire
set of dummies. To force a different selection of the category to be dropped,
specify the desired base level as explained here.

bivariate accommodates high-dimensional fixed effcts. See the remarks on
the fixed-effect options.

Discussion and further information on selected options

The typical estimation command estimates coefficients which describe how a set
of explanatory or "independent" variables are associated with one or more dependent variables
wihin the context of a model. Most commands use multiple independent variables
such that the coefficient estimate for a single independent variable is
"controlled" for the possibly "confounding" effects of the other independent variables.
The inferences drawn from an estimated model about the effects of each independent
variable are potentially affected by several key properties of
the independent variables. Among these properties are:

. the simple correlation of each independent variable, individually, with the dependent variable

. the collinearity of each independent variable with all of the other independent variables

. the number of observations which could be gained for the entire model if a given independent variable is either dropped from the model or imputed

. the mean and dispersion and other descriptive statistics of each independent variable for the estimation sample

. the number of zeros, unique values, integers, etc. for each independent variable

. for fixed effect estimation, the proportion of each variable's variation explained by the fixed effects

The examples
demonstrate some of the capabilities of bivariate described
in the rest of this section.
See Syntax for a complete list of options.

tabstat or tabstat(statlist) requests an optional table of univariate descriptive statistics
on the complete list of variables, with casewise deletion. The table is saved
in matrices r(StatTotal) and r(TransposedST).
If statlist is not supplied, this option produces a default tabstat
table containing the statistics: mean, p50, sd, cv, min, max, skewness.
Alternatively the user can specify a list of statistics selected from those
available here.
Unless explicityly requested, the number
of observations is excluded from the tabstat output on each variable,
but is instead separately saved in r(N).

inspect or inspect(N_list) requests an optional table composed
of the information produced by Stata's inspect command for each
variable in the analysis, with casewise deletion.
After execution of bivariate, the table is returned in matrix r(inspect).
If N_list is not supplied, this option produces a default 8-column
table containing the statistics: N, N_0, N_pos, N_neg, N_unique, ... etc..
Alternatively the user can specify a list of statistics selected from those
available here. Note that N_unique will display
as missing if the number of unique values is greater than 99.

obsgain requests an additional column of output
which gives the number of additional observations that would be gained
by omitting each variable from indepvars.
In order to work properly with factor variables, this option
automatically invokes bivariate's list option.
The variable which most constrains the sample size is returned
in the local macro r(maxobsgainvar) and the number of observations potentialy added
by omitting that variable is returned in r(maxobsgain).

fer2 and demean enable bivariate reveal how fixed-effects
change the bivariate and multivariate properties of the variables.
These two options can be specified individually or together.
Either of these options can be time-consuming on
a large data set or with a large number of independent variables.
The option timeit reports the time required to invoke these options.
See below for more information.

rownames(eqname|varname) For dummy or other factor variables
in the independent variables list, this option appends the value label of the larger value
of the dummy as either the prefix (eqname) or the suffix (varname)
of the row label. Try using rownames(eqname).

format and format(%fmt) specify how the descriptive
statistics are to be formatted. The default is to use a %9.0g format.

format without (%fmt) specifies that each variable's statistics be formatted
with the variable's current display format; see [D] format.

format(%fmt) specifies the format to be used for all
statistics. The maximum width of the specified format should not exceed
nine characters.

list specifies that all factor-variable operators and
time-series operators be removed from indepvars and that the descriptive statistics
output be computed on the resulting list of base variables.
This is an option of the Stata command fvrevar.
Use this option with care, since statistics like the mean
or the correlation coefficient which are computed on a categorical
factor variable are likely to be nonsense.
This option is automaticlly invoked by the option obsgain.

matrix(matrixname) designates a specific name for the saved matrix of bivariate results.
If the option is chosen, the matrix of bivariate results is saved as r(matrixname).
The default name is r(bivariate).

post By invoking this option, the user can subsequently access the bivariate
correlations and their standard errors with the table-making commands
estimates table, esttab, outreg, outreg2
and other commands that store coefficients and standard errors in Stata's
ereturn. space. The bivariate correlation coefficients between
the dependent variable and each of the independent variables are stored
in the row vector e(b) , while their squared standard errors
are stored as the diagonal elements of the matrix e(V).
The sample used to generate these estimates is stored in the
function e(sample). See Stored results.

Remarks

Prior to estimating any statistical model involving one or more dependent variables
and a set of explanatory or "independent" variables, the user typically
wants to understand the information content of individual variables
and the potential interactions among them which could cause problems of
multicollinearity and confounding. Common Stata commands for this purpose include
codebook, inspect,
tabstat, mean, correlation, estat summarize
and the user-written partchart. This program, bivariate adds to this
collection of commands the ability to make and export a table
containing the simple Pearson correlation coefficient between the dependent variable
and each of the independent variables, all computed on the estimation sample.

The bivariate command is designed to accompany an estimation command
like regress in order
to provide bivariate and (optionally) descriptive statistics
on the same variables over the same sample
as used in the estimation command. Like regress
and most estimation commands,
the bivariate command assumes the first variable is the dependent
variable and the rest are independent variables.

The basic syntax for bivariate looks like the basic syntax for
regress. Analagous to the command...

. regress price weight mpg i.rep78 foreign

<output omitted>

...the user can type:

. bivariate price weight mpg i.rep78 foreign

<output omitted>

For continuous independent/explanatory variables, bivariate presents the correlation coefficient
of each independent variable with the dependent variable and the t-statistic of
test of the null hypothesis that the correlation coefficient is zero, with a
p-value giving the significance level at which this hypothesis can be rejected
against a two-sided alternative.

If bivariate detects that a variable in the variable list is dichotomous,
it assumes that the variable is a dummy variable. In addition to presenting the correlation
coefficient, it presents the mean of the dependent variable for each of the two
values of that dichotomous variable. In this case, the t-statistic tests the
hypothesis that the two means are identical, while the p-value gives the
significance level at which this null can be rejected against a two-sided
alternative.

Unless the option novif is specified, the right-most column
of bivariate's output displays the
variance inflation factor
for each independent variable as computed by Stata's estat vif command.
For independent variable Xj, the VIF is defined as:

VIFj = 1/ ( 1 - R^2j)

where R^2j is the R^2 of the regression of Xj in all the other independent variables.
See ivvif
for an expanded calculation of VIF's in the context of instrumental variable regression.

While the obsgain option reveals when a single independent variable is
limiting the sample size, it does not reveal
that the sample could be increased by omitting two or more variables that are
missing on some of the same observatinos. For a more complete diagnosis of the patterns
of missing data, see misstable and user-contributed regmsng.

The list of independent variables for the bivariate command, indepvars,
can include factor variables. By default, bivariate
expands factor variables into temporary variables,
one for each category of the variable,
which match the temporary variables Stata uses behind the scenes
to represent a categorical independent variable in an estimation command.
The option list suppresses this default behavior so that
the factor variables are treated as if they were continuous.
But the bivariate statistics reported by bivariate
on these unexpanded factor variables must be interpreted with caution
unless the variable is
"ordinal".

Remarks on fixed-effect options.
With Sergio Correia's contribution of hdfe and reghdfe to Stata's user-written library,
Stata users can now estimate several models controlled for high-dimensional fixed effects.
These models include ordinary least squares regression (reghdfe),
instrumental variable regression (ivreghdfe) and
Poisson pseudo-likelihood regression (ppmlhdfe).
Furthermore, any model which complies with the assumptions of the Frisch-Waugh-Lovell theorem
can be controlled for multiple high-dimensional fixed effects by first "demeaning" the data
using hdfe and then estimating the model on the demeaned data.
"Demeaning" consists of replacing a variable in the analysis by the residual
from a regression of that variable on all the fixed effects.

The extraction of fixed-effects from a variable reduces the variable's variance
and therefore its information content.
To enable the user to guage how much of the variance of each independent variable
is explained by the fixed-effects alone, the bivariate option fer2
(think fixed-effect R-squared) adds a column to the results table
labeled "FE_R^2". This column presents the R^2 from an ordinary least squares
regression of each raw independent variable on only the fixed-effects
as computed by reghdfe.
To use the option fer2, the user must have installed hdfe, which is available
here.

When estimating a model on "demeaned" data, the bivariate correlations,
the variance-inflation factor (VIF) and the univariate descriptive statistics
provided by options tabstat and inspect are more informative
regarding potential interactions among the variables, multicollinearity
and the information content of individual variables
when they are also calculated on the "demeaned" data.
With the demean option, bivariate's results
are computed on the demeaned data. When options fer2 and demean
are both specified, the R^2 statistics in the fer2 column of the results table
are computed on the raw data and thus unchanged from their values
if the demean option were omitted.
To use the option demean, the user must have installed reghdfe, which is available
here.

Examples

Setup

. sysuse auto, clear

Produce a table of bivariate statistics measuring the strength
of two-way association between the dependent variable and
each of the independent variables and append a table of
descriptive univariate statistics.
Note the expansion of the factor variable i.rep78.

. bivariate price weight mpg i.rep78 foreign, tabstat

Results for the dependent variable: price and each of the independent variables:
weight mpg 1bn.rep78 2.rep78 3.rep78 4.rep78 5.rep78 foreign

Casewise deletion drops: 5 observations.

The analysis uses : 69 observations.
The variance inflation factor is: Centered

Table of bivariate correlation coefficients for the dependent variable: price

Coef. of Means of price:
| Correlation For D=0 For D=1 t-stat p-value VIF
-------------+------------------------------------------------------------------------------
weight | 0.54784 . . 5.36021 0.00000 4.12286
mpg | -0.45595 . . -4.19335 0.00008 3.27866
1.rep78 | -0.09451 6193.25373 4564.50000 -0.77707 0.43986 .
2.rep78 | -0.02235 6169.44262 5967.62500 -0.18297 0.85537 4.43973
3.rep78 | 0.08591 5928.20513 6429.23333 0.70577 0.48278 9.12609
4.rep78 | -0.01532 6172.35294 6071.50000 -0.12539 0.90059 7.82068
5.rep78 | -0.03510 6190.24138 5913.00000 -0.28750 0.77462 6.35944
foreign | -0.01736 6179.25000 6070.14286 -0.14215 0.88739 2.46363
For the following 1 variable(s), which regress would omit from a multiple regression
due to multicollinearity, the VIF value is undefined because it would be infinitely large.
1bn.rep78

If Gallup's -frmttable- is installed, click here:
frmttable , statmat(r(bivariate))

Option -tabstat-:
Descriptive statistics on the dependent and the independent variables:

| mean p50 sd cv min max skewness
-------------+-------------------------------------------------------------------------------------------
price | 6146.04348 5079.00000 2912.44025 0.47387 3291.00000 15906.00000 1.68797
weight | 3032.02899 3200.00000 792.85148 0.26149 1760.00000 4840.00000 0.11806
mpg | 21.28986 20.00000 5.86641 0.27555 12.00000 41.00000 0.99535
1.rep78 | 0.02899 0.00000 0.16899 5.83032 0.00000 1.00000 5.61514
2.rep78 | 0.11594 0.00000 0.32250 2.78157 0.00000 1.00000 2.39920
3.rep78 | 0.43478 0.00000 0.49936 1.14853 0.00000 1.00000 0.26312
4.rep78 | 0.26087 0.00000 0.44233 1.69558 0.00000 1.00000 1.08916
5.rep78 | 0.15942 0.00000 0.36875 2.31306 0.00000 1.00000 1.86075
foreign | 0.30435 0.00000 0.46350 1.52293 0.00000 1.00000 0.85042

If Gallup's -frmttable- is installed, click here:
frmttable , statmat(r(TransposedST))

With the obsgain option, the last column of bivariate output
reveals that the variable rep78 is constraining the sample size for the regression
because it has 5 fewer observations than do the other variables.
Output is omitted until the end of the examples
below.

. bivariate price weight mpg i.rep78 foreign, obsgain

< output omitted >

In addition to the descriptive statistics, the program returns in
r(...) the identity of the variables
with the largest values of the VIF and of obsgain.
The list of returned results is here:

. return list

< output omitted >

With the inspect option, bivariate also produces a table
of the results of Stata's inspect command like this:

. bivariate price weight mpg i.rep78 foreign, inspect

< output omitted >

By adding the post option, the user can store the correlation coefficients
in Stata's ereturn space for later retrieval by e.g. estimates table.
For example, in order to construct and display a single table of
the means of the right-hand-side variables as well as their bivariate
correlation coefficients and their multiple regression coefficients,
the user could execute the following commands.

. mean price weight mpg i.rep78 foreign

< output omitted >

. estimates store means

. bivariate price weight mpg i.rep78 foreign, post

< output omitted >

. estimates store correlations

. regress price weight mpg i.rep78 foreign

< output omitted >

. estimates store regression

. estimates table means correlations regression, t stat(N r2) b(%9.1fc) title(Dependent variable: price)

< output omitted >

Demonstrate that the descriptive statistics produced above
are for the same sample that would be used in the corresponding regression command.

. regress price weight mpg i.rep78 foreign

< output omitted >

. gen byte insample = e(sample)

. summ price weight mpg i.rep78 if insample

< output omitted >

. tab foreign if insample, sum(price)

< output omitted >

The matrices of bivariate statistics
and of descriptive statistics (if requested by the option tabstat)
can be formatted for cleaner listing and
can be retrieved for export.

. bivariate price weight mpg i.rep78 foreign, tabstat format(%9.3f)

< output omitted >

. matrix list r(bivariate)

< output omitted >

. matrix list r(TransposedST)

< output omitted >

Or use Stata's matlist command:

. matlist r(bivariate), format(%9.3f)

< output omitted >

. matlist r(TransposedST), format(%9.3f)

< output omitted >

John Luke Gallup's program frmttable can be used to produce publishable versions of the
matrices returned by bivariate.
For example, after executing the following two commands,
open the MS Word file called "word.doc" to see the resulting table:

. bivariate price weight mpg headroom foreign, novif

< output omitted >

. frmttable using word, replace statmat(r(bivariate))
rtitles("Vehicle weight" \ "Miles per gallon" \ "Headroom" \ "Foreign or domestic")
sdec(3,0,0,2,3,1,0) title("Table _. Bivariate relationships between vehicle price and each independent variables")

< output omitted >

Another way to use the programs together is
with the options group and groupstats.

. bivariate price weight mpg headroom, group(foreign) groupstats(n mean sd)

< output omitted >

. matrix list r(grouptab)

< output omitted >

. frmttable, statmat(r(grouptab))

< output omitted >

. frmttable, statmat(r(frmttable)) substat(1)

< output omitted >

Bivariate now works with time-series
as well as with factor variables}.
To illustrate this usage, switch to Stata's
data on young Women 14-26 years of age in 1968
from the US National Longitudinal Survey.
Before using time-series variables
we must tsset or xtset the data.

. webuse nlswork, clear

. tsset idcode year

< output omitted >

. label define unionlbl 0 "No union" 1 "Union"

. label values union unionlbl

. tab race union, mi

< output omitted >

To estimate the impacts of schooling and experience on the log of wages,
one might estimate the following equation, which uses Stata's factor variable
syntax to include both a linear and a quadratic term in age and Stata's
time-series syntax to include the previous year's weeks worked as well as
the current year for each individual.

. regress ln_w grade c.age##c.age wks_work L.wks_work i.race i.union

Source | SS df MS Number of obs = 6,943
-------------+---------------------------------- F(8, 6934) = 406.66
Model | 414.110272 8 51.7637839 Prob > F = 0.0000
Residual | 882.636102 6,934 .127291044 R-squared = 0.3193
-------------+---------------------------------- Adj R-squared = 0.3186
Total | 1296.74637 6,942 .18679723 Root MSE = .35678

------------------------------------------------------------------------------
ln_wage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
grade | .076018 .0020361 37.34 0.000 .0720266 .0800093
age | .0426677 .0061531 6.93 0.000 .0306057 .0547296
|
c.age#c.age | -.0007171 .0000985 -7.28 0.000 -.0009101 -.0005241
|
wks_work |
--. | .0038372 .0003787 10.13 0.000 .0030949 .0045795
L1. | .0029706 .0002123 13.99 0.000 .0025545 .0033867
|
race |
black | -.1152134 .0098106 -11.74 0.000 -.1344451 -.0959816
other | .0839718 .0424003 1.98 0.048 .0008542 .1670894
|
union |
Union | .1932287 .0100582 19.21 0.000 .1735116 .2129458
_cons | -.1775216 .0957583 -1.85 0.064 -.3652372 .010194
------------------------------------------------------------------------------

The above regression results suggest that each additional "grade" of
education increases wages by 7.6 percent, while an additional
week of work in the current year increases wages by 0.38 percent. Furthermore, additional
weeks of work the previous year are independently contributing 0.29 percent
to current wages. By using the margins command, we see
that the impact of age is positive at age 15-30, but negative
for older workers.

. margins, dydx(age) at(age==(15 (05) 45) ) vsquish

Average marginal effects Number of obs = 6,943
Model VCE : OLS

Expression : Linear prediction, predict()
dy/dx w.r.t. : age
1._at : age = 15
2._at : age = 20
3._at : age = 25
4._at : age = 30
5._at : age = 35
6._at : age = 40
7._at : age = 45

------------------------------------------------------------------------------
| Delta-method
| dy/dx Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
age |
_at |
1 | .0211552 .0032538 6.50 0.000 .0147767 .0275337
2 | .0139844 .0023181 6.03 0.000 .0094402 .0185286
3 | .0068136 .0014487 4.70 0.000 .0039737 .0096534
4 | -.0003572 .0008731 -0.41 0.682 -.0020689 .0013544
5 | -.0075281 .0011683 -6.44 0.000 -.0098182 -.0052379
6 | -.0146989 .0019764 -7.44 0.000 -.0185732 -.0108246
7 | -.0218697 .0028959 -7.55 0.000 -.0275465 -.0161929
------------------------------------------------------------------------------

Because the independent variables include factor and times-series variables, the
option rownames(eqname) improves the appearance of bivariate's
results by separating variables into continuous and discrete variable types
and labeling the values of discrete variables. The format option
is shorthand for format(%9.3f).

. bivariate ln_w grade c.age##c.age wks_work L.wks_work i.race i.union, rownames(eqname) format

Results for the dependent variable: ln_wage and each of the independent variables:
grade age c.age#c.age wks_work L.wks_work 1bn.race 2.race 3.race 0bn.union
1.union

Casewise deletion drops: 21591 observations.

The analysis uses : 6,943 observations.
The variance inflation factor is: Centered

Table of bivariate correlation coefficients for the dependent variable: ln_wage

Coef. of Means of ln_wage:
| Correla~n For D=0 For D=1 t-stat p-value VIF
-------------+------------------------------------------------------------------
Continuous |
grade | 0.458 . . 42.980 0.000 1.079
age | 0.216 . . 18.428 0.000 97.663
c.age#c.age | 0.207 . . 17.626 0.000 97.393
wks_work | 0.235 . . 20.135 0.000 1.350
L.wks_work | 0.300 . . 26.181 0.000 2.021
-------------+------------------------------------------------------------------
race |
white | 0.151 1.684 1.828 12.708 0.000 1.071
black | -0.162 1.830 1.674 -13.638 0.000 .
other | 0.040 1.785 1.955 3.329 0.001 1.033
-------------+------------------------------------------------------------------
union |
No_union | -0.195 1.936 1.739 -16.601 0.000 1.013
Union | 0.195 1.739 1.936 16.601 0.000 .
For the following 2 variable(s), which regress would omit from a multiple regression
due to multicollinearity, the VIF value is undefined because it would be infinitely large.
2.race "1.union"

The above display is useful in showimg the mean values of the dependent
variable for each value of a categorical value. For example,
depending on the individual's race, the mean value of the log of wages is
1.828, 1.674 or 1.785. The VIF statistic diagnosing multicollinearity is
reasonable for all the variables except age and c.age#c.age
(age-squared). These values are exagerated because each is naturally
very highly correlated with the other.

An alternative display is obtained with the option list as follows.

. bivariate ln_w grade c.age##c.age wks_work L.wks_work i.race i.union, list format

Results for the dependent variable: ln_wage and each of the independent variables:
grade age wks_work L.wks_work race union

Casewise deletion drops: 21591 observations.

The analysis uses : 6,943 observations.
The variance inflation factor is: Centered

Table of bivariate correlation coefficients for the dependent variable: ln_wage

Coef. of Means of ln_wage:
| Correla~n For D=0 For D=1 t-stat p-value VIF
-------------+------------------------------------------------------------------
grade | 0.458 . . 42.980 0.000 1.059
age | 0.216 . . 18.428 0.000 1.877
wks_work | 0.235 . . 20.135 0.000 1.295
L.wks_work | 0.300 . . 26.181 0.000 2.016
race | -0.134 . . -11.252 0.000 1.027
union | 0.195 1.739 1.936 16.601 0.000 1.008

The above display shows the same bivariate correlation coefficients
and t-statistics for the continuous variables, but somewhat different
VIF statistics. Invoking list instructs bivariate to
treat all factor variables as continous and to avoid repeating a variable
which appears in more than one factor variable. As a result,
the variable age now has a VIF of 1.877, indicating that it is
not multicollinear with any of the other variables in the analysis.
When using the list option, the user must be careful in
interpeting bivariate's reported correlation coefficient,
t-statistic and VIF statistic for any categorical variable
with more than two values. In this example,
because the variable i.race has three values in the data
and the relative magnitudes of those variables are arbitrary,
bivariate with the list option reports meaningless
correlation, t, p and VIF statistics for this variable.

We learn from the above bivariate display that case deletion has dropped
21,591 observations.
By specifying the option obsgain, we can investigate which of the right-hand-side
variables is responsible for dropping the most observations.

. bivariate ln_w grade c.age##c.age wks_work L.wks_work i.race i.union, obsgain format

< some output omitted >

Table of bivariate correlation coefficients for the dependent variable: ln_wage

Coef. of Means of ln_wage:
| Correla~n For D=0 For D=1 t-stat p-value VIF Obs Gai~d
-------------+-----------------------------------------------------------------------------
grade | 0.458 . . 42.980 0.000 1.059 0.000
age | 0.216 . . 18.428 0.000 1.877 7.000
wks_work | 0.235 . . 20.135 0.000 1.295 176.000
L.wks_work | 0.300 . . 26.181 0.000 2.016 11904.000
race | -0.134 . . -11.252 0.000 1.027 0.000
union | 0.195 1.739 1.936 16.601 0.000 1.008 3406.000

In order to count the number of
observations that could be added by excluding a catagorical variable,
obsgain automatically invokes the list option. The above bivariate results table,
shows that inclusion of the weeks worked in the previous year costs
the analysis 11,904 observations, while inclusion of the variable i.union
loses only 3,406.

Since these data include an average of 6.06 observations
on each of 4,711 individuals,
an alternative analytical approach to estimating this wage equation would be
to introduce a fixed-effect for each individual. The regression results using
areg are:

. areg ln_w grade c.age##c.age wks_work i.race i.union, ab(idcode)

note: grade omitted because of collinearity
note: 2.race omitted because of collinearity
note: 3.race omitted because of collinearity

Linear regression, absorbing indicators Number of obs = 18,847
Absorbed variable: idcode No. of categories = 4,126
F( 4, 14717) = 448.18
Prob > F = 0.0000
R-squared = 0.7595
Adj R-squared = 0.6921
Root MSE = 0.2590

------------------------------------------------------------------------------
ln_wage | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
grade | 0 (omitted)
age | .0279435 .0034585 8.08 0.000 .0211644 .0347225
|
c.age#c.age | -.0002475 .0000551 -4.49 0.000 -.0003555 -.0001396
|
wks_work | .0011334 .000092 12.32 0.000 .000953 .0013138
|
race |
black | 0 (omitted)
other | 0 (omitted)
|
union |
Union | .0986851 .0071023 13.89 0.000 .0847637 .1126066
_cons | 1.038972 .0527042 19.71 0.000 .9356651 1.142279
------------------------------------------------------------------------------
F test of absorbed indicators: F(4125, 14717) = 9.586 Prob > F = 0.000

Naturally variables that do not change over time for an individual,
such as grade and {i.race} are swept out of the regression
by the fixed effect. But some individuals change union membership
over time and all individuals age. It's interesting that,
when controlling for fixed-effects,
the estimated effect of union membership
is an increase of only 10% in wages, about half of the estimated
difference in wages between union and nonunion members when
fixed-effects are omitted. Also,
the estimated impact of age looks quite different here,
with the maximimum wage occurring between 35 and 40 instead of
at age 20. (To see this latter result, execute the following
margins command.)

. margins, dydx(age) at(age==(15 (05) 45) ) vsquish

< output omitted >

The bivariate utility can be used to inform a fixed-effects
estimation by including the option absorb(fe_vars)
and one or both of the options fer2 or demean.
Here is the output of bivariate with the fer2 option
for the variables in the above estimated fixed-effects regression.

. bivariate ln_w grade c.age##c.age wks_work i.race i.union, format rownames(eqname) absorb(idcode) fer2

Results for the dependent variable: ln_wage and each of the independent variables:
grade age c.age#c.age wks_work 1bn.race 2.race 3.race 0bn.union 1.union

Casewise deletion drops: 9687 observations.

The analysis uses : 18,847 observations.
The variance inflation factor is: Centered

Table of bivariate correlation coefficients for the dependent variable: ln_wage

Coef. of Means of ln_wage:
| Correla~n For D=0 For D=1 t-stat p-value VIF FE_R^2
-------------+-----------------------------------------------------------------------------
Continuous |
grade | 0.445 . . 68.149 0.000 1.061 1.000
age | 0.170 . . 23.720 0.000 87.265 0.434
c.age#c.age | 0.163 . . 22.645 0.000 86.273 0.439
wks_work | 0.271 . . 38.688 0.000 1.244 0.279
-------------+-----------------------------------------------------------------------------
race |
white | 0.137 1.658 1.799 19.029 0.000 1.073 1.000
black | -0.146 1.800 1.648 -20.274 0.000 . 1.000
other | 0.031 1.756 1.894 4.263 0.000 1.031 1.000
-------------+-----------------------------------------------------------------------------
union |
No_union | -0.202 1.927 1.705 -28.297 0.000 1.019 0.594
Union | 0.202 1.705 1.927 28.297 0.000 . 0.594
For the following 2 variable(s), which regress would omit from a multiple regression
due to multicollinearity, the VIF value is undefined because it would be infinitely large.
2.race "1.union"

The option fer2 (which requires specification of the fixed effect
variables with absorb(idcode)), adds a column labeled
"FE_R^2" to the displayed results.
For each independent variable, this column presents the
R^2 of a regression of that variable on the fixed-effects
excluding all the other right-hand-side variables.
This statistic reveals the proportion of the variance in each
independent variable that is explained by the fixed-effects alone.
As expected, for variables such as grade and i.race
that remain constant for a given individual, the value of this R^2 is 1.000.
These are the same variables that the areg command
drops from the regression because they are "swept out"
by the fixed-effects. In contrast only 59.4% of the variance of the
i.union variable is swept out by the individual's idcode
and only 27.9% of the wks_work variable is swept out.
The analyst should be cautious about retaining any independent variables
for which "FE_R^2" exceeds, say, 0.90.

In the above table of results, the correlation coefficients and VIF statistics are
unaffected by the options fer2 and absorb(idcode).
However, for a fixed effects regression, the user may be more interested
in the correlations and VIF statistics computed on the variables after the fixed-effects
have been swept out. Adding the demean option provides these
"within" statistics estimated on the data after the fixed-effects
have been extracted.

. bivariate ln_w grade c.age##c.wks_work i.race i.union, format absorb(idcode) fer2 demean

Results for the demeaned dependent variable: ln_wage and each of the demeaned independent variables:
grade age wks_work race union

User has specified the options -demean- and absorb(idcode)-,
which invoke hdfe to demean the data prior to computing -bivariate- results.

Casewise deletion drops: 9687 observations.

The analysis uses : 18,847 observations.
The variance inflation factor is: Centered

Table of bivariate correlation coefficients for the demeaned dependent variable: ln_wage

Coef. of
| Correla~n t-stat p-value VIF FE_R^2
-------------+-------------------------------------------------------
grade | -0.000 -0.000 1.000 . 1.000
age | 0.291 41.039 0.000 1.313 0.434
wks_work | 0.233 32.289 0.000 1.318 0.279
union | 0.120 16.297 0.000 1.004 0.594
For the following 1 variable(s), which regress would omit from a multiple regression
due to multicollinearity, the VIF value is undefined because it would be infinitely large.
grade

Stored results in return

scalars:
r(N) Number of observations on which all variables are present (i.e. after casewise deletion)

r(maxobsgain) Maximum number of observations to be gained by omitting a single variable (if obsgain specified)

r(maxvifval) Maximum value of the VIF statistic (unless novif is specified)

r(meanvif) Mean value of the VIF statistic (unless novif is specified)

r(nmsngvif) Number of explanatory variables with undefined VIF (unless novif is specified)

r(df_a) Number of degrees of freedom absorbed by the fixed-effects (if absorb(fe_vars) specified)

r(maxfer2val) Maximum value of the R^2 of individual right-hand-side variables on the fixed-effects (if fer2 is specified)

macros:
r(maxobsgainvar) Name of the variable which, if omitted,
would most increase the number of observations(if obsgain specified)

r(maxvifvar) Name of the variable with the highest VIF statistic (unless novif is specified)

r(msngvif) Names of explanatory variables with undefined VIF (unless novif is specified)

r(N_stats) Number of statistics requested in the
groupstats(statlist) option (excluding the sample size)

r(statlist) Names of the statistics included in the
groupstats(statlist) option (excluding the sample size)

r(esamplevar) Name specified in the
esample(newvarname [, replace]) option for
the new indicator variable generated by bivariate,
which defines the analysis sample.

r(indepvars) List of user-provided explanatory variables
after expansion of the factor variables.

r(fe_vars) List of fixed-effect variables specified in the option
absorb(fe_vars) (if absorb(fe_vars) specified)

r(maxfer2var) Name of the variable with the largest R^2 when regressed on the fixed-effects (if fer2 is specified)

matrices:
r(bivariate) Main results of the bivariate command stored as
a matrix with K-1 rows, one for each explanatory variable in indepvars.
If the matrix(matrixname) option has been specified, the same results are stored
in a matrix called r(matrixname).

r(vifmat) VIF statistics for the K-1 independent variables in indepvars, sorted from largest to smallest (unless novif is specified)

r(grouptab) Results of the group(varlist) and groupstats(statlist)} options, if specified

r(StatTotal) Results of the tabstat option,
if specified. Dimension S x K, where S is the number of
requested statistics

r(TransposedST) Transposed r(StatTotal) of dimension K x S (if tabstat specified)

r(inspect) Table of the results of inspect for each variable,
after casewise deletion (if inspect specified)

r(fe_r2mat) Matrix of dimension (K-1) by 2 which returns the results
designated above as FE_R^2
of regressing each independent variable only on the fixed effects (column 2).
With the undocumented option fe_r2j, the matrix contains two more columns.
Column 3 (labeled R^2j) contains the R^2 of regressing each independent variable
on all other independent variables and the fixed effects.
Column 4 presents the
variance inflation factor calculated from column 3 as 1/(1 - R^2j).
The matrix fe_r2mat is only returned if absorb(fe_vars) is specified.

Posted results in ereturn

If the post option is specified, the following results are posted in the ereturn space.

scalars:
e(N) Number of observations on which all variables are present

macros:
e(cmd) Name of the command, here bivariate

e(cmdline) The command line issued to bivariate.

e(depvar) Number of statistics requested in the groupstats(statlist) option (excluding the sample size)

e(varlist) Names of the statistics included in the groupstats(statlist) option (excluding the sample size)

e(marginsnotok) The margins command is not available after bivariate.

e(properties) b V.

matrices:
e(b) Main results of the bivariate command stored as
a row matrix with K-1 columns, where K is the number of explanatory variables in indepvars.

e(V) Triangular matrix containing on the diagonal the variances of the
K-1 independent variables.

functions:
e(sample) marks estimation sample. An alternative to the option
esample(newvarname [, replace])

Acknowledgements

To enable bivariate to write its formatted result matrices to a MS Word or TeX file
on disc, this program calls Luke Gallup's frmttable
which the user must separately install from the Stata Journal repository
here.
Gallup's paper in the Stata Journal provides an introduction and user's guide
to frmttable, which also has a comprehensive set of help files.

Gallup, John Luke. 2017.
"A programmer’s command to build formatted statistical tables,"
The Stata Journal, Vol. 12, No. 4, pp. 655-673.
Available: here

To implement its fixed-effect options, new in version 3.6,
this program calls Sergio Correia's hdfe and reghdfe
which the user must separately install from the SSC repostory.
Install hdfe by clicking on this
link.
Install reghdfe from SSC by clicking
here.
The help file for reghdfe acknowledges the author's debt to other Stata contributors,
a debt which I inherit.
His PowerPoint presentation from the 2016 Stata Users
Conference is here.
The latest version of his working paper is:

Correia, Sergio. 2017. "Linear Models with High-Dimensional Fixed Effects:
An Efficient and Feasible Estimator" Working Paper.
Available: here

Author

Mead Over,
Center for Global Development, Washington, DC 20036 USA. Email:
MOver@CGDev.Org if you observe any
problems.