plot.mleBb {dbd} | R Documentation |
Plot a maxium likelihood fit to data from a beta binomial distribution.
Description
Creates a plot of type "h"
of the probabilities of each
possible x
value of a beta binomial distribution where
the probabilities are calculated on the basis of parameters
estimated by the function mleBb()
. If obsd
is supplied it also superimposes/juxtaposes vertical lines
representing the observed proportions.
Usage
## S3 method for class 'mleBb'
plot(x, ..., plot = TRUE, col.fit = "red", col.obsd = "blue",
tikx = NULL, xlim=NULL, ylim=NULL, xlab = NULL,
ylab = NULL, obsd = NULL, incr = NULL,
main = "", legPos = "topright")
Arguments
x |
An object of class |
... |
Not used. |
plot |
Logical scalar; should a plot be produced (or should the function simply return a data frame consisting of the relevant values)? |
col.fit |
The colour for the (vertical) lines corresponding to the “fitted” probabilities, i.e. the probabilities calculated from the fitted parameters. |
col.obsd |
The colour for the (vertical) lines corresponding to the
“observed” probabilities (proportions), i.e. the
probabilities calculated by tabulating the data (from which the
parameters were estimated. Ignored if |
tikx |
(Optional) vector of locations of the tick marks on the |
xlim |
A numeric vector of length 2 specifying the limits
of the |
ylim |
A numeric vector of length 2 specifying the limits
of the |
xlab |
A label for the |
ylab |
A label for the |
obsd |
The data set from which the parameters were estimated, i.e. from
which |
incr |
Numeric scalar; defaults to 0.1 if |
main |
A main title for the plot; defaults to the empty string. |
legPos |
A list with components |
Value
A data frame with numeric columns x
, p
and
possibly po
. The x
column consists of the integers
from 0 to size
. The p
column consists of the
appropriate probabilities of the x
values, calculated by
dbetabinom()
from the rmutil
package. The po
column is present only if obsd
is supplied and consists
of the observed proportions. The value is returned invisibly.
A plot is produced as a side-effect if plot
is TRUE
.
Note
This function calls plotBb()
to do the heavy lifting.
Warning
It is up to the user to make sure that the obsd
argument,
if specified, is indeed the data set from which the object x
was calculated.
Author(s)
Rolf Turner r.turner@auckland.ac.nz
See Also
Examples
if(require(hmm.discnp)) {
xxx <- hmm.discnp::Downloads
fit <- mleBb(xxx,size=14)
plot(fit)
plot(fit,obsd=xxx)
plot(fit,obsd=xxx,legPos=list(x=3,y=0.25))
plot(fit,obsd=xxx,legPos=NULL) # No legend is plotted.
}
set.seed(42)
yyy <- rbinom(300,10,0.7)
fit <- mleBb(yyy,size=10)
plot(fit,obsd=yyy,legPos="topleft")