npqreg {np} | R Documentation |
npqreg
computes a kernel quantile regression estimate of a one
(1) dimensional dependent variable on p-variate explanatory
data, given a set of evaluation points, training points (consisting of
explanatory data and dependent data), and a bandwidth specification
using the method of Li and Racine (2008). A bandwidth specification
can be a conbandwidth
object, or a bandwidth vector, bandwidth
type and kernel type.
npqreg(bws, ...) ## S3 method for class 'formula' npqreg(bws, data = NULL, newdata = NULL, ...) ## S3 method for class 'call' npqreg(bws, ...) ## S3 method for class 'conbandwidth' npqreg(bws, txdat = stop("training data 'txdat' missing"), tydat = stop("training data 'tydat' missing"), exdat, tau = 0.5, gradients = FALSE, ftol = 1.19209e-07, tol = 1.49012e-08, small = 2.22045e-16, itmax = 10000, ...) ## Default S3 method: npqreg(bws, txdat, tydat, ...)
bws |
a bandwidth specification. This can be set as a |
tau |
a numeric value specifying the tauth quantile is
desired. Defaults to |
... |
additional arguments supplied to specify the regression type,
bandwidth type, kernel types, training data, and so on.
To do this,
you may specify any of |
data |
an optional data frame, list or environment (or object
coercible to a data frame by |
newdata |
An optional data frame in which to look for evaluation data. If omitted, the training data are used. |
txdat |
a p-variate data frame of explanatory data (training data) used to calculate the regression estimators. Defaults to the training data used to compute the bandwidth object. |
tydat |
a one (1) dimensional numeric or integer vector of dependent data, each
element i corresponding to each observation (row) i of
|
exdat |
a p-variate data frame of points on which the regression will be
estimated (evaluation data). By default,
evaluation takes place on the data provided by |
gradients |
[currently not supported] a logical value indicating that you want
gradients computed and returned in the resulting |
itmax |
integer number of iterations before failure in the numerical
optimization routine. Defaults to |
ftol |
tolerance on the value of the objective function
evaluated at located minima. Defaults to |
tol |
tolerance on the position of located minima of the
objective function. Defaults to |
small |
a small number, at about the precision of the data type
used. Defaults to |
npqreg
returns a npqregression
object.
The generic
functions fitted
(or quantile
),
se
, predict
, and
gradients
, extract (or generate) estimated values,
asymptotic standard
errors on estimates, predictions, and gradients, respectively, from
the returned object. Furthermore, the functions summary
and plot
support objects of this type. The returned object
has the following components:
eval |
evaluation points |
quantile |
estimation of the quantile regression function (conditional quantile) at the evaluation points |
quanterr |
standard errors of the quantile regression estimates |
quantgrad |
gradients at each evaluation point |
tau |
the tauth quantile computed |
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.
Tristen Hayfield hayfield@mpia.de, Jeffrey S. Racine racinej@mcmaster.ca
Aitchison, J. and C.G.G. Aitken (1976), “Multivariate binary discrimination by the kernel method,” Biometrika, 63, 413-420.
Hall, P. and J.S. Racine and Q. Li (2004), “Cross-validation and the estimation of conditional probability densities,” Journal of the American Statistical Association, 99, 1015-1026.
Koenker, R. W. and G.W. Bassett (1978), “Regression quantiles,” Econometrica, 46, 33-50.
Koenker, R. (2005), Quantile Regression, Econometric Society Monograph Series, Cambridge University Press.
Li, Q. and J.S. Racine (2007), Nonparametric Econometrics: Theory and Practice, Princeton University Press.
Li, Q. and J.S. Racine (2008), “Nonparametric estimation of conditional CDF and quantile functions with mixed categorical and continuous data,” Journal of Business and Economic Statistics, 26, 423-434.
Wang, M.C. and J. van Ryzin (1981), “A class of smooth estimators for discrete distributions,” Biometrika, 68, 301-309.
quantreg
# EXAMPLE 1 (INTERFACE=FORMULA): For this example, we compute a # bivariate nonparametric quantile regression estimate for Giovanni # Baiocchi's Italian income panel (see Italy for details) data("Italy") attach(Italy) # First, compute the likelihood cross-validation bandwidths (default). # Note - this may take a few minutes depending on the speed of your # computer... bw <- npcdensbw(formula=gdp~ordered(year)) # Note - numerical search for computing the quantiles will take a # minute or so... model.q0.25 <- npqreg(bws=bw, tau=0.25) model.q0.50 <- npqreg(bws=bw, tau=0.50) model.q0.75 <- npqreg(bws=bw, tau=0.75) # Plot the resulting quantiles manually... plot(ordered(year), gdp, main="CDF Quantile Estimates for the Italian Income Panel", xlab="Year", ylab="GDP Quantiles") lines(ordered(year), model.q0.25$quantile, col="red", lty=2) lines(ordered(year), model.q0.50$quantile, col="blue", lty=3) lines(ordered(year), model.q0.75$quantile, col="red", lty=2) legend(ordered(1951), 32, c("tau = 0.25", "tau = 0.50", "tau = 0.75"), lty=c(2, 3, 2), col=c("red", "blue", "red")) detach(Italy) ## Not run: # EXAMPLE 1 (INTERFACE=DATA FRAME): For this example, we compute a # bivariate nonparametric quantile regression estimate for Giovanni # Baiocchi's Italian income panel (see Italy for details) data("Italy") attach(Italy) data <- data.frame(ordered(year), gdp) # First, compute the likelihood cross-validation bandwidths (default). # Note - this may take a few minutes depending on the speed of your # computer... bw <- npcdensbw(xdat=ordered(year), ydat=gdp) # Note - numerical search for computing the quantiles will take a # minute or so... model.q0.25 <- npqreg(bws=bw, tau=0.25) model.q0.50 <- npqreg(bws=bw, tau=0.50) model.q0.75 <- npqreg(bws=bw, tau=0.75) # Plot the resulting quantiles manually... plot(ordered(year), gdp, main="CDF Quantile Estimates for the Italian Income Panel", xlab="Year", ylab="GDP Quantiles") lines(ordered(year), model.q0.25$quantile, col="red", lty=2) lines(ordered(year), model.q0.50$quantile, col="blue", lty=3) lines(ordered(year), model.q0.75$quantile, col="red", lty=2) legend(ordered(1951), 32, c("tau = 0.25", "tau = 0.50", "tau = 0.75"), lty=c(2, 3, 2), col=c("red", "blue", "red")) detach(Italy) ## End(Not run)