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.
# S3 method for 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")
An object of class "mleBb"
as returned by the function
mleBb()
Not used.
Logical scalar; should a plot be produced (or should the function simply return a data frame consisting of the relevant values)?
The colour for the (vertical) lines corresponding to the “fitted” probabilities, i.e. the probabilities calculated from the fitted parameters.
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 obsd
is not supplied.
(Optional) vector of locations of the tick marks on the x
-axis.
A numeric vector of length 2 specifying the limits
of the x
-axis. Defaults to c(0,size)
Note that
\ codesize is extracted from argument x
.
A numeric vector of length 2 specifying the limits
of the y
-axis. There is a “sensible” default.
A label for the \(x\)-axis; defaults to x
.
A label for the \(y\)-axis; defaults to probability
.
The data set from which the parameters were estimated, i.e. from
which x
was obtained. (Optional.)
Numeric scalar; defaults to 0.1 if size
(extracted from
x
) is less than 20 and to 0.5 otherwise. This number should
be non-zero and less than 1 in absolute value. (One would usually
want it to be positive, but it could conceiveably be set to a
small negative value.) It gives the value of the “increment”
or “shift” that separates the vertical lines representing
the fitted probabilities and those representing the observed
proportions (calculated from obsd
). Ignored if obsd
is not supplied.
A main title for the plot; defaults to the empty string.
A list with components x
and y
, or a text string,
specifying the placement of the legend. See legend()
for details. A legend is plotted only if obsd
is
specified, whence legPos
is otherwise ignored. The plotting
of a legend may be suppressed (even when obsd
is supplied)
by setting legPos=NULL
.
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
.
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.
# NOT RUN {
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")
# }
Run the code above in your browser using DataLab