Why is this code not optimized for all three points?

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) #95%CI

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 .

+3
2

, " ", , a, b c . a b 0,025, (parms[2]), plnorm(2.5, parms[1], parms[2]) 0 ( 7.5). (0,025) c - .

, x 2.5 7.5:

prior2 <- function(parms) { 
  a <- abs(qlnorm(0.025, parms[1], parms[2]) - 2.5) 
  b <- abs(qlnorm(0.975, parms[1], parms[2]) - 7.5) 
  mode <- exp(parms[1] - parms[2]^2) 
  c <- abs(mode-3.3) 
  return(a + b + c) 
} 

, , . , : 2,5- 2.5, 7.5. , - .

- . . , -, . , (a^2+b^2_c^2). ( ) .

prior3 <- function(parms) { 
  a <- abs(parms[1] - 1.96*parms[2] - log(2.5))
  b <- abs(parms[1] + 1.96*parms[2] - log(7.5)) 
  c <- abs(parms[1] - parms[2]^2 - log(3.3)) 
  return(a^2 + b^2 + c^2) 
} 
+1

. log 95% - mu-2 * sigma mu + 2 * sigma. (mu - 2 * sigma - log (2.5)) + abs (mu + 2 * sigma - log (7.5)) + abs (mu - sigma ^ 2 - log (3.3)).

, , , . , -

+1

Source: https://habr.com/ru/post/1778772/


All Articles