powered by
Create a hanging rootogram for a quantitative numeric vector and compare it to a Gaussian distribution.
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, ... )
a numeric vector of values for which the rootogram is desired
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.
if "hanging" then a hanging rootogram is plotted, and if "deviation" then deviations from zero are plotted.
"hanging"
"deviation"
The type of transformation. Defaults to "sqrt" which takes square roots of the frequencies. "raw" yields untransformed frequencies.
"sqrt"
"raw"
logical; if TRUE a horizontal line is added at zero.
TRUE
The color of the density line for the normal distribution. The default is to make a red density line.
red
a colour to be used to fill the bars. The default of lightgray yields lightgray bars.
lightgray
plot labels. The xlab and ylab refer to the x and y axes respectively
xlab
ylab
Should y axis text be printed. Defaults to n.
n
the range of y values with sensible defaults.
the mean of the Gaussian distribution. Defaults to the sample mean of x.
x
the standard deivation of the Gaussian distribution. Defaults to the sample std.dev. of x.
The distance between the rectangles in the histogram.
further arguments and graphical parameters passed to plot.
plot
Returns a vector of counts of each bar. This may be changed in the future. The plot is the primary output of the function.
The mean and standard deviation of the Gaussian distribution are calculated from the observed data unless the mu and s arguments are given.
mu
s
Tukey, J. W. 1972. Some Graphic and Semigraphic Displays. In Statistical Papers in Honor of George W. Snedecor, p. 293-316.
# NOT RUN { 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) # }
Run the code above in your browser using DataLab