Kernel Consistent Quantile Regression Model Specification Test with Mixed Data Types
np.qcmstest.Rdnpqcmstest implements a consistent test for correct
specification of parametric quantile regression models (linear or
nonlinear) as described in Racine (2006) which extends the work of
Zheng (1998).
Usage
npqcmstest(formula,
data = NULL,
subset,
xdat,
ydat,
model = stop(paste(sQuote("model")," has not been provided")),
tau = 0.5,
distribution = c("bootstrap", "asymptotic"),
bwydat = c("y","varepsilon"),
boot.method = c("iid","wild","wild-rademacher"),
B = 399,
pivot = TRUE,
density.weighted = TRUE,
random.seed = 42,
...)Details
Documentation guide: see np.kernels for kernels,
np.options for global options, and
plot for plotting options.
For distribution = "bootstrap", each quantile model is still
refitted separately using the selected bootstrap law. The resulting score
vectors are collected in bounded groups, and the fixed-design kernel
contractions for \(I_n\) and, when requested, \(\hat\Omega\) are
evaluated as multi-response kernel sums. This reuses kernel geometry
without forming a dense observation-by-observation weight matrix or
changing score order, tau, bwydat, pivoting, density
weighting, or random draws.
The selected bandwidth's effective kernel metadata are shared by the observed and bootstrap statistics. Manual bandwidth inputs and selection controls are not forwarded a second time as kernel-sum arguments.
Bootstrap refits preserve the model's observation weights. Weighted quantile models supply their raw design and response through the retained model frame; zero observation weights need not be inverted.
Model residuals, fitted values, response and design use the model's compact
complete-observation sample, including when it was fitted with
na.exclude. The supplied test data must represent those same complete
observations in the same order. Row counts and response values are checked;
when those agree, the caller remains responsible for supplying the matching
covariate rows. The test does not infer a new pairing or reorder observations.
The original model and its missing-value restoration policy are not modified.
Arguments
Data, Bandwidth Inputs And Formula Interface
These arguments identify the model formula/data interface and explicit data inputs.
- data
This argument belongs to the formula interface (including supported formula-bearing bandwidth-object refits). Native calls must supply their vectors, matrices or data frames directly, or use
with(data, ...). Supplyingdata, including explicitdata = NULL, to a native route that does not consume it is an error; seenp-data-interfaces.an optional data frame, list or environment (or object coercible to a data frame by
as.data.frame) containing the variables in the model. If not found in data, the variables are taken fromenvironment(formula), typically the environment from which the function is called.- formula
a symbolic description of the quantile regression model to be tested. If
xdatandydatare omitted, the data are extracted from this formula anddata.- model
a model object obtained from a call to
rq. Important: the model must retain its model, design and response components, normally requested withmodel=TRUE. Availability is checked from those components, not the spelling of the original call.- subset
an optional vector specifying a subset of observations to be used.
- xdat
a \(p\)-variate data frame of explanatory data (training data) used to calculate the quantile regression estimators.
- ydat
a one (1) dimensional numeric or integer vector of dependent data, each element \(i\) corresponding to each observation (row) \(i\) of
xdat.
Bootstrap And Test Controls
These arguments control the quantile level, test statistic, bootstrap procedure, and reproducibility settings.
- boot.method
a character string used to specify the bootstrap method.
iidwill generate independent identically distributed draws.wildwill use a wild bootstrap.wild-rademacherwill use a wild bootstrap with Rademacher variables. Defaults toiid.- B
an integer value specifying the number of bootstrap replications to use. Defaults to
399.- bwydat
a character string used to specify the left hand side variable used in bandwidth selection.
"varepsilon"uses \(1-\tau,-\tau\) forydatwhile"y"will use \(y\). Defaults to"y".- density.weighted
a logical value specifying whether the statistic should be weighted by the density of
xdat. Defaults toTRUE.- distribution
a character string used to specify the method of estimating the distribution of the statistic to be calculated.
bootstrapwill conduct bootstrapping.asymptoticwill use the normal distribution. Defaults tobootstrap.- pivot
a logical value specifying whether the statistic should be normalised such that it approaches \(N(0,1)\) in distribution. Defaults to
TRUE.- random.seed
an integer used to seed R's random number generator. This is to ensure replicability. Defaults to 42.
- tau
a finite scalar in (0,1) specifying the desired \(\tau\)th quantile. It must equal the single quantile fitted by
model; the default remains 0.5, so passtauexplicitly for other fitted quantiles.
Additional Arguments
Further arguments are passed to the bandwidth-selection routines used by the test.
- ...
additional arguments supplied to control bandwidth selection on the residuals. One can specify the bandwidth type, kernel types, and so on. To do this, you may specify any of
bwscaling,bwtype,ckertype,ckerorder,ukertype,okertype, as described innpregbw. This is necessary if you specifybwsas a \(p\)-vector and not abandwidthobject, and you do not desire the default behaviours.
Bootstrap P-Values
The bootstrap upper-tail p-value is the proportion of bootstrap statistics greater than or equal to the observed statistic. Ties count as at least as extreme, giving the conservative tie convention for discrete statistics. This is the ordinary bootstrap proportion, without an add-one correction; a reported zero is possible with a finite number of replications.
Value
npqcmstest returns an object of type cmstest with the
following components. Components will contain information
related to Jn or In depending on the value of pivot:
- Jn
the statistic
Jn- In
the statistic
In- Omega.hat
as described in Racine, J.S. (2006).
- q.*
the various quantiles of the statistic
Jn(orInifpivot=FALSE) are in componentsq.90,q.95,q.99(one-sided 1%, 5%, 10% critical values)- P
the P-value of the statistic
- Jn.bootstrap
if
pivot=TRUEcontains the bootstrap replications ofJn- In.bootstrap
if
pivot=FALSEcontains the bootstrap replications ofIn
summary supports object of type cmstest.
Book And Method Pointers
npqcmstest tests a parametric conditional-quantile
specification against a nonparametric conditional-quantile
alternative at the supplied \(\tau\). The test therefore sits at the
intersection of conditional CDF/quantile estimation and model
specification testing.
For book-length background, see Li and Racine (2007), Chapter 12 Model Specification Tests and Chapter 6 Conditional CDF and Quantile Estimation. For the later workflow treatment of conditional CDFs and quantiles, see Racine (2019), Chapter 4 Conditional Probability Density and Cumulative Distribution Functions.
References
Aitchison, J. and C.G.G. Aitken (1976), “Multivariate binary discrimination by the kernel method,” Biometrika, 63, 413-420.
Koenker, R.W. and G.W. Bassett (1978), “Regression quantiles,” Econometrica, 46, 33-50.
Li, Q. and J.S. Racine (2007), Nonparametric Econometrics: Theory and Practice, Princeton University Press.
Murphy, K. M. and F. Welch (1990), “Empirical age-earnings profiles,” Journal of Labor Economics, 8, 202-229.
Pagan, A. and A. Ullah (1999), Nonparametric Econometrics, Cambridge University Press.
Racine, J.S. (2006), “Consistent specification testing of heteroskedastic parametric regression quantile models with mixed data,” manuscript.
Wang, M.C. and J. van Ryzin (1981), “A class of smooth estimators for discrete distributions,” Biometrika, 68, 301-309.
Zheng, J. (1998), “A consistent nonparametric test of parametric regression models under conditional quantile restrictions,” Econometric Theory, 14, 123-138.
Author
Tristen Hayfield tristen.hayfield@gmail.com, Jeffrey S. Racine racinej@mcmaster.ca
Usage Issues
If you are using data of mixed types, then it is advisable to use the
data.frame function to construct your input data and not
cbind, since cbind will typically not work as
intended on mixed data types and will coerce the data to the same
type.
Examples
if (FALSE) { # \dontrun{
# EXAMPLE 1: For this example, we conduct a consistent quantile regression
# model specification test for a parametric wage quantile regression
# model that is quadratic in age. The work of Murphy and Welch (1990)
# would suggest that this parametric quantile regression model is
# misspecified.
library("quantreg")
data("cps71")
with(cps71, {
model <- rq(logwage~age+I(age^2), tau=0.5, model=TRUE)
if (interactive()) plot(age, logwage)
lines(age, fitted(model))
X <- data.frame(age)
# Note - this may take a few minutes depending on the speed of your
# computer...
npqcmstest(model = model, xdat = X, ydat = logwage, tau=0.5)
# Sleep for 5 seconds so that we can examine the output...
if (interactive()) Sys.sleep(5)
# Next try Murphy & Welch's (1990) suggested quintic specification.
model <- rq(logwage~age+I(age^2)+I(age^3)+I(age^4)+I(age^5), model=TRUE)
if (interactive()) plot(age, logwage)
lines(age, fitted(model))
X <- data.frame(age)
# Note - this may take a few minutes depending on the speed of your
# computer...
npqcmstest(model = model, xdat = X, ydat = logwage, tau=0.5)
})
} # }