Title: | Nonparametric Series Quantile Regression |
---|---|
Description: | Implements the nonparametric quantile regression method developed by Belloni, Chernozhukov, and Fernandez-Val (2011) to partially linear quantile models. Provides point estimates of the conditional quantile function and its derivatives based on series approximations to the nonparametric part of the model. Provides pointwise and uniform confidence intervals using analytic and resampling methods. |
Authors: | Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val |
Maintainer: | Ivan Fernandez-Val <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.0 |
Built: | 2024-10-24 05:45:08 UTC |
Source: | https://github.com/cran/quantreg.nonpar |
Implements the nonparametric quantile regression methods developed by Belloni, Chernozhukov, and Fernandez-Val (2011) to partially linear quantile models. Provides point estimates of the conditional quantile function and its derivatives based on series approximations to the nonparametric part of the model. Provides pointwise and uniform confidence intervals using analytic and resampling methods.
Package: | quantreg.nonpar |
Type: | Package |
Version: | 1.0 |
Date: | 2014-11-05 |
License: | GPL(>=2) |
This package is used to generate point estimates and uniform and pointwise confidence intervals in nonparametric series quantile regression models. One may use npqr
to generate such estimates and confidence intervals and test hypotheses on the conditional quantile function and its derivatives.
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
Maintainer: Ivan Fernandez-Val <[email protected]>
Belloni, A., Chernozhukov, V., and I. Fernandez-Val (2011), "Conditional quantile processes based on series or many regressors," arXiv: 1105:6154.
Koenker, R. (2011), "Additive models for quantile regression: Model selection and confidence bandaids," Brazilian Journal of Probability and Statistics 25(3), pp. 239-262.
Koenker, R. and G. Bassett (1978): "Regression Quantiles," Econometrica 46, pp. 33-50.
Ramsay, J.O., Wickham, H., Graves, S., and G. Hooker (2013), "fda: Functional Data Analysis," R package version 2.3.6, http://CRAN.R-project.org/package=fda
Returns or evaluates the second derivatives of orthogonal polynomials of degree 1 to degree
over the specified set of points x
: the polynomials are all orthogonal to the constant polynomial of degree 0. Alternatively, evaluates the second derivatives of raw polynomials.
ddpoly(x, ..., degree = 1, coefs = NULL, raw = FALSE)
ddpoly(x, ..., degree = 1, coefs = NULL, raw = FALSE)
x |
a numeric vector at which to evaluate the polynomial. |
... |
further vectors. |
degree |
the degree of the polynomial. Must be less than the number of unique points if |
coefs |
for prediction, coefficients from a previous fit. |
raw |
if true, use raw and not orthogonal polynomials. |
A matrix with rows corresponding to points in x
and columns corresponding to the degree, with attributes "degree"
specifying the degrees of the columns (prior to taking the derivatives) and (unless raw = TRUE
) "coefs"
which contains the centering and normalization constants used in constructing the orthogonal polynomials. The matrix has been given class c("poly","matrix")
.
Both the code and the description of ddpoly
borrow heavily from the poly
command in the stats
package.
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
Chambers, J.M. and Hastie, T.J. (1992) Statistical Models in S. Wadsworth & Brooks/Cole. Kennedy, W.J. Jr and Gentle, J.E. (1980) Statistical Computing. Marcel Dekker.
Returns or evaluates the first derivatives of orthogonal polynomials of degree 1 to degree
over the specified set of points x
: the polynomials are all orthogonal to the constant polynomial of degree 0. Alternatively, evaluates the first derivatives of raw polynomials.
dpoly(x, ..., degree = 1, coefs = NULL, raw = FALSE)
dpoly(x, ..., degree = 1, coefs = NULL, raw = FALSE)
x |
a numeric vector at which to evaluate the polynomial. |
... |
further vectors. |
degree |
the degree of the polynomial. Must be less than the number of unique points if |
coefs |
for prediction, coefficients from a previous fit. |
raw |
if true, use raw and not orthogonal polynomials. |
A matrix with rows corresponding to points in x
and columns corresponding to the degree, with attributes "degree"
specifying the degrees of the columns (prior to taking the derivative) and (unless raw = TRUE
) "coefs"
which contains the centering and normalization constants used in constructing the orthogonal polynomials. The matrix has been given class c("poly","matrix")
.
Both the code and the description of dpoly
borrow heavily from the poly
command in the stats
package.
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
Chambers, J.M. and Hastie, T.J. (1992) Statistical Models in S. Wadsworth & Brooks/Cole. Kennedy, W.J. Jr and Gentle, J.E. (1980) Statistical Computing. Marcel Dekker.
Takes the symbolic derivative (or multiple derivatives) of the right hand side of a formula and returns a matrix with the derivative evaluated at each observation in a dataset
formulaDeriv(inFormula, derivVar, data, nDerivs = 1)
formulaDeriv(inFormula, derivVar, data, nDerivs = 1)
inFormula |
a formula object, with the response Y on the left of a ~ operator, and the covariate terms, separated by + operators on the right, not including the regressor whose effect is to be estimated nonparametrically. Operators such as '*', ':', 'log()', and 'I()' are allowable. However, factor variables should be constructed prior to entry in the formula: the 'factor()' operator is not allowable. |
derivVar |
a character object giving the name of the variable with respect to which the derivative will be taken. |
data |
a data.frame in which to interpret the variables named in the |
nDerivs |
an integer: the number of derivatives to be taken. |
formulaDeriv
returns a matrix whose dimensions are the number of observations in data
and the number of variables on the right hand side of formula
. Each row is the derivative of formula
evaluated at the corresponding observation in data
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
A method for the generic function npqr
. It computes, via a Gaussian method, the t-statistic used to conduct inference in nonparametric series quantile regression models, as well as outputting confidence intervals and hypothesis test p-values at a user-specified level.
gaus(data = data, B = B, taus, formula, basis = NULL, alpha=0.05, var, load, rearrange=F, rearrange.vars="quantile", uniform=F, se="unconditional", average = T, nderivs = 1, method = "fn")
gaus(data = data, B = B, taus, formula, basis = NULL, alpha=0.05, var, load, rearrange=F, rearrange.vars="quantile", uniform=F, se="unconditional", average = T, nderivs = 1, method = "fn")
data |
a data.frame in which to interpret the variables named in the |
B |
the number of simulations to be performed. |
taus |
a numerical vector, whose entries are strictly between 0 and 1, containing the quantile indexes of interest for the quantile effects. |
formula |
a formula object, with the response Y on the left of a ~ operator, and the covariate terms, separated by + operators on the right, not including the regressor whose effect is to be estimated nonparametrically. Operators such as '*', ':', 'log()', and 'I()' are allowable. However, factor variables should be constructed prior to entry in the formula: the 'factor()' operator is not allowable. |
basis |
either a basis generated using the |
alpha |
a real number between 0 and 1: the desired significance level (e.g., 0.05). |
var |
a column name within |
load |
optional manual input of loading vector (or matrix of loading vectors) that will be used as data points at which inference will be performed and over which hypothesis tests will be conducted. Each vector of |
rearrange |
a boolean specifiying whether estimates will be monotonized prior to performing inference (requires that |
rearrange.vars |
if |
uniform |
a boolean specifying whether inference will be uniform across observations and quantiles or done in a pointwise manner. |
se |
either "conditional" or "unconditional". Specifies whether standard errors, for pivotal and gaussian processes, will be conditional on the sample or not. |
average |
if |
nderivs |
the number of derivatives of the conditional quantile function upon which inference should be performed. |
method |
method to be implemented in quantile regressions: passed to function |
gaus
returns a list containing the following elements:
qfits |
a list whose length is equal to the length of |
point.est |
a matrix containing the point estimates of interest (e.g., the average derivative of the function) for each pair of loading vectors and |
var.unique |
a vector containing all values of the covariate of interest with no repeated values. |
CI |
an array containing the two-sided confidence interval for each pair of loading vectors and |
CI.oneSided |
an array containing the one-sided confidence bounds for each pair of loading vectors and |
std.error |
a matrix containing estimated standard errors for the quantile regression point estimates for each pair of loading vectors and |
pvalues |
a vector containing the p-values for hypothesis tests of three null hypotheses. First, that theta(tau,w) <= 0 for all (tau,w) pairs, where theta is the quantity of interest (e.g., the derivative of the function at each quantile and at each observation). Second, that theta(tau,w) >= 0 for all (tau,w) pairs. Third, that theta(tau,w) = 0 for all (tau,w) pairs. |
load |
the loading vector or matrix of loading vectors used as data points at which inference was performed and over which hypothesis tests were conducted. If |
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
Belloni, A., Chernozhukov, V., and I. Fernandez-Val (2011), "Conditional quantile processes based on series or many regressors," arXiv:1105.6154.
A method for the generic function npqr
. It computes, via a gradient bootstrap method, the t-statistic used to conduct inference in nonparametric series quantile regression models, as well as outputting confidence intervals and hypothesis test p-values at a user-specified level.
gbootstrap(data = data, B = B, taus, formula, basis = NULL, alpha = 0.05, var, load, rearrange=F, rearrange.vars="quantile", uniform=F, average=T, nderivs=1, method = "fn")
gbootstrap(data = data, B = B, taus, formula, basis = NULL, alpha = 0.05, var, load, rearrange=F, rearrange.vars="quantile", uniform=F, average=T, nderivs=1, method = "fn")
data |
a data.frame in which to interpret the variables named in the |
B |
the number of bootstrap repetitions to be performed. |
taus |
a numerical vector, whose entries are strictly between 0 and 1, containing the quantile indexes of interest. |
formula |
a formula object, with the response Y on the left of a ~ operator, and the covariate terms, separated by + operators on the right, not including the regressor whose effect is to be estimated nonparametrically. Operators such as '*', ':', 'log()', and 'I()' are allowable. However, factor variables should be constructed prior to entry in the formula: the 'factor()' operator is not allowable. |
basis |
either a basis generated using the |
alpha |
a real number between 0 and 1: the desired significance level (e.g., 0.05). |
var |
a column name within |
load |
optional manual input of loading vector (or matrix of loading vectors) that will be used as data points at which inference will be performed and over which hypothesis tests will be conducted. Each vector of |
rearrange |
a boolean specifiying whether estimates will be monotonized prior to performing inference (requires that |
rearrange.vars |
if |
uniform |
a boolean specifying whether inference will be uniform across observations and quantiles or done in a pointwise manner. |
average |
if |
nderivs |
the number of derivatives of the conditional quantile function upon which inference should be performed. |
method |
method to be implemented in quantile regressions: passed to function |
gbootstrap
returns a list containing the following elements:
qfits |
a list whose length is equal to the length of |
point.est |
a matrix containing the point estimates of interest (e.g., the average derivative of the function) for each pair of loading vectors and |
var.unique |
a vector containing all values of the covariate of interest with no repeated values. |
CI |
an array containing the two-sided confidence interval for each pair of loading vectors and |
CI.oneSided |
an array containing the one-sided confidence bounds for each pair of loading vectors and |
std.error |
a matrix containing estimated standard errors for the quantile regression point estimates for each pair of loading vectors and |
pvalues |
a vector containing the p-values for hypothesis tests of three null hypotheses. First, that theta(tau,w) <= 0 for all (tau,w) pairs, where theta is the quantity of interest (e.g., the derivative of the function at each quantile and at each observation). Second, that theta(tau,w) >= 0 for all (tau,w) pairs. Third, that theta(tau,w) = 0 for all (tau,w) pairs. |
load |
the loading vector or matrix of loading vectors used as data points at which inference was performed and over which hypothesis tests were conducted. If |
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
Belloni, A., Chernozhukov, V., and I. Fernandez-Val (2011), "Conditional quantile processes based on series or many regressors," arXiv:1105.6154.
Demographic and Health Survey data on childhood nutrition in India.
data(india)
data(india)
A data frame with 37623 observations on the following 21 variables.
cheight
child's height (centimeters); a numeric vector
cage
child's age (months); a numeric vector
breastfeeding
duration of breastfeeding (months); a numeric vector
csex
child's sex; a factor with levels male
female
ctwin
whether or not child is a twin; a factor with levels single birth
twin
cbirthorder
birth order of the child; a factor with levels 1
2
3
4
5
mbmi
mother's BMI (kilograms per meter squared); a numeric vector
mage
mother's age (years); a numeric vector
medu
mother's years of education; a numeric vector
edupartner
father's years of education; a numeric vector
munemployed
mother's employment status; a factor variable with levels unemployed
employed
mreligion
mother's religion; a factor variable with levels christian
hindu
muslim
other
sikh
mresidence
mother's residential classification; a factor with levels urban
rural
wealth
mother's relative wealth; a factor with levels poorest
poorer
middle
richer
richest
electricity
electricity access; a factor with levels no
yes
radio
radio ownership; a factor with levels no
yes
television
television ownership; a factor with levels no
yes
refrigerator
refrigerator ownership; a factor with levels no
yes
bicycle
bicycle ownership; a factor with levels no
yes
motorcycle
motorcycle ownership; a factor with levels no
yes
car
car ownership; a factor with levels no
yes
http://www.econ.uiuc.edu/~roger/research/bandaids/india.Rda
Koenker, R. (2011), "Additive models for quantile regression: Model selection and confidence bandaids," Brazilian Journal of Probability and Statistics 25(3), pp. 239-262.
Returns the medians of a vector of ordered factor variables, the modes of a vector of unordered factor variables, and the means of a vector of numeric variables.
load.sum(vec)
load.sum(vec)
vec |
A vector of ordered factor variables, a vector of unordered factor variables, or a vector of numeric variables. |
load.sum
returns the medians of a vector of ordered factor variables, the mode of a vector of unordered factor variables, and the mean of a vector of numeric variables.
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
Obtains the square root of a symmetric matrix by spectral decomposition.
msqrt(a)
msqrt(a)
a |
a matrix |
msqrt
returns the square root of a symmetric matrix, obtained via spectral decomposition
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
A method for the generic function npqr
. It computes the quantile regression fits without performing inference
no.process(data = data, taus, formula, basis = NULL, var, load, rearrange=F, rearrange.vars="quantile", average=T, nderivs=1, method = "fn")
no.process(data = data, taus, formula, basis = NULL, var, load, rearrange=F, rearrange.vars="quantile", average=T, nderivs=1, method = "fn")
data |
a data.frame in which to interpret the variables named in the |
taus |
a numerical vector, whose entries are strictly between 0 and 1, containing the quantile indexes of interest. |
formula |
a formula object, with the response Y on the left of a ~ operator, and the covariate terms, separated by + operators on the right, not including the regressor whose effect is to be estimated nonparametrically. Operators such as '*', ':', 'log()', and 'I()' are allowable. However, factor variables should be constructed prior to entry in the formula: the 'factor()' operator is not allowable. |
basis |
either a basis generated using the |
var |
a column name within |
load |
optional manual input of loading vector (or matrix of loading vectors) that will be used as data points at which inference will be performed and over which hypothesis tests will be conducted. Each vector of |
rearrange |
a boolean specifiying whether estimates will be monotonized (requires that |
rearrange.vars |
if |
average |
if |
nderivs |
the number of derivatives of the conditional quantile function upon which point estimates should be generated. |
method |
method to be implemented in quantile regressions: passed to function |
no.process
returns a list containing the following elements:
qfits |
a list whose length is equal to the length of |
point.est |
a matrix containing the point estimates of interest (e.g., the average derivative of the function) for each pair of loading vectors and |
var.unique |
a vector containing all values of the covariate of interest with no repeated values. |
load |
the loading vector or matrix of loading vectors used as data points at which point estimates were generated. If |
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
Belloni, A., Chernozhukov, V., and I. Fernandez-Val (2011), "Conditional quantile processes based on series or many regressors," arXiv:1105.6154.
Implements the nonparametric quantile regression methods developed by Belloni, Chernozhukov, and Fernandez-Val (2011) to partially linear quantile models, ,
. Provides point estimates of the conditional quantile function and its derivatives based on series approximations to the nonparametric part of the model,
, approximated by
. Provides pointwise and uniform confidence intervals using analytic and resampling methods.
npqr(formula, data, basis = NULL, var, taus = c(0.25, 0.5, 0.75), print.taus = NULL, B = 200, nderivs = 1, average = T, load = NULL, alpha = 0.05, process = "pivotal", rearrange = F, rearrange.vars="quantile", uniform = F, se = "unconditional", printOutput = T, method = "fn")
npqr(formula, data, basis = NULL, var, taus = c(0.25, 0.5, 0.75), print.taus = NULL, B = 200, nderivs = 1, average = T, load = NULL, alpha = 0.05, process = "pivotal", rearrange = F, rearrange.vars="quantile", uniform = F, se = "unconditional", printOutput = T, method = "fn")
formula |
a formula object, with the response Y on the left of a ~ operator, and the covariate terms, separated by + operators on the right, not including the regressor whose effect is to be estimated nonparametrically. Operators such as '*', ':', 'log()', and 'I()' are allowable. However, factor variables should be constructed prior to entry in the formula: the 'factor()' operator is not allowable. |
data |
a data.frame in which to interpret the variables named in the |
basis |
a nonparametric basis object (created with the package |
var |
a column name within |
taus |
a vector of quantiles of interest. |
print.taus |
a vector of quantiles (which must be a subset of |
B |
the number of simulations (for the pivotal and gaussian methods) or bootstrap repetitions (for the weighted bootstrap and gradient bootstrap methods) to be performed. |
nderivs |
if |
average |
if |
load |
optional manual input of loading vector (or matrix of loading vectors) that will be used as data points at which inference will be performed and over which hypothesis tests will be conducted. Each vector of |
alpha |
a real number between 0 and 1: the desired significance level (e.g., 0.05). |
process |
either "pivotal", "gaussian", "wbootstrap", "gbootstrap", or "none": specifies the process used to estimate confidence intervals and p-values of hypothesis tests (or, if |
rearrange |
a boolean specifiying whether estimates will be monotonized prior to performing inference (requires that |
rearrange.vars |
if |
uniform |
a boolean specifying whether inference will be done uniformly across observations and quantiles or in a pointwise manner. |
se |
either "conditional" or "unconditional". Specifies whether standard errors, for pivotal and gaussian methods, will be conditional on the sample or not. |
printOutput |
a boolean specifying whether or not output will be printed. |
method |
method to be implemented in quantile regressions: passed to function |
The loading vector may be specified in one of two ways: it may be input manually with load
. If load
is not specified, the loading vector will be calculated automatically using average
and nderivs
as parameters.
Note that derivatives calculated automatically will always be with respect to the nonparametric variable of interest, var
. This means that, for example, if var=logprice
, where logprice
is the natural logarithm of price, then the derivative will be taken with respect to logprice
, not with respect to price
. Specification of var
will not admit mathematical functions such as log
. Specification of formula
will admit some functions (e.g., log
, multiplication of covariates, interaction of covariates). However, formula will not admit some formula operators; in particular, factor variables must be saved as new variables prior to entry into formula. See the vignette for more information.
returns a list of results
CI |
an array containing the two-sided confidence interval for each pair of loading vectors and |
CI.oneSided |
an array containing the one-sided confidence bounds for each pair of loading vectors and |
point.est |
a matrix containing the point estimates of interest (e.g., the average derivative of the conditional quantile function) for each pair of loading vectors and |
std.error |
a matrix containing estimated standard errors for the point estimates for each pair of loading vectors and |
pvalues |
a vector containing the p-values for hypothesis tests of three null hypotheses. First, that theta(tau,w) <= 0 for all (tau,w) pairs, where theta is the quantity of interest (e.g., the derivative of the function at each quantile and at each observation). Second, that theta(tau,w) >= 0 for all (tau,w) pairs. Third, that theta(tau,w) = 0 for all (tau,w) pairs. |
taus |
This is the input vector of quantile indexes. |
coefficients |
a list of length equal to the number of |
var.unique |
a vector containing all values of the covariate of interest with no repeated values. |
load |
the loading vector or matrix of loading vectors used as data points at which inference was performed and over which hypothesis tests were conducted. If |
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
Belloni, A., Chernozhukov, V., and I. Fernandez-Val (2011), "Conditional quantile processes based on series or many regressors," arXiv: 1105:6154.
Koenker, R. (2011), "Additive models for quantile regression: Model selection and confidence bandaids," Brazilian Journal of Probability and Statistics 25(3), pp. 239-262.
Koenker, R. and G. Bassett (1978): "Regression Quantiles," Econometrica 46, pp. 33-50.
Ramsay, J.O., Wickham, H., Graves, S., and G. Hooker (2013), "fda: Functional Data Analysis," R package version 2.3.6, http://CRAN.R-project.org/package=fda
data(india) ## Subset the data for speed india.subset<-india[1:1000,] formula=cheight~mbmi+breastfeeding+mage+medu+edupartner basis.bsp <- create.bspline.basis(breaks=quantile(india$cage,c(0:10)/10)) n=length(india$cage) B=500 alpha=.95 taus=c(1:24)/25 print.taus=c(1:4)/5 ## Inference on average growth rate piv.bsp <- npqr(formula=formula, data=india.subset, basis=basis.bsp, var="cage", taus=taus, print.taus=print.taus, B=B, nderivs=1, average=1, alpha=alpha, process="pivotal", rearrange=FALSE, uniform=TRUE, se="unconditional", printOutput=TRUE, method="fn") yrange<-range(piv.bsp$CI) xrange<-c(0,1) plot(xrange,yrange,type="n",xlab="",ylab="Average Growth (cm/month)") lines(piv.bsp$taus,piv.bsp$point.est) lines(piv.bsp$taus,piv.bsp$CI[1,,1],col="blue") lines(piv.bsp$taus,piv.bsp$CI[1,,2],col="blue") title("Average Growth Rate") ## Estimation on average growth acceleration with no inference piv.bsp.secondderiv <- npqr(formula=formula, data=india.subset, basis=basis.bsp, var="cage", taus=taus, print.taus=print.taus, B=B, nderivs=2, average=0, alpha=alpha, process="none", se="conditional", rearrange=FALSE, printOutput=FALSE, method="fn") xsurf<-as.vector(piv.bsp.secondderiv$taus) ysurf<-as.vector(piv.bsp.secondderiv$var.unique) zsurf<-t(piv.bsp.secondderiv$point.est) persp(xsurf, ysurf, zsurf, xlab="Quantile", ylab="Age (months)", zlab="Growth Acceleration", ticktype="detailed", phi=30, theta=120, d=5, col="green", shade=0.75, main="Growth Acceleration")
data(india) ## Subset the data for speed india.subset<-india[1:1000,] formula=cheight~mbmi+breastfeeding+mage+medu+edupartner basis.bsp <- create.bspline.basis(breaks=quantile(india$cage,c(0:10)/10)) n=length(india$cage) B=500 alpha=.95 taus=c(1:24)/25 print.taus=c(1:4)/5 ## Inference on average growth rate piv.bsp <- npqr(formula=formula, data=india.subset, basis=basis.bsp, var="cage", taus=taus, print.taus=print.taus, B=B, nderivs=1, average=1, alpha=alpha, process="pivotal", rearrange=FALSE, uniform=TRUE, se="unconditional", printOutput=TRUE, method="fn") yrange<-range(piv.bsp$CI) xrange<-c(0,1) plot(xrange,yrange,type="n",xlab="",ylab="Average Growth (cm/month)") lines(piv.bsp$taus,piv.bsp$point.est) lines(piv.bsp$taus,piv.bsp$CI[1,,1],col="blue") lines(piv.bsp$taus,piv.bsp$CI[1,,2],col="blue") title("Average Growth Rate") ## Estimation on average growth acceleration with no inference piv.bsp.secondderiv <- npqr(formula=formula, data=india.subset, basis=basis.bsp, var="cage", taus=taus, print.taus=print.taus, B=B, nderivs=2, average=0, alpha=alpha, process="none", se="conditional", rearrange=FALSE, printOutput=FALSE, method="fn") xsurf<-as.vector(piv.bsp.secondderiv$taus) ysurf<-as.vector(piv.bsp.secondderiv$var.unique) zsurf<-t(piv.bsp.secondderiv$point.est) persp(xsurf, ysurf, zsurf, xlab="Quantile", ylab="Age (months)", zlab="Growth Acceleration", ticktype="detailed", phi=30, theta=120, d=5, col="green", shade=0.75, main="Growth Acceleration")
A method for the generic function npqr
. It computes, via a pivotal method, the t-statistic used to conduct inference in nonparametric series quantile regression models, as well as outputting confidence intervals and hypothesis test p-values at a user-specified level.
pivotal(data=data, B=B, taus, formula, basis = NULL, alpha=0.05, var, load, rearrange=F, rearrange.vars="quantile", uniform=F, se="unconditional", average=T, nderivs=1, method="fn")
pivotal(data=data, B=B, taus, formula, basis = NULL, alpha=0.05, var, load, rearrange=F, rearrange.vars="quantile", uniform=F, se="unconditional", average=T, nderivs=1, method="fn")
data |
a data.frame in which to interpret the variables named in the |
B |
the number of simulations to be performed. |
taus |
a numerical vector, whose entries are strictly between 0 and 1, containing the quantile indexes of interest. |
formula |
a formula object, with the response Y on the left of a ~ operator, and the covariate terms, separated by + operators on the right, not including the regressor whose effect is to be estimated nonparametrically. Operators such as '*', ':', 'log()', and 'I()' are allowable. However, factor variables should be constructed prior to entry in the formula: the 'factor()' operator is not allowable. |
basis |
either a basis generated using the |
alpha |
a real number between 0 and 1: the desired significance level (e.g., 0.05). |
var |
a column name within |
load |
optional manual input of loading vector (or matrix of loading vectors) that will be used as data points at which inference will be performed and over which hypothesis tests will be conducted. Each vector of |
rearrange |
a boolean specifiying whether estimates will be monotonized prior to performing inference (requires that |
rearrange.vars |
if |
uniform |
a boolean specifying whether inference will be uniform across observations and quantiles or done in a pointwise manner. |
se |
either "conditional" or "unconditional". Specifies whether standard errors, for pivotal and gaussian processes, will be conditional on the sample or not. |
average |
if |
nderivs |
the number of derivatives of the conditional quantile function upon which inference should be performed. |
method |
method to be implemented in quantile regressions: passed to function |
pivotal
returns a list containing the following elements:
qfits |
a list whose length is equal to the length of |
point.est |
a matrix containing the point estimates of interest (e.g., the average derivative of the function) for each pair of loading vectors and |
var.unique |
a vector containing all values of the covariate of interest with no repeated values. |
CI |
an array containing the two-sided confidence interval for each pair of loading vectors and |
CI.oneSided |
an array containing the one-sided confidence bounds for each pair of loading vectors and |
std.error |
a matrix containing estimated standard errors for the quantile regression point estimates for each pair of loading vectors and |
pvalues |
a vector containing the p-values for hypothesis tests of three null hypotheses. First, that theta(tau,w) <= 0 for all (tau,w) pairs, where theta is the quantity of interest (e.g., the derivative of the function at each quantile and at each observation). Second, that theta(tau,w) >= 0 for all (tau,w) pairs. Third, that theta(tau,w) = 0 for all (tau,w) pairs. |
load |
the loading vector or matrix of loading vectors used as data points at which inference was performed and over which hypothesis tests were conducted. If |
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
Belloni, A., Chernozhukov, V., and I. Fernandez-Val (2011), "Conditional quantile processes based on series or many regressors," arXiv:1105.6154.
A wrapper for poly
, dpoly
, and ddpoly
.
poly.wrap(x, degree = 1, coefs = NULL, nderivs = 1, raw = FALSE)
poly.wrap(x, degree = 1, coefs = NULL, nderivs = 1, raw = FALSE)
x |
a numeric vector at which to evaluate the polynomial. |
degree |
the degree of the polynomial. Must be less than the number of unique points if |
coefs |
for prediction, coefficients from a previous fit. |
nderivs |
allowable values are 0, 1, and 2. If |
raw |
if true, use raw and not orthogonal polynomials. |
poly.wrap
returns the value returned by poly
, dpoly
, or ddpoly
, depending on the value of nderivs
.
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
Remove I() tags from a formula. Used in the process of computing the symbolic derivative of the right hand side of a formula.
removeI(inString)
removeI(inString)
inString |
a character object |
removeI
returns a character object identical to inString
but with any I() tags removed
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
A method for the generic function npqr
. It computes, via a weighted bootstrap method, the t-statistic used to conduct inference in nonparametric series quantile regression models, as well as outputting confidence intervals and hypothesis test p-values at a user-specified level.
wbootstrap(data = data, B = B, taus, formula, basis = NULL, alpha=0.05, var, load, rearrange=F, rearrange.vars="quantile", uniform=F, average=T, nderivs=1, method = "fn")
wbootstrap(data = data, B = B, taus, formula, basis = NULL, alpha=0.05, var, load, rearrange=F, rearrange.vars="quantile", uniform=F, average=T, nderivs=1, method = "fn")
data |
a data.frame in which to interpret the variables named in the |
B |
the number of bootstrap repetitions to be performed. |
taus |
a numerical vector, whose entries are strictly between 0 and 1, containing the quantile indexes of interest. |
formula |
a formula object, with the response Y on the left of a ~ operator, and the covariate terms, separated by + operators on the right, not including the regressor whose effect is to be estimated nonparametrically. Operators such as '*', ':', 'log()', and 'I()' are allowable. However, factor variables should be constructed prior to entry in the formula: the 'factor()' operator is not allowable. |
basis |
either a basis generated using the |
alpha |
a real number between 0 and 1: the desired significance level (e.g., 0.05). |
var |
a column name within |
load |
optional manual input of loading vector (or matrix of loading vectors) that will be used as data points at which inference will be performed and over which hypothesis tests will be conducted. Each vector of |
rearrange |
a boolean specifiying whether estimates will be monotonized prior to performing inference (requires that |
rearrange.vars |
if |
uniform |
a boolean specifying whether inference will be uniform across observations and quantiles or done in a pointwise manner. |
average |
if |
nderivs |
the number of derivatives of the function itself upon which inference should be performed. |
method |
method to be implemented in quantile regressions: passed to function |
wbootstrap
returns a list containing the following elements:
qfits |
a list whose length is equal to the length of |
point.est |
a matrix containing the point estimates of interest (e.g., the average derivative of the function) for each pair of loading vectors and |
var.unique |
a vector containing all values of the covariate of interest with no repeated values. |
CI |
an array containing the two-sided confidence interval for each pair of loading vectors and |
CI.oneSided |
an array containing the one-sided confidence bounds for each pair of loading vectors and |
std.error |
a matrix containing estimated standard errors for the point estimates for each pair of loading vectors and |
pvalues |
a vector containing the p-values for hypothesis tests of three null hypotheses. First, that theta(tau,w) <= 0 for all (tau,w) pairs, where theta is the quantity of interest (e.g., the derivative of the function at each quantile and at each observation). Second, that theta(tau,w) >= 0 for all (tau,w) pairs. Third, that theta(tau,w) = 0 for all (tau,w) pairs. |
load |
the loading vector or matrix of loading vectors used as data points at which inference was performed and over which hypothesis tests were conducted. If |
Michael Lipsitz, Alexandre Belloni, Victor Chernozhukov, Ivan Fernandez-Val
Belloni, A., Chernozhukov, V., and I. Fernandez-Val (2011), "Conditional quantile processes based on series or many regressors," arXiv:1105.6154.