twCoefLogitnormE: twCoefLogitnormE

View source: R/logitnorm.R

twCoefLogitnormER Documentation

twCoefLogitnormE

Description

Estimating coefficients of logitnormal distribution from expected value, i.e. mean, and upper quantile.

Usage

twCoefLogitnormE(mean, quant, perc = c(0.975), 
    method = "BFGS", theta0 = c(mu = 0, sigma = 1), 
    returnDetails = FALSE, ...)

Arguments

mean

the expected value of the density function

quant

the quantile values

perc

the probabilities for which the quantiles were specified

method

method of optimization (see optim)

theta0

starting parameters

returnDetails

if TRUE, the full output of optim is returned with attribute resOptim

...

further arguments to optim

Value

named numeric matrix with estimated parameters of the logitnormal distribution. colnames: c("mu","sigma")

Author(s)

Thomas Wutzler

See Also

logitnorm

Examples

# estimate the parameters
(thetaE <- twCoefLogitnormE(0.7,0.9))

x <- seq(0,1,length.out = 41)[-c(1,41)]	# plotting grid
px <- plogitnorm(x,mu = thetaE[1],sigma = thetaE[2])	#percentiles function
plot(px~x); abline(v = c(0.7,0.9),col = "gray"); abline(h = c(0.5,0.975),col = "gray")
dx <- dlogitnorm(x,mu = thetaE[1],sigma = thetaE[2])	#density function
plot(dx~x); abline(v = c(0.7,0.9),col = "gray")

z <- rlogitnorm(1e5, mu = thetaE[1],sigma = thetaE[2])
mean(z)	# about 0.7

# vectorized
(theta <- twCoefLogitnormE(mean = seq(0.4,0.8,by = 0.1),quant = 0.9))

logitnorm documentation built on May 29, 2024, 6:40 a.m.