(Half-)Normal probability plots with simulated envelopes for
unitquantreg objects
Source: R/hnp.R
hnp.RdProduces a (half-)normal probability plot from a fitted model
object of class unitquantreg.
Usage
hnp(object, ...)
# S3 method for unitquantreg
hnp(
object,
nsim = 99,
halfnormal = TRUE,
plot = TRUE,
output = TRUE,
level = 0.95,
resid.type = c("quantile", "cox-snell"),
...
)Arguments
- object
fitted model object of class
unitquantreg.- ...
currently not used.
- nsim
number of simulations used to compute envelope. Default is 99.
- halfnormal
logical. If
TRUE, a half-normal plot is produced. IfFALSE, a normal plot is produced.- plot
Should the (half-)normal plot be plotted? Default is
TRUE.- output
Should the output be returned? Default is
TRUE.- level
confidence level of the simulated envelope. Default is 0.95.
- resid.type
type of residuals to be used. The default is
quantile. Seeresiduals.unitquantregfor further details.
Value
A list with the following components in ordered
(and absolute if halfnormal is TRUE) values:
- obs
the observed residuals.
- teo
the theoretical residuals.
- lower
lower envelope band.
- median
median envelope band.
- upper
upper envelope band.
- time_elapsed
time elapsed to fit the
nsimmodels.
Details
Residuals plots with simulated envelope were proposed by Atkinson (1981) and can be construct as follows:
generate sample set of \(n\) independent observations from the estimated parameters of the fitted model;
fit the model using the generated sample, if
halfnormalisTRUEcompute the absolute values of the residuals and arrange them in order;repeat steps (1) and (2)
nsimnumber of times;consider the \(n\) sets of the
nsimordered statistics of the residuals, then for each set compute the quantilelevel/2, the median and the quantile 1 -level/2;plot these values and the ordered residuals of the original sample set versus the expected order statistics of a (half)-normal distribution, which is approximated as $$G^{-1} \left(\frac{i + n - 0.125}{2n + 0.5} \right)$$ for half-normal plots, i.e.,
halfnormal=TRUEor $$G^{-1} \left(\frac{i - 0.375}{n + 0.25}\right)$$ for normal plots, i.e.,halfnormal=FALSE, where \(G(\cdot)\) is the the cumulative distribution function of standard Normal distribution forquantileresiduals or the standard exponential distribution for thecox-snellresiduals.
According to Atkinson (1981), if the model was correctly specified then no
more than level100% of the observations are expected to appear
outside the envelope bands. Additionally, if a large proportion of the
observations lies outside the envelope, thus one has evidence against
the adequacy of the fitted model.
References
Atkinson, A. C., (1981). Two graphical displays for outlying and influential observations in regression. Biometrika 68(1), 13--20.