help fedistr

fedistr Visualize distributions after absorbing fixed effects and covariates

Syntax

fedistr
varlist [if] [in]
[weight] , [options]

Absorbed variables
fe(varlist) Fixed effects variables and categorical controls.

controls(varlist) Continuous control variables (used as linear controls).

Stratify into subsamples
by(var) Plots separate distributions for each level of the specified variable.

Plotted distribution(s)
compare Additionally plots the original distributions before absorbing FEs/covariates.

histogram Plots histograms (the default).

density Plots kernel densities.

bins(num) Specifies the number of bins of histograms.

width(num) Specifies the width of histogram bars.

bwidth(num) Specifies the bandwidth of density functions.

Additonal parameters
percentiles(numlist) Includes information on specified percentiles p of the distributions (0<p<100).

nobs Includes the number of non-missing observations.

Variable transformations
standardize Bring all variables on a scale with a mean of zero and a standard deviation of one (applied before residualization).

log Use the natural logarithms of all variables (applied before residualization).

logvvar(varlist) Only use logged values of specified variables.

winsor(numlist) Winsorize the variables at the specified percentiles p before residualization (0<p<100).

winsorres(numlist) Winsorize at the specified percentiles after residualization.

meancenter Add back the means to all variables after residualization.

Note: the transformations are implemented in the following order: winsorize original variable, log, standardize, residualize, add mean back, winsor residualized.

Sample manipulation
commonsample Ensures a common sample across all plots by dropping all observations with missings on any of the specified variables.

dropsingle Drop singleton observations, i.e. observations with n=1 within the specified fixed effects and/or by.

dropzerovar Drop observations that do not vary within the specified fixed effects and/or by.

Keep variables in dataset
keepvars Retain the residualized and possibly transformed variables in the dataset (saved with suffix _res).

replace Overwrite the existing version of variables instead of generating a new variable.

Scheme and colors
plotscheme(str) Defines an alternative graph scheme, such as plotscheme(white_tableau). See the collection in https://github.com/asjadnaqvi/stata-schemepack.

colorscheme(str) Defines a custom color palette (e.g. colorscheme(tableau)). To define your own colors, use a list of hex colors (e.g. colorscheme(#E6007E #009FE3 #312783)).

cintensity(num) Changes the color intensity. Higher values make colors darker.

Plot and element size
scale(num) Resizes all elements in the plot. For example, scale(1.1) increases text, marker, and lines sizes by 10%.

xysize(num) Specifies the relative width to height. For example, xysize(1.2) draws a plot with 20% more width than height.

legsize(num) Resizes the legend.

Other
nolegend Omits the legend when the original distributions are included via compare.

legpos(num) Position of the legend (enter values 1-12, akin to the positions of clock hands).

opts(str) Passes on options to the twoway plot(s). For example, opts(xtitle("Example")) changes the x axis title. See help twoway.

grcopts(str) Passes on options to graph combine, which is used internally to combine twoway plots when more than one distribution is plotted. See help graph combine.

slow Use native Stata commands instead of Gtools, reghdfe, and ftools.

Examples

Setup

. sysuse lifeexp, clear

Simple case - one variable, one fixed effect

. fedistr gnppc, fe(region)

Compare to the original distribution

. fedistr gnppc, fe(region) compare

Multiple variables

. fedistr gnppc lexp, fe(region) compare

Include continuous control variiables

. fedistr gnppc lexp, fe(region) controls(trunk) compare

Use densities instead of histograms

. fedistr gnppc lexp, fe(region) density compare

Include percentiles

. fedistr gnppc lexp, fe(region) p(1 99) compare

Separate plots for subsamples

. fedistr gnppc, fe(region) by(foreign) compare