Learn R Programming

FlexReg (version 1.2)

curve.density: Draw density plots

Description

The function draws a curve corresponding to the probability density/mass function of the specified distribution (beta, flexible beta, variance-inflated beta, binomial, beta-binomial, or flexible beta-binomial). For beta, flexible beta, and variance-inflated beta, it also allows to plot the probability of augmentation in zero/one.

Usage

curve.density(
  type = NULL,
  size = NULL,
  mu = NULL,
  theta = NULL,
  phi = NULL,
  p = NULL,
  w = NULL,
  k = NULL,
  q0 = NULL,
  q1 = NULL,
  ...
)

Arguments

type

a character specifying the distribution type to be plotted ("Beta", "FB", "VIB", "Bin", "BetaBin", or "FBB").

size

the total number of trials (to be specified if type is "Bin", "BetaBin", or "FBB").

mu

the mean parameter of the distribution. It must lie in (0, 1).

theta

the overdispersion parameter (to be specified if type is "BetaBin" or "FBB"). It must lie in (0, 1).

phi

the precision parameter (an alternative way to specify the theta parameter if type is "BetaBin" or "FBB"). It must be a positive real value.

p

the mixing weight (to be specified if type is "FB" or "VIB"). It must lie in (0, 1).

w

the normalized distance among clusters of the FB distribution (to be specified if type = "FB"). It must lie in (0, 1).

k

the extent of the variance inflation (to be specified if type = "VIB"). It must lie in (0, 1).

q0

the probability of augmentation in zero (it can be specified only if type is "Beta", "FB", or "VIB"). It must lie in (0, 1). In case of no augmentation is NULL (default).

q1

the probability of augmentation in one (it can be specified only if type is "Beta", "FB", or "VIB"). It must lie in (0, 1). In case of no augmentation is NULL (default).

...

additional arguments of stat_function().

References

Ascari, R., Migliorati, S. (2021). A new regression model for overdispersed binomial data accounting for outliers and an excess of zeros. Statistics in Medicine, 40(17), 3895--3914. doi:10.1002/sim.9005

Di Brisco, A. M., Migliorati, S. (2020). A new mixed-effects mixture model for constrained longitudinal data. Statistics in Medicine, 39(2), 129--145. doi:10.1002/sim.8406

Di Brisco, A. M., Migliorati, S., Ongaro, A. (2020). Robustness against outliers: A new variance inflated regression model for proportions. Statistical Modelling, 20(3), 274--309. doi:10.1177/1471082X18821213

Ferrari, S.L.P., and Cribari-Neto, F. (2004). Beta Regression for Modeling Rates and Proportions. Journal of Applied Statistics, 31(7), 799--815. doi:10.1080/0266476042000214501

Migliorati, S., Di Brisco, A. M., Ongaro, A. (2018). A New Regression Model for Bounded Responses. Bayesian Analysis, 13(3), 845--872. doi:10.1214/17-BA1079

Examples

Run this code
curve.density("Beta", mu=.5, phi=20)
curve.density("Beta", mu=.5, phi=20, q1 = .3)
curve.density("FB", mu=.5, phi=20, p=.4, w=.8)
curve.density("FB", mu=.5, phi=20, p=.4, w=.8, q0= .1)
curve.density("VIB", mu=.5, phi=20, p=.9, k=.8, col=3)
curve.density("VIB", mu=.5, phi=20, p=.9, k=.8, col=3, q0=.1, q1=.3)

curve.density("Bin", size=10, mu=.7)
curve.density("BetaBin", size=10, mu=.7, phi=10)
curve.density("FBB", size=10, mu=.7, phi=10, p=.2,w=.7)


Run the code above in your browser using DataLab