Class and methods for beta distributions in regression specification using the workflow from the distributions3 package.
BetaR(mu, phi)
Arguments
mu: numeric. The mean of the beta distribution.
phi: numeric. The precision parameter of the beta distribution.
Details
Alternative parameterization of the classic beta distribution in terms of its mean mu and precision parameter phi. Thus, the distribution provided by BetaR is equivalent to the Beta distribution with parameters alpha = mu * phi and beta = (1 - mu) * phi.
Returns
A BetaR distribution object.
See Also
dbetar, Beta
Examples
## package and random seedlibrary("distributions3")set.seed(6020)## three beta distributionsX <- BetaR( mu = c(0.25,0.50,0.75), phi = c(1,1,2))
X
## compute moments of the distributionmean(X)variance(X)skewness(X)kurtosis(X)## support interval (minimum and maximum)support(X)## simulate random variablesrandom(X,5)## histograms of 1,000 simulated observationsx <- random(X,1000)hist(x[1,])hist(x[2,])hist(x[3,])## probability density function (PDF) and log-density (or log-likelihood)x <- c(0.25,0.5,0.75)pdf(X, x)pdf(X, x, log =TRUE)log_pdf(X, x)## cumulative distribution function (CDF)cdf(X, x)## quantilesquantile(X,0.5)## cdf() and quantile() are inverses (except at censoring points)cdf(X, quantile(X,0.5))quantile(X, cdf(X,1))## all methods above can either be applied elementwise or for## all combinations of X and x, if length(X) = length(x),## also the result can be assured to be a matrix via drop = FALSEp <- c(0.05,0.5,0.95)quantile(X, p, elementwise =FALSE)quantile(X, p, elementwise =TRUE)quantile(X, p, elementwise =TRUE, drop =FALSE)## compare theoretical and empirical mean from 1,000 simulated observationscbind("theoretical"= mean(X),"empirical"= rowMeans(random(X,1000)))