# DISTPLOTS: Empirical distribution plots In nsRFA: Non-Supervised Regional Frequency Analysis

## Description

Sample values are plotted against their empirical distribution in graphs where points belonging to a particular distribution should lie on a straight line.

## Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36``` ``` plotpos (x, a=0, orient="xF", ...) plotposRP (x, a=0, orient="xF", ...) loglogplot (x, a=0, orient="xF", ...) unifplot (x, a=0, orient="xF", line=FALSE, ...) normplot (x, a=0, orient="xF", line=FALSE, ...) lognormplot (x, a=0, orient="xF", line=FALSE, ...) studentplot (x, df, a=0, orient="xF", line=FALSE,...) logisplot (x, a=0, orient="xF", line=FALSE,...) gammaplot (x, shape, a=0, orient="xF", line=FALSE,...) expplot (x, a=0, orient="xF", line=FALSE,...) paretoplot (x, a=0, orient="xF", line=FALSE,...) gumbelplot (x, a=0, orient="xF", line=FALSE, ...) frechetplot (x, a=0, orient="xF", line=FALSE,...) weibullplot (x, a=0, orient="xF", line=FALSE,...) plotposRPhist (xcont, xhist=NA, infhist=NA, suphist=NA, nbans=NA, seuil=NA, col12=c(1,1), a=0, orient="xF", ...) pointspos (x, a=0, orient="xF", ...) pointsposRP (x, a=0, orient="xF", ...) loglogpoints (x, a=0, orient="xF", ...) unifpoints (x, a=0, orient="xF", ...) normpoints (x, a=0, orient="xF", ...) studentpoints (x, df, a=0, orient="xF", ...) logispoints (x, a=0, orient="xF", ...) gammapoints (x, shape, a=0, orient="xF", ...) exppoints (x, a=0, orient="xF", ...) gumbelpoints (x, a=0, orient="xF", ...) weibullpoints (x, a=0, orient="xF", ...) regionalplotpos (x, cod, a=0, orient="xF", ...) regionalnormplot (x, cod, a=0, orient="xF", ...) regionallognormplot (x, cod, a=0, orient="xF", ...) regionalexpplot (x, cod, a=0, orient="xF", ...) regionalparetoplot (x, cod, a=0, orient="xF", ...) regionalgumbelplot (x, cod, a=0, orient="xF", ...) regionalfrechetplot (x, cod, a=0, orient="xF", ...) pointsposRPhist (xcont, xhist=NA, infhist=NA, suphist=NA, nbans=NA, seuil=NA, col12=c(1,1), a=0, orient="xF", ...) ```

## Arguments

 `x` vector representing a data-sample `xcont` vector of systematic data (see `BayesianMCMC`) `xhist` vector of historical data (see `BayesianMCMC`) `infhist` inferior limit for historical data (see `BayesianMCMC`) `suphist` superior limit for historical data (see `BayesianMCMC`) `nbans` period (in years) over which the threshold has not been exceeded except for the historical data (see `BayesianMCMC`) `seuil` threshold non exceeded in the historical period except for the historical data (see `BayesianMCMC`) `df` degrees of freedom (> 0, maybe non-integer) of the Student t distribution. 'df = Inf' is allowed. `shape` shape parameter of the distribution `a` plotting position parameter, normally between 0 and 0.5 (the default value here, corresponding to the Hazen plotting position, see details) `orient` if `orient="xF"` the abscissa will be x and the ordinate F `line` if TRUE (default) a straight line indicating the normal, lognormal, ..., distribution with parameters estimated from `x` is plotted `cod` array that defines the data subdivision among sites `col12` vector of 2 elements containing the colors for the systematic and historical data respectively `...` graphical parameters as `xlab`, `ylab`, `main`, ...

## Details

A brief introduction on Probability Plots (or Quantile-Quantile plots) is available on http://en.wikipedia.org/wiki/Q-Q_plot. For plotting positions see http://en.wikipedia.org/wiki/Plotting_position.

For the quantiles of the comparison distribution typically the Weibull formula k/(n + 1) is used (default here). Several different formulas have been used or proposed as symmetrical plotting positions. Such formulas have the form

(k - a)/(n + 1 - 2a)

for some value of a in the range from 0 to 1/2. The above expression k/(n+1) is one example of these, for a=0. The Filliben plotting position has a = 0.3175 and the Cunanne plotting position has a = 0.4 should be nearly quantile-unbiased for a range of distributions. The Hazen plotting position, widely used by engineers, has a = 0.5. The Blom's plotting position, a = 3/8, gives nearly unbiased quantiles for the normal distribution, while the Gringeton plotting position, a = 0.44, is optimized for the largest observations from a Gumbel distribution. For the generalized Pareto, the GEV and related distributions of the Type I (Gumbel) and Weibull, a = 0.35 is suggested.

For large sample size, n, there is little difference between these various expressions.

## Value

Representation of the values of `x` vs their empirical probability function F in a cartesian, uniform, normal, lognormal or Gumbel plot. `plotpos` and `unifplot` are analogous except for the axis notation, `unifplot` has the same notation as `normplot`, `lognormplot`, ... `plotposRP` is analogous to `plotpos` but the frequencies F are expressed as Return Periods T=1/(1-F). With the default settings, F is defined with the Weibull plotting position F=k/(n+1). The straight line (if `line`=TRUE) indicate the uniform, normal, lognormal or Gumbel distribution with parameters estimated from `x`. The regional plots draw samples of a region on the same plot.

`pointspos`, `normpoints`, ... are the analogous of `points`, they can be used to add points or lines to `plotpos`, `normplot`, ... `normpoints` can be used either on `normplot` or `lognormplot`. `exppoints` can be used either on `expplot` or `paretoplot` (since the log-transformed Pareto random variable is exponentially distributed). `gumbelpoints` can be used either on `gumbelplot` or `frechetplot` (since the log-transformed Frechet random variable is distributed as a Gumbel).

`loglogplot` plots the logarithm of sample vs the logarithm of the empirical exceedance probability. For the log-log plot, the tail probability is represented by a straight line for power-law distributions (e.g. log-pearson, log-logistic, Frechet, ..., HEAVY TAIL), but not for the other subexponential or exponential distributions (e.g. gumbel, gamma, Pearson type III, ..., MODERATE TAIL); see El Adlouni et al. (2008).

`plotposRPhist` is based on the method in Stedinger et al. (1993, pp. 18.41-42).

## Note

For information on the package and the Author, and for all the references, see `nsRFA`.

These functons are analogous to `qqnorm`; for the distributions, see `Normal`, `Lognormal`, `LOGNORM`, `GUMBEL`.
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57``` ```x <- rnorm(30,10,2) plotpos(x) normplot(x) normplot(x,xlab=expression(D[m]),ylab=expression(hat(F)), main="Normal plot",cex.main=1,font.main=1) normplot(x,line=FALSE) x <- rlnorm(30,log(100),log(10)) normplot(x) lognormplot(x) x <- rand.gumb(30,1000,100) normplot(x) gumbelplot(x) x <- rnorm(30,10,2) y <- rnorm(50,10,3) z <- c(x,y) codz <- c(rep(1,30),rep(2,50)) regionalplotpos(z,codz) regionalnormplot(z,codz,xlab="z") regionallognormplot(z,codz) regionalgumbelplot(z,codz) plotpos(x) pointspos(y,pch=2,col=2) x <- rnorm(50,10,2) F <- seq(0.01,0.99,by=0.01) qq <- qnorm(F,10,2) plotpos(x) pointspos(qq,type="l") normplot(x,line=FALSE) normpoints(x,type="l",lty=2,col=3) lognormplot(x) normpoints(x,type="l",lty=2,col=3) gumbelplot(x) gumbelpoints(x,type="l",lty=2,col=3) # distributions comparison in probabilistic graphs x <- rnorm(50,10,2) F <- seq(0.001,0.999,by=0.001) loglikelhood <- function(param) {-sum(dgamma(x, shape=param[1], scale=param[2], log=TRUE))} parameters <- optim(c(1,1),loglikelhood)\$par qq <- qgamma(F,shape=parameters[1],scale=parameters[2]) plotpos(x) pointspos(qq,type="l") normplot(x,line=FALSE) normpoints(qq,type="l") lognormplot(x,line=FALSE) normpoints(qq,type="l") ```