# diagnose.qc: Diagnose Quantile Crossing In qrcm: Quantile Regression Coefficients Modeling

## Description

Diagnose quantile crossing in a model estimated with `iqr`.

## Usage

 `1` ```diagnose.qc(obj) ```

## Arguments

 `obj` an object created with `iqr`.

## Details

The function determines if quantile crossing occurs in your fitted model, and provides a number of diagnostic tools.

Local quantile crossing is defined by `obj\$PDF < 0`, and is obtained when the quantile function, say Q(p | x), has negative first derivatives at the values of p that correspond to the observed data. Global quantile crossing occurs when the conditional quantile function has negative first derivatives at some values of p. To assess global crossing, a grid of approximately 1000 quantiles is used. Note that local crossing is a special case of global crossing.

The function will assess local and global crossing, and return a summary pcross of the quantiles at which global crossing occurs. It is important to understand that crossing at extremely low or high quantiles is very common, but may be considered irrelevant in practice. For example, if all observations have crossing quantiles, implying that global crossing is 100%, but crossing only occurs at quantile above 0.999, the fitted model can be safely used for prediction. Very frequently, crossing occurs at extreme quantiles that do not correspond to any observation in the data.

This command will also compute a crossIndex, that represents the average length, across observations, of the sub-intervals p* such that Q'(p* | x) < 0. For example, if Q'(p | x) < 0 in the interval p* = (0.3,0.5), the contribution to the crossIndex is 0.5 - 0.3 = 0.2. If crossing is detected at a single quantile, the interval is assumed to have length 1e-6. In principle, the crossIndex is always between 0 (no quantile crossing) and 1 (all observations crossing at all quantiles, which is clearly impossible). In practice, values of crossIndex greater than 0.05 are relatively rare.

## Value

A list with the following items:

 `qc` a data frame with two columns (qc.local, qc.global) containing logical indicators of local and global quantile crossing for each observation in the data. `qc.local, qc.global` the absolute number of observations for which local/global quantile crossing was detected. `pcross` a frequency table of the values of p at which global quantile crossing was detected. `crossIndex` the estimated index of crossing described above.

If no quantile crossing is detected, `pcross = NULL`, and `crossIndex = 0`.

## Author(s)

Paolo Frumento paolo.frumento@unipi.it

## References

Sottile, G., and Frumento, P. (2021). Parametric estimation of non-crossing quantile functions. Statistical Modelling [forthcoming].

`iqr`, `qc.control`.
 ``` 1 2 3 4 5 6 7 8 9 10``` ``` # Using simulated data n <- 1000 x1 <- runif(n,0,3) x2 <- rbinom(n,1,0.5) u <- runif(n) y <- 1*qexp(u) + (2 + 3*u)*x1 + 5*x2 m <- iqr(y ~ x1 + x2, formula.p = ~ slp(p,7)) diagnose.qc(m) ```