ubeta: adapted draws of a Beta distribution

Description Usage Arguments Details Value Examples

Description

This function slightly generalizes the basic rbeta function, allowing translation and dilatation with support and truncation with trunc. Also the retained parameterization with expectation mu and coefficient of variation coefvar encompasses some degenerate cases.
When the intersection of support and trunc is empty, an error is issued.
The number of returned draws is max(length(mu),length(coefvar)). When both lengths are not equal, the smaller one must be equal to one, if not an error is issued.
NA value are possible in mu and coefvar, then missing values are returned for the considered draws.
Be aware that giving some of the mu either equal to support[1] or equal to support[2] will imply draws fixed to this value if it belongs to the truncation interval (NA otherwise). So an extreme value for mu means that it is sure, not compensated by coefvar. We advise not to introduce such degenerate cases.

Usage

1
ubeta(mu, coefvar, support=c(0, 1), trunc=support)

Arguments

mu

numeric vector of the expectation of the beta, must be in the interval defined by support.

coefvar

numeric vector of the coefficient of variation. Must be comprised between 0 and 100.

support

The two limits of the interval for which the beta is defined (equivalent to a translation and dilatation). The support interval is common for all draws.

trunc

The two limits to which distribution is truncated. The truncation interval is common for all draws. In fact, it is computed as the intersection with support which cannot be empty.

Details

The proposed parameterization is given by the following relationships with the standard a and b parameters when support=c(0,1).
mu = a / (a+b) and coefvar = 200 / (a+b),
a = 200 * (mu / coefvar) and b = 200 * ((1-mu)/coefvar).
When mu is equal to support[1] or support[2], this is a degenerate case considered as fixed with coefvar is null whatever is the provided value.

Value

A vector of the drawn values, possibly containing NA.

Examples

1
2
3
4
 prr3k("RESET"); # For R checking compliance
 ubeta(rep(0.8, 20), 2);
 ubeta(c(rep(0.8, 19), NA), 2, support=c(-10, 20));
 ubeta(c(rep(0.8, 19), NA), 100*runif(20), support=c(-10, 10), trunc=c(0.5, 1.5));

prr documentation built on May 2, 2019, 6:35 p.m.

Related to ubeta in prr...