Last data update: 2014.03.03

R: Hanging rootogram for normal distribution
rootonormR Documentation

Hanging rootogram for normal distribution

Description

Create a hanging rootogram for a quantitative numeric vector and compare it to a Gaussian distribution.

Usage

rootonorm(x, breaks = "Sturges", type = c("hanging", "deviation"),
  scale = c("sqrt", "raw"), zeroline = TRUE, linecol = "red",
  rectcol = "lightgrey", xlab = xname, ylab = "Sqrt(frequency)",
  yaxt = "n", ylim = NULL, mu = mean(x), s = sd(x), gap = 0.1, ...)

Arguments

x

a numeric vector of values for which the rootogram is desired

breaks

Either the character string ‘Sturges’ to use Sturges' algorithm to decide the number of breaks or a positive integer that sets the number of breaks.

type

if "hanging" then a hanging rootogram is plotted, and if "deviation" then deviations from zero are plotted.

scale

The type of transformation. Defaults to "sqrt" which takes square roots of the frequencies. "raw" yields untransformed frequencies.

zeroline

logical; if TRUE a horizontal line is added at zero.

linecol

The color of the density line for the normal distribution. The default is to make a red density line.

rectcol

a colour to be used to fill the bars. The default of lightgray yields lightgray bars.

xlab, ylab

plot labels. The xlab and ylab refer to the x and y axes respectively

yaxt

Should y axis text be printed. Defaults to n.

ylim

the range of y values with sensible defaults.

mu

the mean of the Gaussian distribution. Defaults to the sample mean of x.

s

the standard deivation of the Gaussian distribution. Defaults to the sample std.dev. of x.

gap

The distance between the rectangles in the histogram.

...

further arguments and graphical parameters passed to plot.

Details

The mean and standard deviation of the Gaussian distribution are calculated from the observed data unless the mu and s arguments are given.

Value

Returns a vector of counts of each bar. This may be changed in the future. The plot is the primary output of the function.

Author(s)

Claus Ekstrom claus@rprimer.dk

References

Tukey, J. W. 1972. Some Graphic and Semigraphic Displays. In Statistical Papers in Honor of George W. Snedecor, p. 293-316.

Examples


oldpar <- par()
par(mfrow=c(2,2))
rootonorm(rnorm(200))
rootonorm(rnorm(200), type="deviation", scale="raw")
rootonorm(rnorm(200), mu=1)
rootonorm(rexp(200), mu=1)
par(oldpar)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MESS)
Loading required package: geepack

Attaching package: 'MESS'

The following object is masked from 'package:stats':

    power.t.test

> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MESS/rootonorm.Rd_%03d_medium.png", width=480, height=480)
> ### Name: rootonorm
> ### Title: Hanging rootogram for normal distribution
> ### Aliases: rootogram rootonorm
> ### Keywords: hplot
> 
> ### ** Examples
> 
> 
> oldpar <- par()
> par(mfrow=c(2,2))
> rootonorm(rnorm(200))
> rootonorm(rnorm(200), type="deviation", scale="raw")
> rootonorm(rnorm(200), mu=1)
> rootonorm(rexp(200), mu=1)
> par(oldpar)
Warning messages:
1: In par(oldpar) : graphical parameter "cin" cannot be set
2: In par(oldpar) : graphical parameter "cra" cannot be set
3: In par(oldpar) : graphical parameter "csi" cannot be set
4: In par(oldpar) : graphical parameter "cxy" cannot be set
5: In par(oldpar) : graphical parameter "din" cannot be set
6: In par(oldpar) : graphical parameter "page" cannot be set
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>