Learn R Programming

HelpersMG (version 5.1)

dbeta_new: Density for the Beta distributions.

Description

Density for the Beta distribution with parameters mu and v or shape1 and shape2 (and optional non-centrality parameter ncp). The returned object has three attributes: shape1, shape2, and ncp Note that if x has attributes, they are preserved.

Usage

dbeta_new(
  x,
  mu = NULL,
  v = NULL,
  shape1,
  shape2,
  ncp = 0,
  log = FALSE,
  silent = FALSE
)

Arguments

x

vector of quantiles.

mu

mean of the Beta distribution.

v

variance of the Beta distribution.

shape1

non-negative parameters of the Beta distribution.

shape2

non-negative parameters of the Beta distribution.

ncp

non-centrality parameter.

log

logical; if TRUE, probabilities p are given as log(p).

silent

If FALSE, show the shape1 and shape 2 values.

Value

dbeta_new gives the density for the Beta distributions

Details

dbeta_new returns the density for the Beta distributions

The Beta distribution with parameters shape1 = a and shape2 = b has density gamma(a+b)/(gamma(a)gamma(b))x^(a-1)(1-x)^(b-1) for a > 0, b > 0 and 0 <= x <= 1 where the boundary values at x=0 or x=1 are defined as by continuity (as limits). The mean is a/(a+b) and the variance is ab/((a+b)^2 (a+b+1)). These moments and all distributional properties can be defined as limits.

See Also

Other Distributions: cutter(), dcutter(), dggamma(), logLik.cutter(), plot.cutter(), print.cutter(), rcutter()

Examples

Run this code
# NOT RUN {
pi <- rbeta(100, shape1=0.48, shape2=0.12)
hist(pi, freq=FALSE, breaks=seq(from=0, to=1, by=0.1), ylim=c(0, 8), las=1)
library("HelpersMG")
mx <- ScalePreviousPlot()$ylim["end"]/
      max(dbeta_new(seq(from=0.01, to=0.99, by=0.01), mu = 0.8, v=0.1))
curve(dbeta_new(x, mu = 0.8, v=0.1)*mx, add=TRUE, col="red")
out <- dbeta_new(0.1, mu = 0.8, v=0.1)
out
attributes(out)$shape1; attributes(out)$shape2; attributes(out)$ncp
dbeta(0.1, shape1=attributes(out)$shape1, shape2=attributes(out)$shape2, 
      ncp=attributes(out)$ncp)

# It can be used to generate random numbers using mu and v
out <- dbeta_new(0.1, mu = 0.8, v=0.1, silent=TRUE)
pi <- rbeta(100, shape1=attributes(out)$shape1, shape2=attributes(out)$shape2, 
      ncp=attributes(out)$ncp)
hist(pi, freq=FALSE, breaks=seq(from=0, to=1, by=0.1), ylim=c(0, 8), las=1)
# }

Run the code above in your browser using DataLab