>From the help page: Note:
'optim' will work with one-dimensional 'par's, but the default method does not work well (and will warn). Use 'optimize' instead. Next, there is a constraint of x>=0 that you are not imposing. Finally, it is easy to see that qnorm(0.7, 0.0032, x) is monotome in x, so the solution is x=0. In fact, x1 = 0.0032 + sqrt(x) * qnorm(0.7). optim(0.0207, fr) does a good enough job, as does optimize(fr, low=0, up=0.05) Advice: numerical optimization is not a black box, and has to be used with some analysis of the problem to hand. See e.g. MASS4, chapter 16. On Mon, 18 Jun 2007, livia wrote: > > Hi, I would like to minimize the value of x1-x2, x2 is a fixed value of 0.01, > x1 is the quantile of normal distribution (0.0032,x) with probability of > 0.7, and the changing value should be x. Initial value for x is 0.0207. I am > using the following codes, but it does not work. > > fr <- function(x) { > x1<-qnorm(0.7,0.0032,x) > x2=0.01 > x1-x2 > } > xsd <- optim(0.0207, fr, NULL,method="BFGS") > > It is the first time I am trying to use optimization. Could anyone give me > some advice? > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.