| Title: | Nonlinear and Penalized Quantile Regression Coefficients Modeling |
|---|---|
| Description: | Penalized and nonlinear parametric modeling of quantile regression coefficient functions. The penalized integrated loss minimization estimator (lasso and group lasso penalties) of Sottile, Frumento, Chiodi and Bottai (2020) <doi:10.1177/1471082X19825523> performs covariate selection using the information on all quantiles simultaneously. Nonlinear parametric quantile models, in which the conditional quantile function can be a nonlinear function of the parameters, of the covariates or both, are estimated by integrated loss minimization as in Bottai and Cilluffo (2020) <doi:10.1177/0962280220941159>. Both approaches extend the quantile regression coefficients modeling framework of Frumento and Bottai (2016) <doi:10.1111/biom.12410> implemented in 'qrcm'. |
| Authors: | Gianluca Sottile [aut, cre] (ORCID: <https://orcid.org/0000-0001-9347-7251>), Paolo Frumento [aut, cph] (author of parts of the code adapted from 'qrcm') |
| Maintainer: | Gianluca Sottile <[email protected]> |
| License: | GPL-2 |
| Version: | 1.0.0 |
| Built: | 2026-10-17 10:25:15 UTC |
| Source: | https://github.com/gianluca-sottile/qrcmnp |
Extract Coefficients of a Penalized QRCM
## S3 method for class 'piqr' coef(object, pos.lambda, lambda, ...)## S3 method for class 'piqr' coef(object, pos.lambda, lambda, ...)
object |
an object of class |
pos.lambda |
the position of the selected value of |
lambda |
alternatively, a value of |
... |
not used. |
The matrix at the selected
.
K-fold cross-validation of the integrated loss along the path of a
piqr() fit (uncensored data only).
cv_piqr( formula, formula.p = ~slp(p, 3), weights, data, s, penalty = c("lasso", "group"), penalty.factor, nlambda = 100, lambda.min.ratio, lambda, nfolds = 10, foldid, ... )cv_piqr( formula, formula.p = ~slp(p, 3), weights, data, s, penalty = c("lasso", "group"), penalty.factor, nlambda = 100, lambda.min.ratio, lambda, nfolds = 10, foldid, ... )
formula, formula.p, weights, data, s, penalty, penalty.factor, nlambda, lambda.min.ratio, lambda
|
as in |
nfolds |
number of folds (default 10). |
foldid |
an optional vector of fold indicators (integers in
|
... |
further arguments passed to |
The cross-validated loss of observation is
,
computed numerically, where is estimated without
the fold containing . In each fold the variables are standardized
as in the full data and is rescaled by the size of the
training sample, so that the same value of corresponds to
the same penalty in all fits. lambda.1se is the largest
whose error is within one standard error of the minimum.
An object of class "cv.piqr", a list with items lambda, cvm
(mean cross-validated loss), cvsd (its standard error), lambda.min,
lambda.1se, pos.min, pos.1se (positions in lambda), foldid and
fit (the piqr() fit on the full data).
set.seed(1) n <- 300 dat <- data.frame(x1 = runif(n), x2 = runif(n), x3 = runif(n)) dat$y <- 1 + qnorm(runif(n)) + 2 * dat$x1 cv <- cv_piqr(y ~ x1 + x2 + x3, formula.p = ~ slp(p, 2), data = dat, nfolds = 5, nlambda = 20) cv plot(cv) coef(cv$fit, pos.lambda = cv$pos.1se)set.seed(1) n <- 300 dat <- data.frame(x1 = runif(n), x2 = runif(n), x3 = runif(n)) dat$y <- 1 + qnorm(runif(n)) + 2 * dat$x1 cv <- cv_piqr(y ~ x1 + x2 + x3, formula.p = ~ slp(p, 2), data = dat, nfolds = 5, nlambda = 20) cv plot(cv) coef(cv$fit, pos.lambda = cv$pos.1se)
Computes the goodness-of-fit criteria of Bottai and Cilluffo (2020,
Section 3) for one or more niqr() fits.
gof.niqr(object, ...)gof.niqr(object, ...)
object |
an object of class |
... |
further objects of class |
With the minimized (average) loss, the number of
parameters and the sample size, the criteria are
and
(AIC.log, BIC.log), and , .
Smaller values indicate a better fit. Bottai and Cilluffo (2020) write the
last two criteria in terms of ; here the total loss is
used, otherwise the penalty would dominate. Note that, unlike the log
versions, AIC and BIC depend on the scale of the response; the log
versions are recommended.
A data frame with columns npar, loss, AIC, BIC, AIC.log
and BIC.log (one row per model).
Bottai, M. and Cilluffo, G. (2020). Nonlinear parametric quantile models. Statistical Methods in Medical Research, 29(12), 3757-3769. doi:10.1177/0962280220941159
Computes an information criterion along the path of a piqr() fit and
returns the value of at which it is minimized.
gof.piqr( object, method = c("BIC", "AIC"), Cn = 1, plot = TRUE, logi = TRUE, df = NULL, ... )gof.piqr( object, method = c("BIC", "AIC"), Cn = 1, plot = TRUE, logi = TRUE, df = NULL, ... )
object |
an object of class |
method |
the criterion, |
Cn |
a positive constant (or a character string with an expression in
|
plot |
logical: plot the criterion against |
logi |
logical: if |
df |
how to count the degrees of freedom: |
... |
further graphical parameters. |
With logi = TRUE, the criteria of Sottile et al. (2020, eq. 3.6-3.7) are
where is the minimized integrated loss. With logi = FALSE,
and .
Note that Bottai and Cilluffo (2020) define the log-criteria with
and ; the selected model is the same as with
the definition above when for the BIC.
A list with items call, minLambda (the selected value of
), dfMinLambda (its degrees of freedom), posMinLambda (its
position in object$lambda), betaMin (the coefficients at the selected
) and curve (the criterion along the path).
Sottile, G., Frumento, P., Chiodi, M. and Bottai, M. (2020). A penalized approach to covariate selection through quantile regression coefficient models. Statistical Modelling, 20(4), 369-385. doi:10.1177/1471082X19825523
Lee, E. R., Noh, H. and Park, B. U. (2014). Model selection via Bayesian information criterion for quantile regression models. Journal of the American Statistical Association, 109(505), 216-229. doi:10.1080/01621459.2013.836975
set.seed(1) n <- 200 x1 <- runif(n); x2 <- runif(n) y <- 1 + qnorm(runif(n)) + 2 * x1 fit <- piqr(y ~ x1 + x2, formula.p = ~ slp(p, 2), nlambda = 20) gof.piqr(fit, method = "AIC") gof.piqr(fit, method = "BIC", df = "parameters", plot = FALSE)$posMinLambdaset.seed(1) n <- 200 x1 <- runif(n); x2 <- runif(n) y <- 1 + qnorm(runif(n)) + 2 * x1 fit <- piqr(y ~ x1 + x2, formula.p = ~ slp(p, 2), nlambda = 20) gof.piqr(fit, method = "AIC") gof.piqr(fit, method = "BIC", df = "parameters", plot = FALSE)$posMinLambda
Estimates a parametric model for the whole conditional quantile function, possibly nonlinear in the parameters, in the covariates, or both, by minimizing the integrated loss function of Frumento and Bottai (2016), as described by Bottai and Cilluffo (2020).
niqr( formula, data, fun, fun2 = NULL, x0, weights, cluster, control = niqr.control(), ... )niqr( formula, data, fun, fun2 = NULL, x0, weights, cluster, control = niqr.control(), ... )
formula |
a two-sided formula |
data |
an optional data frame containing the variables in |
fun |
a function |
fun2 |
an optional function |
x0 |
starting values for |
weights |
optional non-negative weights: a vector, or a variable in
|
cluster |
an optional vector, or a variable in |
control |
a list of control parameters, see |
... |
not used. Arguments of the interface of 'qrcmNP' 0.2.x ( |
Let be a parametric model for the
conditional quantile function of given . The estimator
minimizes
where . The
integral is computed with the trapezoidal rule on a grid of n.p values of
(denser in the tails), splitting the interval containing
, where the
integrand is not differentiable. The gradient
is computed in the same way, with numerical derivatives of fun (or of
fun2) with respect to . The loss is minimized by a damped
Newton algorithm that uses the Hessian
where is the derivative with respect to , i.e. the inverse of
the conditional density. is positive semi-definite and estimates
the Hessian of the expected loss at the true parameter.
The asymptotic covariance matrix of is estimated by the
sandwich formula (Bottai and Cilluffo, 2020,
Theorem 3), where is the covariance of the individual
contributions to the gradient (summed within clusters if cluster is
supplied), or by the (cluster) bootstrap (niqr.control(se = "boot")).
The model is assumed to be monotonically increasing in for all
observations. A warning is given if quantile crossing is detected.
Good starting values x0 are important: the loss function may have several
local minima when is not one-to-one in
(Bottai and Cilluffo, 2020, Theorem 1).
An object of class "niqr", a list with items:
coefficients |
the estimated |
se |
standard errors. |
covar |
the estimated covariance matrix of |
obj.function |
the minimized loss |
gradient, hessian, omega
|
gradient, Hessian and outer product of the
gradient at |
CDF, PDF
|
fitted conditional CDF and density at the observed responses. |
converged, n.it
|
convergence indicator and number of iterations. |
call, terms, X, y, weights, cluster, fun, fun2, control
|
the elements of the model. |
The matrix interface niqr(fun, fun2, x0, X, y) of 'qrcmNP' 0.2.x was
removed in version 1.0.0: use niqr(y ~ x, data, fun, fun2, x0), where the
model matrix of the formula plays the role of the old X.
Bottai, M. and Cilluffo, G. (2020). Nonlinear parametric quantile models. Statistical Methods in Medical Research, 29(12), 3757-3769. doi:10.1177/0962280220941159
Frumento, P. and Bottai, M. (2016). Parametric modeling of quantile regression coefficient functions. Biometrics, 72(1), 74-84. doi:10.1111/biom.12410
niqr.control(), summary.niqr(), predict.niqr(),
plot.niqr(), gof.niqr(), test.fit.niqr().
## Model linear in the covariates, nonlinear in the parameters: ## beta0(p) = theta1 + exp(theta2 * p), beta1(p) = theta3 + theta4 * p set.seed(1234) n <- 300 x <- runif(n) fun <- function(theta, p) { cbind(theta[1] + exp(theta[2] * p), theta[3] + theta[4] * p) } u <- runif(n) beta <- fun(c(1, 1, 1, 1), u) y <- beta[, 1] + beta[, 2] * x m <- niqr(y ~ x, fun = fun, x0 = c(a = 0.5, b = 0.5, c = 0.5, d = 0.5)) summary(m) predict(m, type = "QF", p = c(0.1, 0.5, 0.9), newdata = data.frame(x = 0.5)) ## Model nonlinear in the covariate: Hill dose-response quantile function ## Q(p | dose) = b0(p) + (b1 - b0(p)) / (1 + 10^(b3 - log10(dose))) set.seed(1) dose <- rep(10^seq(-2, 2, length.out = 20), each = 15) fun.h <- function(theta, p) { cbind(theta[1] + exp(theta[2]) * qnorm(p), theta[3], theta[4]) } fun2.h <- function(beta, X) { beta[, 1] + (beta[, 2] - beta[, 1]) / (1 + 10^(beta[, 3] - log10(X[, 2]))) } yh <- fun2.h(fun.h(c(1, log(0.5), 10, 0), runif(length(dose))), cbind(1, dose)) mh <- niqr(yh ~ dose, fun = fun.h, fun2 = fun2.h, x0 = c(0, 0, 5, 0.5)) summary(mh)## Model linear in the covariates, nonlinear in the parameters: ## beta0(p) = theta1 + exp(theta2 * p), beta1(p) = theta3 + theta4 * p set.seed(1234) n <- 300 x <- runif(n) fun <- function(theta, p) { cbind(theta[1] + exp(theta[2] * p), theta[3] + theta[4] * p) } u <- runif(n) beta <- fun(c(1, 1, 1, 1), u) y <- beta[, 1] + beta[, 2] * x m <- niqr(y ~ x, fun = fun, x0 = c(a = 0.5, b = 0.5, c = 0.5, d = 0.5)) summary(m) predict(m, type = "QF", p = c(0.1, 0.5, 0.9), newdata = data.frame(x = 0.5)) ## Model nonlinear in the covariate: Hill dose-response quantile function ## Q(p | dose) = b0(p) + (b1 - b0(p)) / (1 + 10^(b3 - log10(dose))) set.seed(1) dose <- rep(10^seq(-2, 2, length.out = 20), each = 15) fun.h <- function(theta, p) { cbind(theta[1] + exp(theta[2]) * qnorm(p), theta[3], theta[4]) } fun2.h <- function(beta, X) { beta[, 1] + (beta[, 2] - beta[, 1]) / (1 + 10^(beta[, 3] - log10(X[, 2]))) } yh <- fun2.h(fun.h(c(1, log(0.5), 10, 0), runif(length(dose))), cbind(1, dose)) mh <- niqr(yh ~ dose, fun = fun.h, fun2 = fun2.h, x0 = c(0, 0, 5, 0.5)) summary(mh)
Control Parameters for niqr
niqr.control( tol = 1e-06, maxit = 100, n.p = 199, eps = 1e-04, h = .Machine$double.eps^(1/3), se = c("sandwich", "boot", "none"), R = 200, verbose = FALSE )niqr.control( tol = 1e-06, maxit = 100, n.p = 199, eps = 1e-04, h = .Machine$double.eps^(1/3), se = c("sandwich", "boot", "none"), R = 200, verbose = FALSE )
tol |
convergence tolerance on the relative change of the parameters
(default |
maxit |
maximum number of iterations (default 100). |
n.p |
number of grid points used to compute the integrals over |
eps |
the grid covers |
h |
relative step for numerical derivatives (default
|
se |
how to estimate the covariance matrix: |
R |
number of bootstrap replications (default 200). |
verbose |
logical: print the progress of the algorithm? |
A list of control parameters.
Fits the penalized integrated loss minimization (PILM) estimator of
Sottile et al. (2020) along a path of values of the tuning parameter
. Quantile regression coefficients are modelled as parametric
functions of the quantile order , and covariates are selected using
the information on all quantiles simultaneously.
piqr( formula, formula.p = ~slp(p, 3), weights, data, s, nlambda = 100, lambda.min.ratio = ifelse(nobs < nvars, 0.01, 1e-04), lambda, tol = 1e-06, maxit = 100, penalty = c("lasso", "group"), penalty.factor, method = c("pnewton", "legacy"), verbose = FALSE, ... )piqr( formula, formula.p = ~slp(p, 3), weights, data, s, nlambda = 100, lambda.min.ratio = ifelse(nobs < nvars, 0.01, 1e-04), lambda, tol = 1e-06, maxit = 100, penalty = c("lasso", "group"), penalty.factor, method = c("pnewton", "legacy"), verbose = FALSE, ... )
formula |
a two-sided formula of the form |
formula.p |
a one-sided formula of the form |
weights |
an optional vector of non-negative weights. |
data |
an optional data frame, list or environment containing the
variables in |
s |
an optional |
nlambda |
number of values of |
lambda.min.ratio |
smallest value of |
lambda |
an optional user-supplied decreasing sequence of values of
|
tol |
convergence tolerance (default |
maxit |
maximum number of Newton iterations for each |
penalty |
either |
penalty.factor |
optional vector of non-negative penalty weights
|
method |
|
verbose |
logical: if |
... |
not used (an error is given for the removed argument |
Under the quantile regression coefficients model (QRCM) of Frumento and Bottai (2016), the conditional quantile function is
where is a set of known functions of (defined
by formula.p) and is a matrix of
parameters. The penalized estimator minimizes
where is the check loss of quantile regression. As suggested by
Sottile et al. (2020), and are standardized, and the
response is mapped to the interval ; the values of lambda refer
to this internal scale. The estimated coefficients are returned on the
original scale.
With method = "pnewton", for each the integrated loss is
replaced by its second-order expansion (gradient and Hessian are available in
closed form) and the resulting penalized quadratic problem is solved by
coordinate descent ("lasso") or block coordinate descent ("group"); a
backtracking line search guarantees the decrease of the penalized objective
(proximal Newton method). The path starts from
, the smallest value at which all penalized coefficients
are zero, and uses warm starts, sequential strong rules and a final check of
the Karush-Kuhn-Tucker conditions. With censored or truncated data, the
estimating equations of Frumento and Bottai (2017) replace the gradient of the
loss; since they are not the gradient of a loss function, the symmetric part
of their Jacobian is used in the quadratic approximation, and the iterate with
the smallest violation of the KKT conditions is returned (convergence is
declared when the average violation is below 5e-4).
The intercept (the first row of ) is never penalized. Use
gof.piqr() to select by AIC or BIC, cv_piqr() for
cross-validation, and refit_piqr() to re-estimate the selected model without
penalty and obtain standard errors (Sottile et al., 2020, Section 3.2).
An object of class "piqr", a list with items:
call |
the matched call. |
lambda |
the sequence of values of |
coefficients |
a list (one element for each |
covar |
a list of covariance matrices (only with |
obj.function |
the minimized (unpenalized) integrated loss, on the
original scale, for each |
df |
number of covariates (including the intercept) with nonzero
coefficients, for each |
npar |
number of nonzero coefficients, for each |
dl |
matrix of the |
seqS |
a list of 0/1 matrices indicating the nonzero coefficients. |
penalty, penalty.factor, method
|
as in the call. |
converged |
logical vector, convergence at each |
internal |
a list of objects used by the methods. |
Sottile, G., Frumento, P., Chiodi, M. and Bottai, M. (2020). A penalized approach to covariate selection through quantile regression coefficient models. Statistical Modelling, 20(4), 369-385. doi:10.1177/1471082X19825523
Frumento, P. and Bottai, M. (2016). Parametric modeling of quantile regression coefficient functions. Biometrics, 72(1), 74-84. doi:10.1111/biom.12410
Frumento, P. and Bottai, M. (2017). Parametric modeling of quantile regression coefficient functions with censored and truncated data. Biometrics, 73(4), 1179-1188. doi:10.1111/biom.12675
Friedman, J., Hastie, T. and Tibshirani, R. (2010). Regularization paths for generalized linear models via coordinate descent. Journal of Statistical Software, 33(1), 1-22. doi:10.18637/jss.v033.i01
Lee, J. D., Sun, Y. and Saunders, M. A. (2014). Proximal Newton-type methods for minimizing composite functions. SIAM Journal on Optimization, 24(3), 1420-1443. doi:10.1137/130921428
gof.piqr(), cv_piqr(), refit_piqr(), summary.piqr(),
plot.piqr(), predict.piqr().
set.seed(1234) n <- 300 x1 <- rexp(n) x2 <- runif(n, 0, 5) x3 <- rnorm(n) # irrelevant covariate # true model: beta0(p) = 1 + qnorm(p), beta1(p) = 1 + 2 p, beta2(p) = 1 u <- runif(n) y <- 1 + qnorm(u) + (1 + 2 * u) * x1 + x2 dat <- data.frame(y, x1, x2, x3) fit <- piqr(y ~ x1 + x2 + x3, formula.p = ~ slp(p, 2), data = dat, nlambda = 30) fit best <- gof.piqr(fit, method = "BIC", plot = FALSE) coef(fit, pos.lambda = best$posMinLambda) # group lasso: covariates enter or leave the model as a whole fitg <- piqr(y ~ x1 + x2 + x3, formula.p = ~ slp(p, 2), data = dat, nlambda = 30, penalty = "group") plot(fitg, xvar = "lambda") # unpenalized re-estimation of the selected model (with standard errors) m <- refit_piqr(fit, pos.lambda = best$posMinLambda) summary(m)set.seed(1234) n <- 300 x1 <- rexp(n) x2 <- runif(n, 0, 5) x3 <- rnorm(n) # irrelevant covariate # true model: beta0(p) = 1 + qnorm(p), beta1(p) = 1 + 2 p, beta2(p) = 1 u <- runif(n) y <- 1 + qnorm(u) + (1 + 2 * u) * x1 + x2 dat <- data.frame(y, x1, x2, x3) fit <- piqr(y ~ x1 + x2 + x3, formula.p = ~ slp(p, 2), data = dat, nlambda = 30) fit best <- gof.piqr(fit, method = "BIC", plot = FALSE) coef(fit, pos.lambda = best$posMinLambda) # group lasso: covariates enter or leave the model as a whole fitg <- piqr(y ~ x1 + x2 + x3, formula.p = ~ slp(p, 2), data = dat, nlambda = 30, penalty = "group") plot(fitg, xvar = "lambda") # unpenalized re-estimation of the selected model (with standard errors) m <- refit_piqr(fit, pos.lambda = best$posMinLambda) summary(m)
Plots the estimated coefficient functions (the columns of fun(theta, p))
with pointwise confidence bands, and a uniform QQ-plot of the fitted CDF.
## S3 method for class 'niqr' plot( x, conf.int = TRUE, which = NULL, ask = interactive(), polygon = TRUE, ... )## S3 method for class 'niqr' plot( x, conf.int = TRUE, which = NULL, ask = interactive(), polygon = TRUE, ... )
x |
an object of class |
conf.int |
logical: draw 95% confidence bands? |
which |
an optional vector of indices of the coefficient functions to
plot (use |
ask |
logical: choose interactively what to plot? Default |
polygon |
logical: draw the confidence bands as shaded areas? |
... |
additional graphical parameters. |
No return value, called for its side effects.
Coefficient paths, gradient paths and estimated coefficient functions
of a piqr() fit.
## S3 method for class 'piqr' plot( x, xvar = c("lambda", "objective", "grad", "beta"), pos.lambda, label = FALSE, which = NULL, ask = interactive(), polygon = TRUE, ... )## S3 method for class 'piqr' plot( x, xvar = c("lambda", "objective", "grad", "beta"), pos.lambda, label = FALSE, which = NULL, ask = interactive(), polygon = TRUE, ... )
x |
an object of class |
xvar |
what to plot: |
pos.lambda |
the position of the selected |
label |
logical: label the curves (paths only)? |
which |
for |
ask |
logical: for |
polygon |
logical: for |
... |
additional graphical parameters ( |
No return value, called for its side effects.
set.seed(1) n <- 200 x1 <- runif(n); x2 <- runif(n); x3 <- runif(n) y <- 1 + qnorm(runif(n)) + 2 * x1 - x2 fit <- piqr(y ~ x1 + x2 + x3, formula.p = ~ slp(p, 2), nlambda = 20) oldpar <- par(mfrow = c(1, 2)) plot(fit, xvar = "lambda") plot(fit, xvar = "grad") par(oldpar) plot(fit, xvar = "beta", pos.lambda = 20, which = 2)set.seed(1) n <- 200 x1 <- runif(n); x2 <- runif(n); x3 <- runif(n) y <- 1 + qnorm(runif(n)) + 2 * x1 - x2 fit <- piqr(y ~ x1 + x2 + x3, formula.p = ~ slp(p, 2), nlambda = 20) oldpar <- par(mfrow = c(1, 2)) plot(fit, xvar = "lambda") plot(fit, xvar = "grad") par(oldpar) plot(fit, xvar = "beta", pos.lambda = 20, which = 2)
Prediction after Nonlinear Parametric Quantile Models
## S3 method for class 'niqr' predict( object, type = c("beta", "CDF", "PDF", "QF", "sim"), newdata, p, se = TRUE, ... )## S3 method for class 'niqr' predict( object, type = c("beta", "CDF", "PDF", "QF", "sim"), newdata, p, se = TRUE, ... )
object |
an object of class |
type |
the type of prediction: |
newdata |
an optional data frame (for |
p |
a vector of quantile orders (for |
se |
logical: compute delta-method standard errors ( |
... |
not used. |
type = "beta": a list with one data frame for each column of fun, with
columns p, beta, and (if se = TRUE) se, low, up (95% pointwise
confidence limits).
type = "CDF" or "PDF": a vector.
type = "QF": a data frame with one column for each p or, if se = TRUE,
a list with items fit and se.fit.
type = "sim": a vector of simulated responses.
Predictions from a piqr() fit at a selected value of .
## S3 method for class 'piqr' predict( object, pos.lambda, type = c("beta", "CDF", "QF", "sim"), newdata, p, se = !is.null(object$covar), lambda, ... )## S3 method for class 'piqr' predict( object, pos.lambda, type = c("beta", "CDF", "QF", "sim"), newdata, p, se = !is.null(object$covar), lambda, ... )
object |
an object of class |
pos.lambda |
the position of the selected value of |
type |
the type of prediction: |
newdata |
an optional data frame in which to look for the covariates
(and, for |
p |
a vector of quantile orders (for |
se |
logical: should standard errors be computed? They are available only
with |
lambda |
alternatively to |
... |
not used. |
type = "beta": a list with one data frame for each covariate, with
columns p, beta (and se, low, up if se = TRUE).
type = "CDF": a data frame with columns CDF and PDF.
type = "QF": a data frame of fitted quantiles (one column for each p)
or, if se = TRUE, a list with items fit and se.fit.
type = "sim": a vector of simulated responses.
set.seed(1) n <- 200 x <- runif(n) y <- qexp(runif(n)) * (1 + x) fit <- piqr(y ~ x, formula.p = ~ slp(p, 3), nlambda = 10) predict(fit, pos.lambda = 10, type = "QF", p = c(0.25, 0.5), newdata = data.frame(x = c(0, 0.5, 1))) head(predict(fit, pos.lambda = 10, type = "CDF"))set.seed(1) n <- 200 x <- runif(n) y <- qexp(runif(n)) * (1 + x) fit <- piqr(y ~ x, formula.p = ~ slp(p, 3), nlambda = 10) predict(fit, pos.lambda = 10, type = "QF", p = c(0.25, 0.5), newdata = data.frame(x = c(0, 0.5, 1))) head(predict(fit, pos.lambda = 10, type = "CDF"))
Following Sottile et al. (2020, Section 3.2), the penalized estimator is used
to select the covariates, and the selected model is re-estimated without
penalty with qrcm::iqr(), which provides asymptotic standard errors,
Wald tests and goodness-of-fit diagnostics.
refit_piqr( object, pos.lambda, criterion = c("BIC", "AIC"), keep = c("covariates", "coefficients"), data, ... )refit_piqr( object, pos.lambda, criterion = c("BIC", "AIC"), keep = c("covariates", "coefficients"), data, ... )
object |
an object of class |
pos.lambda |
the position of the selected value of |
criterion |
|
keep |
|
data |
an optional data frame; by default, the |
... |
further arguments passed to |
An object of class "iqr" (see qrcm::iqr()), with an additional
attribute "pos.lambda".
The standard errors are conditional on the selected model and do not account for the selection step.
piqr(), gof.piqr(), qrcm::iqr(), qrcm::summary.iqr()
set.seed(1) n <- 300 x1 <- runif(n); x2 <- runif(n) dat <- data.frame(y = 1 + qnorm(runif(n)) + 2 * x1, x1, x2) fit <- piqr(y ~ x1 + x2, formula.p = ~ slp(p, 2), data = dat, nlambda = 20) m <- refit_piqr(fit) summary(m)set.seed(1) n <- 300 x1 <- runif(n); x2 <- runif(n) dat <- data.frame(y = 1 + qnorm(runif(n)) + 2 * x1, x1, x2) fit <- piqr(y ~ x1 + x2, formula.p = ~ slp(p, 2), data = dat, nlambda = 20) m <- refit_piqr(fit) summary(m)
Summarize a Nonlinear Parametric Quantile Model
## S3 method for class 'niqr' summary(object, p, ...) ## S3 method for class 'summary.niqr' print(x, digits = max(3L, getOption("digits") - 3L), ...)## S3 method for class 'niqr' summary(object, p, ...) ## S3 method for class 'summary.niqr' print(x, digits = max(3L, getOption("digits") - 3L), ...)
object |
an object of class |
p |
an optional vector of quantile orders: if supplied, the summary
reports the coefficient functions |
... |
for future methods. |
x |
an object of class |
digits |
number of significant digits. |
An object of class "summary.niqr". Without p: the table of
estimated parameters with standard errors, z-values and p-values, the
minimized loss and the information criteria of gof.niqr(). With p: a
list with one table for each value of p.
Summary of a piqr() fit at a selected value of .
## S3 method for class 'piqr' summary(object, pos.lambda, SE = FALSE, p, cov = FALSE, lambda, ...) ## S3 method for class 'summary.piqr' print(x, digits = max(3L, getOption("digits") - 3L), ...)## S3 method for class 'piqr' summary(object, pos.lambda, SE = FALSE, p, cov = FALSE, lambda, ...) ## S3 method for class 'summary.piqr' print(x, digits = max(3L, getOption("digits") - 3L), ...)
object |
an object of class |
pos.lambda |
the position of the selected value of |
SE |
logical: if |
p |
an optional vector of quantile orders. If supplied, the summary
reports |
cov |
logical: if |
lambda |
alternatively to |
... |
for future methods. |
x |
an object of class |
digits |
number of significant digits. |
An object of class "summary.piqr". Without p: a list with the
selected lambda, the matrix of coefficients, their standard errors
se (if requested and available), the minimized loss obj.function, the
number of observations n and of nonzero parameters free.par. With
p: a list with one element for each value of p, containing the
estimated (and standard errors, if available).
piqr(), gof.piqr(), refit_piqr().
set.seed(1) n <- 200 x1 <- runif(n); x2 <- runif(n) y <- 1 + qnorm(runif(n)) + 2 * x1 fit <- piqr(y ~ x1 + x2, formula.p = ~ slp(p, 2), nlambda = 20) best <- gof.piqr(fit, plot = FALSE) summary(fit, pos.lambda = best$posMinLambda) summary(fit, pos.lambda = best$posMinLambda, p = c(0.1, 0.5, 0.9))set.seed(1) n <- 200 x1 <- runif(n); x2 <- runif(n) y <- 1 + qnorm(runif(n)) + 2 * x1 fit <- piqr(y ~ x1 + x2, formula.p = ~ slp(p, 2), nlambda = 20) best <- gof.piqr(fit, plot = FALSE) summary(fit, pos.lambda = best$posMinLambda) summary(fit, pos.lambda = best$posMinLambda, p = c(0.1, 0.5, 0.9))
Under a correctly specified model, the fitted values of the conditional
CDF, , are approximately
uniformly distributed. This function computes the Kolmogorov-Smirnov and
Cramer-von Mises statistics of their empirical distribution, and obtains
p-values by parametric bootstrap, as in qrcm::test.fit().
## S3 method for class 'niqr' test.fit(object, R = 100, trace = FALSE, ...)## S3 method for class 'niqr' test.fit(object, R = 100, trace = FALSE, ...)
object |
an object of class |
R |
number of bootstrap replications (default 100). |
trace |
logical: print the progress? |
... |
not used. |
A matrix with the test statistics and their bootstrap p-values.