binstest {binsreg} | R Documentation |
Data-Driven Nonparametric Shape Restriction and Parametric Model Specification Testing using Binscatter
Description
binstest
implements binscatter-based hypothesis testing procedures for parametric functional
forms of and nonparametric shape restrictions on the regression function of interest, following the results
in Cattaneo, Crump, Farrell and Feng (2024a) and
Cattaneo, Crump, Farrell and Feng (2024b).
If the binning scheme is not set by the user,
the companion function binsregselect
is used to implement binscatter in a
data-driven way and inference procedures are based on robust bias correction.
Binned scatter plots based on different methods can be constructed using the companion functions binsreg
,
binsqreg
or binsglm
.
Usage
binstest(y, x, w = NULL, data = NULL, estmethod = "reg",
family = gaussian(), quantile = NULL, deriv = 0, at = NULL,
nolink = F, testmodel = NULL, testmodelparfit = NULL,
testmodelpoly = NULL, testshape = NULL, testshapel = NULL,
testshaper = NULL, testshape2 = NULL, lp = Inf, bins = NULL,
nbins = NULL, pselect = NULL, sselect = NULL, binspos = "qs",
binsmethod = "dpi", nbinsrot = NULL, randcut = NULL, nsims = 500,
simsgrid = 20, simsseed = NULL, vce = NULL, cluster = NULL,
asyvar = F, dfcheck = c(20, 30), masspoints = "on", weights = NULL,
subset = NULL, numdist = NULL, numclust = NULL, estmethodopt = NULL,
...)
Arguments
y |
outcome variable. A vector. |
x |
independent variable of interest. A vector. |
w |
control variables. A matrix, a vector or a |
data |
an optional data frame containing variables used in the model. |
estmethod |
estimation method. The default is |
family |
a description of the error distribution and link function to be used in the generalized linear model when |
quantile |
the quantile to be estimated. A number strictly between 0 and 1. |
deriv |
derivative order of the regression function for estimation, testing and plotting.
The default is |
at |
value of |
nolink |
if true, the function within the inverse link function is reported instead of the conditional mean function for the outcome. |
testmodel |
a vector or a logical value. It sets the degree of polynomial and the number of smoothness constraints for parametric model specification
testing. If |
testmodelparfit |
a data frame or matrix which contains the evaluation grid and fitted values of the model(s) to be tested against. The 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 or a logical value. It sets the degree of polynomial and the number of smoothness constraints for nonparametric shape restriction
testing. If |
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 |
lp |
an Lp metric used for parametric model specification testing and/or shape restriction testing. The default is |
bins |
a vector. If |
nbins |
number of bins for partitioning/binning of |
pselect |
vector of numbers within which the degree of polynomial |
sselect |
vector of numbers within which the number of smoothness constraints |
binspos |
position of binning knots. The default is |
binsmethod |
method for data-driven 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 data-driven ROT selector is used instead. |
randcut |
upper bound on a uniformly distributed variable used to draw a subsample for bins/degree/smoothness selection.
Observations for which |
nsims |
number of random draws for hypothesis testing. The default is
|
simsgrid |
number of evaluation points of an evenly-spaced grid within each bin used for evaluation of
the supremum (infimum or Lp metric) operation needed to construct hypothesis testing
procedures. The default is |
simsseed |
seed for simulation. |
vce |
procedure to compute the variance-covariance matrix estimator. For least squares regression and generalized linear regression, the allowed options are the same as that for |
cluster |
cluster ID. Used for compute cluster-robust standard errors. |
asyvar |
if true, the standard error of the nonparametric component is computed and the uncertainty related to control
variables is omitted. Default is |
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. |
numdist |
number of distinct values for selection. Used to speed up computation. |
numclust |
number of clusters for selection. Used to speed up computation. |
estmethodopt |
a list of optional arguments used by |
... |
optional arguments to control bootstrapping if |
Value
testshapeL |
Results for |
testshapeR |
Results for |
testshape2 |
Results for |
testpoly |
Results for |
testmodel |
Results for |
imse.var.rot |
Variance constant in IMSE, ROT selection. |
imse.bsq.rot |
Bias constant in IMSE, ROT selection. |
imse.var.dpi |
Variance constant in IMSE, DPI selection. |
imse.bsq.dpi |
Bias constant in IMSE, DPI selection. |
opt |
A list containing options passed to the function, as well as total sample size |
Author(s)
Matias D. Cattaneo, Princeton University, Princeton, NJ. cattaneo@princeton.edu.
Richard K. Crump, Federal Reserve Bank of New York, New York, NY. richard.crump@ny.frb.org.
Max H. Farrell, UC Santa Barbara, Santa Barbara, CA. mhfarrell@gmail.com.
Yingjie Feng (maintainer), Tsinghua University, Beijing, China. fengyingjiepku@gmail.com.
References
Cattaneo, M. D., R. K. Crump, M. H. Farrell, and Y. Feng. 2024a: On Binscatter. American Economic Review 114(5): 1488-1514.
Cattaneo, M. D., R. K. Crump, M. H. Farrell, and Y. Feng. 2024b: Nonlinear Binscatter Methods. Working Paper.
Cattaneo, M. D., R. K. Crump, M. H. Farrell, and Y. Feng. 2024c: Binscatter Regressions. Working Paper.
See Also
binsreg
, binsqreg
, binsglm
, binsregselect
.
Examples
x <- runif(500); y <- sin(x)+rnorm(500)
est <- binstest(y,x, testmodelpoly=1)
summary(est)