Learn R Programming

nsRFA (version 0.5-8)

DISTPLOTS: Distribution plots

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

plotpos (x, ...)
 unifplot (x, line=TRUE, ...)
 normplot (x, line=TRUE, ...)
 lognormplot (x, line=TRUE, ...)
 gumbelplot (x, line=TRUE, ...)
 pointspos (x, ...)
 unifpoints (x, ...)
 normpoints (x, ...)
 gumbelpoints (x, ...)
 regionalplotpos (x, cod, ...)
 regionalnormplot (x, cod, ...)
 regionallognormplot (x, cod, ...)
 regionalgumbelplot (x, cod, ...)

Arguments

x
vector representing a data-sample
line
if TRUE (default) a straigth line indicating the normal, lognormal or Gumbel distribution with parameters estimated from x is plotted
cod
array that defines the data subdivision among sites
...
graphical parameters as xlab, ylab, main, ...

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, ... $F$ is defined with the plotting position $F=(n-0.5)/n$. The straigth 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 in normplot or lognormplot.

Details

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

See Also

These functons are analogous to qqnorm; for the distributions, see Normal, Lognormal, LOGNORM, GUMBEL.

Examples

Run this code
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")

Run the code above in your browser using DataLab