Hi,

my first guess is that the algorithm returns a negative value in some 
step - recall that you start from 0.0207!! This negative value is then 
passed as standard error to qnorm and that cannot work...
My guess is based on a small experiment where I tried a different 
starting point (.02 is so close to 0 that one cannot see anything):
xsd <- optim(20, fr, NULL,method="BFGS",control=list(trace=6))

The warnings which you didn't include also tell you about NaNs in 
qnorm() - another strong indication of wrong arguments to qnorm().

Try constrained optimization to resctrict to positive values.
See ?constrOptim or use optim() with a method allowing for box 
constraints - see ?optim, arguments lower, upper.

Petr

livia napsal(a):
> 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?

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic

______________________________________________
[email protected] 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.

Reply via email to