[R] using optimize with two unknowns, e.g. to parameterize a distribution with given confidence interval

David LeBauer dlebauer at illinois.edu
Fri Oct 15 23:31:20 CEST 2010


Hi,

I would like to write a function that finds parameters of a log-normal
distribution with a 1-alpha CI of (x_lcl, x_ucl):

However, I don't know how to optimize for the two unknown parameters.

Here is my unsuccessful attempt to find a lognormal distribution with
a 90%CI of 1,20:

prior <- function(x_lcl, x_ucl, alpha, mean, var) {
  a <- (plnorm(x_lcl, mean, var) - (alpha/2))^2
  b <- (plnorm(x_ucl, mean, var) - (1-alpha/2))^2
  return(a+b)
  }

optimize(fn=prior, interval = c(-5, 100), 1, 20)

I understand that this problem has a closed form solution, but I would
like to make this a general function.

Thanks,

David

-- 
David LeBauer, PhD
Energy Biosciences Institute
University of Illinois Urbana-Champaign
1206 W. Gregory Drive
Urbana, IL  61801, U.S.A.



More information about the R-help mailing list