Background
I am trying to install the distribution on 95% CI and mode. The cost function that I use solves three functions for 0: P (X = 2.5 | mu, sigma) = 0.025, P (X = 7.5 | mu, sigma) = 0.975, and log-N (mu, sigma) = 3.3. Note: the logarithm mode is = $ e ^ {\ mu- \ sigma ^ 2)} $:
An approach
First I write a cost function, prior
prior <- function(parms) {
a <- abs(plnorm(2.5, parms[1], parms[2]) - 0.025)
b <- abs(plnorm(7.5, parms[1], parms[2]) - 0.975)
mode <- exp(parms[1] - parms[2]^2)
c <- abs(mode-3.3)
return(a + b + c)
}
And then I look for parameters that minimize the cost of the function
v = nlm(prior,c(log(3.3),0.14))
Obviously, the function is maximized for LCL mode, but not for UCL.
abs(plnorm(7.5, parms[1], parms[2]) - 0.975)
> [1] 0.02499989
Here is a graph with dashed lines at the desired 95% CI:
x <- seq(0,10,0.1)
plot(x,dlnorm(x, v$estimate[1],v$estimate[2]),type='l')
abline(v=c(2.5,7.5), lty=2)
Question
Optimization of two points is close, and the whole mistake is in the third. However, I would like it to exactly match the dots.
How can I make a function give equal weight to the value of a, b and c terms? It seems that the function matches only a and c.
. [cross validated] [1], , R nlm(), CV .