R/dllogistic.R

#' @title The L-Logistic Distribution
#' @name llogistic
#' @description Density, distribution function,
#' quantile function and random generation for
#' the L-Logistic distribution with parameters m and phi.
#' @param x,q vector of quantiles.
#' @param p vector of probabilities.
#' @param n number of observations.
#' @param m,phi  parameters of the L-Logistic distribution.
#'  The parameter m lies in the interval (0,1) and phi is positive.
#' @param log,log.p logical; if TRUE, probabilities p are given as log(p).
#' @return dllogistic(x,m,phi) gives the density function,
#'  rllogistic(n,m,phi) gives n random variates and qllogistic(p,m,phi) gives the quantile.
#' @param lower.tail logical; if TRUE (default), probabilities are \eqn{P[X \leq x ]}, otherwise, P[X > x].
#' @source The L-Losgistic distribution was introduced by Tadikamalla and Johnson (1982), which refer to this distribution as Logit-Logistic
#' distribution. Here, we have a new parameterization of the Logit-Logistic with the median as a parameter.

#' @importFrom stats runif
#' @references Paz, R.F., Balakrishnan, N and  Bazán, Jorge L. (2016). L-Logistic Distribution: Properties, Inference and an Application to Study Poverty and Inequality  in Brazil.
#' São Carlos: Universidade Federal de São Carlos. Tecnical-Scientific Report No. 261, Teory and Method. Sponsored by the Department of Statistical, <URL:\url{http://www.pipges.ufscar.br/publicacoes/relatorios-tecnicos/arquivos-1/rt261.pdf}>.
#' @references TADIKAMALLA, P. R.; JOHNSON, N. L. (1982). Systems of frequency curves generated by transformations
#' of logistic variables. Biometrika, v. 69, n. 2, p. 461.
#' @details The llogistic distribution has density
#'
#'  \eqn{f(x)=phi (1 - m)^phi m^phi (x(1 - x))^(phi - 1)/((1 - m)^phi x^phi + m^phi (1 - x)^phi)^2},
#'
#'  for 0< x < 1, where m is a median of the distribution and phi is a shape parameter.
#' @examples
#' dllogistic(0.3, 0.5, 2)
#' @export
dllogistic = function(x, m, phi, log = FALSE) {
  if (log == TRUE) {
    d = log(phi) + phi * log(1 - m) + phi * log(m) + (phi - 1) * log(1 - x) + (phi - 1) * log(x) -
      2 * log(((1 - m)^phi * x^phi + m^phi * (1 - x)^phi))
  } else {
    d = (phi * (1 - m)^phi * m^phi * (x * (1 - x))^(phi - 1))/(((1 - m)^phi * x^phi + m^phi * (1 - x)^phi)^2)
  }
  return(d)
}

Try the llogistic package in your browser

Any scripts or data that you put into this service are public.

llogistic documentation built on May 2, 2019, 6:52 a.m.