*! version 1.0.0 5may2018
xtavplot -- Added-variable plots for panel data estimation

Syntax

xtavplot indepvar
[, options]

options

Plot
marker_options change look of markers (color,
size, etc.)

marker_label_options add marker labels;
change look or position

xlim(# [#]), ylim(# [#]) limit
the ranges of the x and y residuals displayed

addmeans rescale the residuals, regression line
and confidence intervals to be centered on the means of x and y
instead of zero

generate(exvar eyvar) save the values of x and y residuals
in new variables

nodisplay suppress display of plot

Regression line
rlopts(cline_options) affect rendition of
the regression line

nocoef turns off display of coefficent below graph

Confidence interval
noci turns off confidence interval

ciunder puts confidence intervals underneath scatter

level(level:#) specifies the confidence level

ciopts(fitarea_options:ci_options) affect rendition of
the confidence

ciplot(graph_twoway:plottype) how to plot CIs;
default is ciplot(rline);
a common alternative is ciplot(rarea)

Add plots
"addplot(addplot_option:plot)" add other plots to the
generated graph

Y axis, X axis, Titles, Legend, Overall
twoway_options any options documented in
[G-3] twoway_options, except for by()

Description of xtavplot

xtavplot creates an added-variable plot (a.k.a. partial-regression leverage
plot, partial regression plot, or adjusted partial residual plot) after
xtreg, fe (fixed-effects estimation), xtreg, re (random-effects
estimation) or xtreg, be (between-effects
estimation). xtavplot cannot be used after xtreg, mle or
xtreg, pa.

indepvar is an independent (x) variable (a.k.a. predictor, carrier, or
covariate) that may or may not be included in the preceding estimation.

xtavplot shows the partial correlation between one indepvar and
the depvar from a multivariate panel regression.

Besides showing the relationship between the indepvar and the depvar
controlling for the other regressors, xtavplot is useful for visually
identifying which outlier observations have a big effect on the estimated
coefficient.

After fixed-effects estimation, the plotted e(x|X) values are the
residuals from the
regression of x on the other X variables in the original
regression, and the plotted e(y|X) values are the residuals
from the regression of y on the other X variables.

After between-effects estimation, e(av.x|av.X) and
e(av.y|av.X) are the residuals from the
regression of per-unit means of the indepvar (av.x) and
depvar (av.y) on the per-unit means of the other
independent (av.X) variables.

After random-effects estimation, e(x*|X*) and e(y*|X*)
are the residuals from the
regression of heteroskedasticity-corrected indepvar (x*)
and heteroskedasticity-corrected depvar (y*) on the other
heteroskedasticity-corrected independent (X*) variables.

The fitted line shown in the graph is the least squares fit between the
residuals. For each of the three panel data estimation methods, the fitted line
has the same slope as estimated coefficient on the indepvar in
the preceding regression.

By construction, the residuals e(x|X) and e(y|X) each have a mean
of zero, and the regression line fitted between them passes exactly
through e(x|X)=0 and e(y|X)=0. At that point, the confidence
interval has zero width, giving it an unfamiliar shape. Note that this
also happens in a conventional regression when all the independent variables
have a value of zero and there is no constant term.

Options for xtavplot

Plot

marker_options
affect the rendition of markers drawn at the plotted points, including
their shape, size, color, and outline; see [G-3] marker_options.

marker_label_options
specify whether and how markers are to be labeled;
see [G-3] marker_label_options.

xlim(# [#]), ylim(# [#]) limit
the range of the indepvar and depvar residuals displayed. If
only one number is specified, residuals with a value below that number will
not be displayed in the scatter plot. If two numbers are specified, residuals
below that first number and above the second number will not be displayed.

Excluding observations of the residual does not affect the slope of the regression
line in the graph. The purpose of these options is to avoid situations where
outlying observations cause a lot of extra white space in the graph, obscuring
display of the relationship between the variables. Make sure that the undisplayed observations are not important
to the estimated relationship. Since panel datasets are typically large,
it is common to have one or more distant outliers which don't significantly affect
the estimates.

addmeans rescales the scatterplot values, the regression line and the
confidence intervals to be centered on the mean values of the x and
y variables instead of being centered on zero by default. This may make
the plot more visually intuitive, but it is important to make clear to viewers
that the graph is showing conditioned values rather than the original data.

generate(exvar eyvar) saves the values of the x and y residuals
in variables named by the user. The user must specify two variable names for
exvar and eyvar. These
residuals can be used for subsequent calculations or graphing commands.

nodisplay suppresses display of the plot. This is mainly useful
for users creating their own plots with generate(exvar eyvar).

Regression line

rlopts(cline_options) affects the rendition of the regression
(fitted) line. See [G-3] cline_options.

nocoef turns off display below the graph of the regression coefficent,
standard error and t statistic.

Confidence interval

noci turns off display of the confidence interval on the graph.

ciunder confidence interval will be graphed underneath the scatter
plot (i.e. data scatter is graphed on top of confidence interval). This is
mainly useful when graphing a solid confidence interval with option
ciplot(rarea).

level(#) specifies the confidence level, in percent,
for confidence interval of the coefficients; see help level.

ciopts(line_options) affects how the upper and lower
confidence interval lines are rendered.
See [G-3] cline_options.
If you specify ciplot(), then rather than using
cline_options, you should specify whichever options are appropriate for
the plottype.

ciplot(plottype)
specifies how the confidence interval is to be plotted. The
default is ciplot(rline), meaning that the prediction will be
plotted by graph twoway rline.

A common alternative is ciplot(rarea), which will
substitute lines around the prediction for shading.
See [G-2] graph twoway for a list of plottype
choices. You may choose any plottypes that expect two y variables
and one x variable.

Add plots

addplot(plot) provides a way to add other plots to the generated graph.
See [G-3] addplot_option.

Y axis, X axis, Titles, Legend, Overall

twoway_options are any of the options documented in
[G-3] twoway_options, excluding by(). These include options
for titling the graph (see [G-3] title_options) and for saving
the graph to disk (see [G-3] saving_option).

Examples

Setup

. webuse nlswork

. keep in 1/1000

. xtreg ln_w ttl_exp age c.age#c.age not_smsa south, fe

Added-variable plot

. xtavplot ttl_exp

With solid confidence interval area

. xtavplot ttl_exp, ciplot(rarea) ciunder

With +'s as marker symbols, no confidence interval and no coefficient reporting

. xtavplot ttl_exp, msymbol(+) noci nocoef

Stored results

xtavplot stores the following in r():

Scalars

r(coef) the estimated coefficient of the added variable

r(se) the standard error of the estimated coefficient

Author

John Luke Gallup, Portland State University, USA
jlgallup@pdx.edu