Nothing
#' Logit-Normal distribution maximum likelihood estimation
#'
#' The maximum likelihood estimate of `mu` is the empirical mean of the
#' logit transformed data and the maximum likelihood estimate of
#' `sigma` is the square root of the logit transformed
#' biased sample variance.
#'
#' For the density function of the logit-normal distribution see
#' [dlogitnorm][logitnorm::dlogitnorm].
#'
#' @param x a (non-empty) numeric vector of data values.
#' @param na.rm logical. Should missing values be removed?
#' @param ... currently affects nothing.
#' @return `mllogitnorm` returns an object of [class][base::class]
#' `univariateML`. This is a named numeric vector with maximum likelihood
#' estimates for `mu` and `sigma` and the following attributes:
#' \item{`model`}{The name of the model.}
#' \item{`density`}{The density associated with the estimates.}
#' \item{`logLik`}{The loglikelihood at the maximum.}
#' \item{`support`}{The support of the density.}
#' \item{`n`}{The number of observations.}
#' \item{`call`}{The call as captured my `match.call`}
#' @examples
#' AIC(mllogitnorm(USArrests$Rape / 100))
#' @seealso [Normal][stats::dnorm] for the normal density.
#' @references Atchison, J., & Shen, S. M. (1980). Logistic-normal
#' distributions: Some properties and uses. Biometrika, 67(2), 261-272.
#' @export
mllogitnorm <- function(x, na.rm = FALSE, ...) {}
univariateML_metadata$mllogitnorm <- list(
"model" = "LogitNormal",
"density" = "logitnorm::dlogitnorm",
"support" = intervals::Intervals(c(0, 1), closed = c(FALSE, FALSE)),
"names" = c("mu", "sigma"),
"default" = c(2, 3)
)
mllogitnorm_ <- function(x, ...) {
n <- length(x)
y <- stats::qlogis(x)
mu <- mean(y)
sigma <- sqrt(stats::var(y) * (n - 1) / n)
H <- mean(log(x))
G <- mean(log(1 - x))
estimates <- c(mu = mu, sigma = sigma)
logLik <-
-n / 2 * (1 + log(2 * pi) + 2 * log(sigma) + 2 * H + 2 * G)
list(estimates = estimates, logLik = logLik)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.