Description Usage Arguments Value Author(s) References See Also Examples
binsreg
implements binscatter estimation with robust inference proposed and plots, following the
results in Cattaneo, Crump, Farrell and Feng (2019a).
Binscatter provides a flexible way of describing
the mean relationship between two variables, after possibly adjusting for other covariates, based on
partitioning/binning of the independent variable of interest. The main purpose of this function is to
generate binned scatter plots with curve estimation with robust pointwise confidence intervals and
uniform confidence band. If the binning scheme is not set by the user, the companion function
binsregselect
is used to implement binscatter in a datadriven (optimal)
way. Hypothesis testing about the regression function can also be conducted via the companion
function binsregtest
.
1 2 3 4 5 6 7 8 9 10 11 12 13  binsreg(y, x, w = NULL, deriv = 0, dots = c(0, 0), dotsgrid = 0,
dotsgridmean = T, line = NULL, linegrid = 20, ci = NULL,
cigrid = 0, cigridmean = T, cb = NULL, cbgrid = 20,
polyreg = NULL, polyreggrid = 20, polyregcigrid = 0, by = NULL,
bycolors = NULL, bysymbols = NULL, bylpatterns = NULL,
legendTitle = NULL, legendoff = F, testmodel = c(3, 3),
testmodelparfit = NULL, testmodelpoly = NULL, testshape = c(3, 3),
testshapel = NULL, testshaper = NULL, testshape2 = NULL,
nbins = NULL, binspos = "qs", binsmethod = "dpi",
nbinsrot = NULL, samebinsby = F, nsims = 500, simsgrid = 20,
simsseed = 666, vce = "HC1", cluster = NULL, level = 95,
noplot = F, dfcheck = c(20, 30), masspoints = "on",
weights = NULL, subset = NULL)

y 
outcome variable. A vector. 
x 
independent variable of interest. A vector. 
w 
control variables. A matrix or a vector. 
deriv 
derivative order of the regression function for estimation, testing and plotting.
The default is 
dots 
a vector. 
dotsgrid 
number of dots within each bin to be plotted. Given the choice, these dots are point estimates
evaluated over an evenlyspaced grid within each bin. The default is 
dotsgridmean 
If true, the dots corresponding to the point estimates evaluated at the mean of 
line 
a vector. 
linegrid 
number of evaluation points of an evenlyspaced grid within each bin used for evaluation of
the point estimate set by the 
ci 
a vector. 
cigrid 
number of evaluation points of an evenlyspaced grid within each bin used for evaluation of the point
estimate set by the 
cigridmean 
If true, the confidence intervals corresponding to the point estimates evaluated at the mean of 
cb 
a vector. 
cbgrid 
number of evaluation points of an evenlyspaced grid within each bin used for evaluation of the point
estimate set by the 
polyreg 
degree of a global polynomial regression model for plotting. By default, this fit is not included
in the plot unless explicitly specified. Recommended specification is 
polyreggrid 
number of evaluation points of an evenlyspaced grid within each bin used for evaluation of
the point estimate set by the 
polyregcigrid 
number of evaluation points of an evenlyspaced grid within each bin used for constructing
confidence intervals based on polynomial regression set by the 
by 
a vector containing the group indicator for subgroup analysis; both numeric and string variables
are supported. When 
bycolors 
an ordered list of colors for plotting each subgroup series defined by the option 
bysymbols 
an ordered list of symbols for plotting each subgroup series defined by the option 
bylpatterns 
an ordered list of line patterns for plotting each subgroup series defined by the option 
legendTitle 
String, title of legend. 
legendoff 
If true, no legend is added. 
testmodel 
a vector. 
testmodelparfit 
a data frame or matrix which contains the evaluation grid and fitted values of the model(s) to be tested against. The first column contains a series of evaluation points at which the binscatter model and the parametric model of interest are compared with each other. Each parametric model is represented by other columns, which must contain the fitted values at the corresponding evaluation points. 
testmodelpoly 
degree of a global polynomial model to be tested against. 
testshape 
a vector. 
testshapel 
a vector of null boundary values for hypothesis testing. Each number 
testshaper 
a vector of null boundary values for hypothesis testing. Each number 
testshape2 
a vector of null boundary values for hypothesis testing. Each number 
nbins 
number of bins for partitioning/binning of 
binspos 
position of binning knots. The default is 
binsmethod 
method for datadriven selection of the number of bins. The default is 
nbinsrot 
initial number of bins value used to construct the DPI number of bins selector. If not specified, the datadriven ROT selector is used instead. 
samebinsby 
if true, a common partitioning/binning structure across all subgroups specified by the option 
nsims 
number of random draws for constructing confidence bands and hypothesis testing. The default is

simsgrid 
number of evaluation points of an evenlyspaced grid within each bin used for evaluation of
the supremum (or infimum) operation needed to construct confidence bands and hypothesis testing
procedures. The default is 
simsseed 
seed for simulation. 
vce 
Procedure to compute the variancecovariance matrix estimator. Options are

cluster 
cluster ID. Used for compute clusterrobust standard errors. 
level 
nominal confidence level for confidence interval and confidence band estimation. Default is 
noplot 
If true, no plot produced. 
dfcheck 
adjustments for minimum effective sample size checks, which take into account number of unique
values of 
masspoints 
how mass points in

weights 
an optional vector of weights to be used in the fitting process. Should be 
subset 
Optional rule specifying a subset of observations to be used. 

A 

A list containing data for plotting. Each item is a sublist of data frames for each group. Each sublist may contain the following data frames:


A vector of critical values for constructing confidence band for each group. 

Return of 

A list containing options passed to the function, as well as 
Matias D. Cattaneo, University of Michigan, Ann Arbor, MI. cattaneo@umich.edu.
Richard K. Crump, Federal Reserve Bank of New York, New York, NY. richard.crump@ny.frb.org.
Max H. Farrell, University of Chicago, Chicago, IL. max.farrell@chicagobooth.edu.
Yingjie Feng (maintainer), University of Michigan, Ann Arbor, MI. yjfeng@umich.edu.
Cattaneo, M. D., R. K. Crump, M. H. Farrell, and Y. Feng. 2019a: On Binscatter. Working Paper.
Cattaneo, M. D., R. K. Crump, M. H. Farrell, and Y. Feng. 2019b: Binscatter Regressions. Working Paper.
1 2 3 
Call: binsreg
Binscatter Plot
Bin selection method (binsmethod) = IMSE direct plugin
Placement (binspos) = Quantilespaced
Derivative (deriv) = 0
Group (by) = Full Sample
Sample size (n) = 500
# of distinct values (Ndist) = 500
# of clusters (Nclust) = NA
dots, degree (p) = 0
dots, smooth (s) = 0
# of bins (nbins) = 9
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.