Dear all, I am wondering if there is a minor bug in the optimimize function; please see below:
--- > ## example taken from optimize documentation > f <- function (x, a) (x - a)^2 > xmin <- optimize(f, c(0, 1), tol = 0.0001, a = 1/3) > xmin $minimum [1] 0.3333333 $objective [1] 0 > ## if we change argument a to j things still work fine > f2 <- function (x, j) (x - j)^2 > xmin2 <- optimize(f2, c(0, 1), tol = 0.0001, j = 1/3) > xmin2 $minimum [1] 0.3333333 $objective [1] 0 > ## if we change argument a to i things fail > f3 <- function (x, i) (x - i)^2 > xmin3 <- optimize(f3, c(0, 1), tol = 0.0001, i = 1/3) Error in optimize(f3, c(0, 1), tol = 1e-04, i = 1/3) : 'xmin' not less than 'xmax' > xmin3 $minimum [1] 0.3333333 $objective [1] 0 > ##Same here > xmin3 <- optimize(f3, lower=0, upper=1, tol = 0.0001, i = 1/3) Error in f(arg, ...) (from #1) : argument "i" is missing, with no default > xmin3 $minimum [1] 0.3333333 $objective [1] 0 > ## a workaround is > xmin3 <- optimize(f3, interval=c(0, 1), tol = 0.0001, i = 1/3) > xmin3 $minimum [1] 0.3333333 $objective [1] 0 --- the problem is, I guess, due to the keyword 'interval' gets mixed up with 'i'. Has anyone experienced that? Best regards S�ren [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.