betaHPD(alpha,beta,p=.95,plot=FALSE)
TRUE
then plot the density and
show the HDRNAs
is returned. In general, a highest density region of $f(\theta)$ with content
$p \in [0,1]$ is a set of regions $\mathcal{Q}$ of the
parameter space with the following properties:
$$\int_\mathcal{Q} f(\theta) d\theta = p$$
and
$$f(\theta) > f(\theta^*) \, \forall\
\theta \in \mathcal{Q},
\theta^* \not\in \mathcal{Q}$$
For a continuous, unimodal density defined with respect to a single
parameter (like the Beta case considered here), a HDR region is a
contiguous interval in $[0,1]$.
This function uses numerical methods are used to solve for the
boundaries of a HDR region for the Beta density, via repeated calls
the functions dbeta
, pbeta
and
qbeta
. The function uniroot
is used to
find points $v$ and $w$ such that $$f(v) = f(w)$$ subject
to the constraint $$\int_v^w f(\theta; \alpha, \beta) d\theta = p$$
pbeta
, qbeta
,
dbeta
, uniroot