Ord_plot.RdOrd plots for diagnosing discrete distributions.
Ord_plot(obj, legend = TRUE, estimate = TRUE, tol = 0.1, type = NULL,
xlim = NULL, ylim = NULL, xlab = "Number of occurrences",
ylab = "Frequency ratio", main = "Ord plot", gp = gpar(cex = 0.5),
lwd = c(2,2), lty=c(2,1), col=c("black", "red"),
name = "Ord_plot", newpage = TRUE, pop = TRUE,
return_grob = FALSE, ...)
Ord_estimate(x, type = NULL, tol = 0.1)either a vector of counts, a 1-way table of frequencies of counts or a data frame or matrix with frequencies in the first column and the corresponding counts in the second column.
logical. Should a legend be plotted?.
logical. Should the distribution and its parameters be estimated from the data? See details.
tolerance for estimating the distribution. See details.
a character string indicating the distribution, must be
one of "poisson", "binomial", "nbinomial"
or "log-series" or NULL. In the latter case the
distribution is estimated from the data. See details.
limits for the x axis.
limits for the y axis.
a label for the x axis.
a label for the y axis.
a title for the plot.
a "gpar" object controlling the grid graphical
parameters of the points.
vectors of length 2, giving the line width and line type used for drawing the OLS line and the WLS lines.
vector of length 2 giving the colors used for drawing the OLS and WLS lines.
name of the plotting viewport.
logical. Should grid.newpage be called
before plotting?
logical. Should the viewport created be popped?
logical. Should a snapshot of the display be returned as a grid grob?
further arguments passed to grid.points.
a vector giving intercept and slope for the (fitted) line in the Ord plot.
The Ord plot plots the number of occurrences against a certain frequency ratio (see Friendly (2000) for details) and should give a straight line if the data comes from a poisson, binomial, negative binomial or log-series distribution. The intercept and slope of this straight line conveys information about the underlying distribution.
Ord_plot fits a usual OLS line (black) and a weighted OLS line
(red). From the coefficients of the latter the distribution is
estimated by Ord_estimate as described in Table 2.10 in
Friendly (2000). To judge whether a coefficient is positive or
negative a tolerance given by tol is used. If none of the
distributions fits well, no parameters are estimated. Be careful with
the conclusions from Ord_estimate as it implements just some
simple heuristics!
A vector giving the intercept and slope of the weighted OLS line.
J. K. Ord (1967), Graphical methods for a class of discrete distributions, Journal of the Royal Statistical Society, A 130, 232–238.
Michael Friendly (2000), Visualizing Categorical Data. SAS Institute, Cary, NC.
## Simulated data examples:
dummy <- rnbinom(1000, size = 1.5, prob = 0.8)
Ord_plot(dummy)
## Real data examples:
data("HorseKicks")
data("Federalist")
data("Butterfly")
data("WomenQueue")
if (FALSE) { # \dontrun{
grid.newpage()
pushViewport(viewport(layout = grid.layout(2, 2)))
pushViewport(viewport(layout.pos.col=1, layout.pos.row=1))
Ord_plot(HorseKicks, main = "Death by horse kicks", newpage = FALSE)
popViewport()
pushViewport(viewport(layout.pos.col=1, layout.pos.row=2))
Ord_plot(Federalist, main = "Instances of 'may' in Federalist papers", newpage = FALSE)
popViewport()
pushViewport(viewport(layout.pos.col=2, layout.pos.row=1))
Ord_plot(Butterfly, main = "Butterfly species collected in Malaya", newpage = FALSE)
popViewport()
pushViewport(viewport(layout.pos.col=2, layout.pos.row=2))
Ord_plot(WomenQueue, main = "Women in queues of length 10", newpage = FALSE)
popViewport(2)
} # }
## same
mplot(
Ord_plot(HorseKicks, return_grob = TRUE, main = "Death by horse kicks"),
Ord_plot(Federalist, return_grob = TRUE, main = "Instances of 'may' in Federalist papers"),
Ord_plot(Butterfly, return_grob = TRUE, main = "Butterfly species collected in Malaya"),
Ord_plot(WomenQueue, return_grob = TRUE, main = "Women in queues of length 10")
)