Plot the revisability of an object of class "prova_pr" (probability) as a histogram
Source:R/display.R
hist.prova_pr.RdThe posterior probabilities calculated with the Pr() function, and outputted as a "prova_pr" (probability) object, have an associated "revisability" that comes from the finite size of the data sample. This revisability can be interpreted in two ways:
How the probabilities could change, if we collected a much larger (infinite) data sample, and how likely would such change be;
The relative frequency of a particular variate value in the full (sampled and unsampled) population is unknown; we can quantify our uncertainty about this relative frequency with a probability distribution.
The hist() method for a "prova_pr" (probability) object is a utility to visualize this kind of revisability, in the form of a distribution. This distribution is represented by a histogram formed from samples of revised proobabilities (or long-run frequencies). The bin size is chosen according to the Monte Carlo accuracy.
Arguments
- x
Object of class "prova_pr" (probability), obtained with
Pr().- breaks
as in function
graphics::hist(), orNULL(default). ValueNULLdetermines bin width from the Monte Carlo accuracy (roughly speaking, each bin spans two standard deviations).- legend
One of the values
'bottomright','bottom','bottomleft','left','topleft','top','topright','right','center'(seegraphics::legend()): plot a legend at that position. ValueFALSEorNAdoes not plot any legend. Default'topright'.- lty, lwd, col, alpha.f, xlab, ylab, xlim, ylim, main, grid, axes, add
see analogous arguments in
graphics::matplot()- alpha.f.fill
Numeric, default
0.125: opacity of the histogram filling,0being completely invisible and1completely opaque.- showmean
Logical, default
TRUE: show the means of the probability distributions? The means correspond to the probabilities about the next observed unit.- ...
Other parameters to be passed to
pplot().
Value
Invisibly, an object of class "histogram".
See also
Pr() to calculate posterior probabilities and quantiles.
plot.prova_pr() to plot the posterior probabilities.
pplot() (on which hist.prova_pr() is based) for more general plots.
Examples
## Use the "K" object 'Kexample',
## calculated from the "penguins" dataset;
## variates: 'species' and 'bill_len'
## calculate the probability, and its revisability,
## for the value 'Adelie' of the "species" variate
probs <- Pr(data.frame(species = 'Adelie'), NULL, Kexample)
probs$value
#>
#> species
#> Adelie 0.4402005
## show the revisability of this probability; equivalently show
## the probability distribution for the relative frequency of
## 'Adelie' penguins in the full population
hist(probs, legend = 'topright')