Creates a plot of type "h"
of the probabilities of
each possible x
value of a db distribution where
the probabilities are calculated on the basis of parameters
estimated by the function mleDb()
. If obsd
is supplied it also superimposes/juxtaposes vertical lines
representing the observed proportions.
# S3 method for mleDb
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 "mleDb"
as returned by the function
mleDb()
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(nbot,ntop)
where
nbot
is 0 if x[["zeta"]]
is TRUE
(i.e.
zero origin indexing is uses) and is 1 otherwise. Note that
ntop
and zeta
are 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 ntop
(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 ntop
or from 1 to ntop
depending on whether
zeta
is TRUE
. The p
column consists of
the appropriate probabilities of the x
values, calculated
by link{ddb}()
. 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 <- mleDb(xxx,ntop=14,z=TRUE)
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 <- mleDb(yyy,ntop=10,z=TRUE)
plot(fit,obsd=yyy,legPos="topleft")
# }
Run the code above in your browser using DataLab