# qqbounds: Computation of confidence intervals for qqplot In distr: Object Oriented Implementation of Distributions

## Description

We compute confidence intervals for QQ plots. These can be simultaneous (to check whether the whole data set is compatible) or pointwise (to check whether each (single) data point is compatible);

## Usage

 1 2 3 qqbounds(x,D,alpha,n,withConf.pw, withConf.sim, exact.sCI=(n<100),exact.pCI=(n<100), nosym.pCI = FALSE, debug = FALSE)

## Arguments

 x data to be checked for compatibility with distribution D. D object of class "UnivariateDistribution", the assumed data distribution. alpha confidence level n sample size withConf.pw logical; shall pointwise confidence lines be computed? withConf.sim logical; shall simultaneous confidence lines be computed? exact.pCI logical; shall pointwise CIs be determined with exact Binomial distribution? exact.sCI logical; shall simultaneous CIs be determined with exact kolmogorov distribution? nosym.pCI logical; shall we use (shortest) asymmetric CIs? debug logical; if TRUE additional output to debug confidence bounds.

## Details

Both simultaneous and pointwise confidence intervals come in a finite-sample and an asymptotic version; the finite sample versions will get quite slow for large data sets x, so in these cases the asymptotic version will be preferrable.
For simultaneous intervals, the finite sample version is based on C function "pkolmogorov2x" from package stats, while the asymptotic one uses R function pkstwo again from package stats, both taken from the code to ks.test.

Both finite sample and asymptotic versions use the fact, that the distribution of the supremal distance between the empirical distribution F.emp and the corresponding theoretical one F (assuming data from F) does not depend on F for continuous distribution F and leads to the Kolmogorov distribution (compare, e.g. Durbin(1973)). In case of F with jumps, the corresponding Kolmogorov distribution is used to produce conservative intervals.
For pointwise intervals, the finite sample version is based on corresponding binomial distributions, (compare e.g., Fisz(1963)), while the asymptotic one uses a CLT approximation for this binomial distribution. In fact, this approximation is only valid for distributions with strictly positive density at the evaluation quantiles.

In the finite sample version, the binomial distributions will in general not be symmetric, so that, by setting nosym.pCI to TRUE we may produce shortest asymmetric confidence intervals (albeit with a considerable computational effort).

The symmetric intervals returned by default will be conservative (which also applies to distributions with jumps in this case).

For distributions with jumps or with density (nearly) equal to 0 at the corresponding quantile, we use the approximation of (D-E(D))/sd(D) by the standard normal at these points; this latter approximation is only available if package distrEx is installed; otherwise the corresponding columns will be filled with NA.

## Value

A list with components crit — a matrix with the lower and upper confidence bounds, and err a logical vector of length 2.

Component crit is a matrix with length(x) rows and four columns c("sim.left","sim.right","pw.left","pw.right"). Entries will be set to NA if the corresponding x component is not in support(D) or if the computation method returned an error or if the corresponding parts have not been required (if withConf.pw or withConf.sim is FALSE).

err has components pw —do we have a non-error return value for the computation of pointwise CI's (FALSE if withConf.pw is FALSE)— and sim —do we have a non-error return value for the computation of simultaneous CI's (FALSE if withConf.sim is FALSE).

## Author(s)

Peter Ruckdeschel [email protected]

## References

Durbin, J. (1973) Distribution theory for tests based on the sample distribution function. SIAM.

Fisz, M. (1963). Probability Theory and Mathematical Statistics. 3rd ed. Wiley, New York.

qqplot from package stats – the standard QQ plot function, ks.test again from package stats for the implementation of the Kolmogorov distributions; qqplot from package distr for comparisons of distributions, and qqplot from package distrMod for comparisons of data with models, as well as qqplot for checking of corresponding robust esimators.

## Examples

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 qqplot(Norm(15,sqrt(30)), Chisq(df=15)) ## uses: qqbounds(x = rnorm(30),Norm(),alpha=0.95,n=30, withConf.pw = TRUE, withConf.sim = TRUE, exact.sCI=TRUE ,exact.pCI= TRUE, nosym.pCI = FALSE) qqbounds(x = rchisq(30,df=4),Chisq(df=4),alpha=0.95,n=30, withConf.pw = TRUE, withConf.sim = TRUE, exact.sCI=FALSE ,exact.pCI= FALSE, nosym.pCI = FALSE) qqbounds(x = rchisq(30,df=4),Chisq(df=4),alpha=0.95,n=30, withConf.pw = TRUE, withConf.sim = TRUE, exact.sCI=TRUE ,exact.pCI= TRUE, nosym.pCI = TRUE)

### Example output

:startupmsg>  Utilities for Start-Up Messages (version 0.9.5)
:startupmsg>
:startupmsg>  NEWS("startupmsg")

:distr>  Object Oriented Implementation of Distributions (version
:distr>  2.7.0)
:distr>
:distr>  Attention: Arithmetics on distribution objects are
:distr>  understood as operations on corresponding random variables
:distr>  (r.v.s); see distrARITH().
:distr>
:distr>  Some functions from package 'stats' are intentionally masked
:distr>
:distr>  Note that global options are controlled by distroptions()
:distr>  ---c.f. ?"distroptions".
:distr>
:distr>    http://distr.r-forge.r-project.org/
:distr>  Package "distrDoc" provides a vignette to this package as
:distr>  well as to several extension packages; try
:distr>  vignette("distr").

Attaching package: 'distr'

The following objects are masked from 'package:stats':

df, qqplot, sd

\$crit
sim.left   sim.right    pw.left     pw.right
[1,] -4.7534243088 -0.65081083 -3.1134581 -1.181856795
[2,] -4.7534243088 -0.63430973 -2.9941634 -1.063978230
[3,] -4.7534243088 -0.56883448 -2.4577358 -0.975589320
[4,] -4.7534243088 -0.44526322 -1.9929001 -0.734246388
[5,] -4.7534243088 -0.39974278 -1.8598866 -0.669851052
[6,] -4.7534243088 -0.39740710 -1.8528697 -0.667295070
[7,] -4.7534243088 -0.29486682 -1.6153036 -0.524480059
[8,] -4.7534243088 -0.26132821 -1.5557267 -0.472990008
[9,] -4.7534243088 -0.06639406 -1.2385783 -0.227165775
[10,] -1.5096802432  0.12311036 -0.9707350 -0.036436104
[11,] -1.4437679693  0.14546913 -0.9424371 -0.014738529
[12,] -1.3905185245  0.16521690 -0.9219843  0.008340591
[13,] -1.3673561100  0.17429831 -0.9139648  0.020148384
[14,] -0.8066066766  0.50543746 -0.5681577  0.325222742
[15,] -0.8052649273  0.50653956 -0.5672158  0.326234364
[16,] -0.7687188575  0.53726509 -0.5444216  0.357375004
[17,] -0.7022958446  0.59678631 -0.4882497  0.402803636
[18,] -0.4621277887  0.86115068 -0.2915373  0.612294916
[19,] -0.4175527593  0.92134449 -0.2476603  0.650684312
[20,] -0.3802808132  0.97530747 -0.2152770  0.688816579
[21,] -0.2917722727  1.12006986 -0.1320028  0.779544196
[22,] -0.2791954291  1.14297279 -0.1229178  0.795961168
[23,] -0.2764103047  1.14813752 -0.1210703  0.799788008
[24,]  0.0009783871  2.13988452  0.1648865  1.134805417
[25,]  0.0300189063  2.60465372  0.2022127  1.170068835
[26,]  0.0728609656  4.75342431  0.2384268  1.244247267
[27,]  0.1668087692  4.75342431  0.3518778  1.388881809
[28,]  0.4173932380  4.75342431  0.6557955  1.947930840
[29,]  0.4689486894  4.75342431  0.7850346  2.054477720
[30,]  0.6343901507  4.75342431  1.0646293  2.994543317

\$err
sim   pw
TRUE TRUE

\$crit
sim.left sim.right     pw.left  pw.right
[1,] 0.002829761  1.167843 -0.13239795  1.031253
[2,] 0.002829761  1.244282 -0.02675085  1.180006
[3,] 0.002829761  1.373429  0.12573038  1.395182
[4,] 0.562318021  1.773000  0.51780789  1.952375
[5,] 0.900164716  2.005224  0.72126107  2.244523
[6,] 0.935765182  2.033293  0.74513323  2.278966
[7,] 1.542847453  2.586107  1.19318682  2.932996
[8,] 1.991440596  3.061456  1.55319621  3.471079
[9,] 2.094330489  3.176871  1.63771387  3.599343
[10,] 2.286327136  3.398231  1.79685128  3.843096
[11,] 2.346364187  3.469038  1.84694682  3.920469
[12,] 2.694201005  3.894367  2.13973924  4.379443
[13,] 2.802469213  4.032187  2.23163130  4.526068
[14,] 2.861868270  4.108950  2.28217717  4.607289
[15,] 2.943299276  4.215553  2.35161283  4.719548
[16,] 3.436044656  4.897947  2.77480881  5.422794
[17,] 3.487317210  4.973087  2.81910915  5.498510
[18,] 3.667272540  5.244006  2.97494517  5.768431
[19,] 3.701009323  5.296125  3.00421917  5.819787
[20,] 4.376281055  6.453700  3.59377458  6.906086
[21,] 4.489147777  6.674926  3.69294766  7.100307
[22,] 4.789130352  7.320565  3.95734742  7.638493
[23,] 5.575719448  9.828704  4.65474454  9.255318
[24,] 5.795131263 11.120742  4.84922687  9.782448
[25,] 6.050327725 14.569816  5.07385743 10.457362
[26,] 6.226159724 33.376842  5.22648613 10.971783
[27,] 6.290504366 33.376842  5.28161545 11.172349
[28,] 6.745131999 33.376842  5.64744587 12.855166
[29,] 6.745589567 33.376842  5.64777896 12.857169
[30,] 7.333415021 33.376842  5.86720134 16.531295

\$err
sim   pw
TRUE TRUE

\$crit
sim.left sim.right   pw.left  pw.right
[1,] 0.002829761  2.099676 0.2156880  1.410666
[2,] 0.002829761  2.117038 0.2156880  1.410666
[3,] 0.002829761  2.127346 0.2156880  1.410666
[4,] 0.002829761  2.305405 0.3928674  1.690914
[5,] 0.002829761  2.502770 0.5574596  1.938538
[6,] 0.002829761  2.519306 0.5574596  1.938538
[7,] 0.002829761  2.684331 0.7135654  2.169473
[8,] 0.002829761  3.148371 1.0115330  2.607870
[9,] 0.613042787  3.498045 1.3019176  3.037344
[10,] 0.802256470  3.654912 1.4471670  3.254050
[11,] 0.907891809  3.756246 1.4471670  3.254050
[12,] 0.995508073  3.847422 1.4471670  3.254050
[13,] 1.339060803  4.265330 1.7421406  3.699448
[14,] 1.725257002  4.853175 2.0482846  4.170994
[15,] 2.030095885  5.420620 2.3720386  4.682284
[16,] 2.358419592  6.171143 2.7209896  5.250935
[17,] 2.527059417  6.636850 2.9079005  5.564306
[18,] 2.898267334  8.000380 3.3147278  6.271588
[19,] 2.909910170  8.054961 3.3147278  6.271588
[20,] 2.984944522  8.433768 3.3147278  6.271588
[21,] 3.172501515  9.691575 3.5391176  6.678941
[22,] 3.227836261 10.211030 3.5391176  6.678941
[23,] 3.300741340 11.107024 3.5391176  6.678941
[24,] 3.303345185 11.145667 3.5391176  6.678941
[25,] 3.364380523 12.282573 3.7815571  7.135376
[26,] 3.453339429 17.448753 3.7815571  7.135376
[27,] 3.532416907 33.376842 4.0463677  7.656423
[28,] 3.842265229 33.376842 4.3395390  8.265854
[29,] 3.974033929 33.376842 4.3395390  8.265854
[30,] 4.521228981 33.376842 5.5034154 11.218259

\$err
sim   pw
TRUE TRUE

distr documentation built on July 9, 2018, 3 a.m.