nlminb(stats)
nlminb()所属R语言包:stats
Optimization using PORT routines
优化使用港口例程
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Unconstrained and constrained optimization using PORT routines.
约束和约束优化使用端口例程。
用法----------Usage----------
nlminb(start, objective, gradient = NULL, hessian = NULL, ...,
scale = 1, control = list(), lower = -Inf, upper = Inf)
参数----------Arguments----------
参数:start
numeric vector, initial values for the parameters to be optimized.
数字向量,为参数的初始值进行优化。
参数:objective
Function to be minimized. Must return a scalar value (possibly NA/Inf). The first argument to objective is the vector of parameters to be optimized, whose initial values are supplied through start. Further arguments (fixed during the course of the optimization) to objective may be specified as well (see ...).
要最小化的运作。必须返回一个标量值(可能NA / INF)。的第一个参数objective是参数向量进行优化,通过start提供的初始值。进一步参数(在优化过程中固定)objective可指定为(见...)。
参数:gradient
Optional function that takes the same arguments as objective and evaluates the gradient of objective at its first argument. Must return a vector as long as start.
可选的功能,为objective相同的论点,并评估在其第一个参数的梯度objective。只要start必须返回一个向量。
参数:hessian
Optional function that takes the same arguments as objective and evaluates the hessian of objective at its first argument. Must return a square matrix of order length(start). Only the lower triangle is used.
可选的功能,为objective相同的论点,并评估在其第一个参数objective麻袋。为了length(start)必须返回一个方阵。只使用较低的三角形。
参数:...
Further arguments to be supplied to objective.
进一步提供的参数objective。
参数:scale
See PORT documentation (or leave alone).
看到端口文件(或独自离开)。
参数:control
A list of control parameters. See below for details.
控制参数的列表。细节见下文。
参数:lower, upper
vectors of lower and upper bounds, replicated to be as long as start. If unspecified, all parameters are assumed to be unconstrained.
上限和下限的向量,复制到start。如果未指定,假定所有参数都可以不受约束。
Details
详情----------Details----------
Any names of start are passed on to objective and where applicable, gradient and hessian. The parameter vector will be coerced to double.
任何start的名称传递给objective“(如适用),gradient和hessian。裹挟参数向量将翻一番。
The PORT documentation is at http://netlib.bell-labs.com/cm/cs/cstr/153.pdf.
港口文件是在http://netlib.bell-labs.com/cm/cs/cstr/153.pdf的。
值----------Value----------
A list with components:
与组件列表:
参数:par
The best set of parameters found.
找到最佳的参数集。
参数:objective
The value of objective corresponding to par.
objective相应par的价值。
参数:convergence
An integer code. 0 indicates successful convergence.
一个整数的代码。 0表示成功衔接。
参数:message
A character string giving any additional information returned by the optimizer, or NULL. For details, see PORT documentation.
给予任何其他信息的一个字符串返回的优化,或NULL。有关详情,请参阅端口文件。
参数:iterations
Number of iterations performed.
执行的迭代次数。
参数:evaluations
Number of objective function and gradient function evaluations
数目标函数和梯度功能评价
控制参数----------Control parameters----------
Possible names in the control list and their default values are:
control列表和它们的默认值中的可能的名称是:
eval.max Maximum number of evaluations of the objective
eval.max的最大数量客观的评价
iter.max Maximum number of iterations allowed.
iter.max迭代允许的最大数量。
trace The value of the objective function and the parameters is printed every trace'th iteration. Defaults to 0 which
trace目标函数和参数的值打印每traceth的迭代。默认为0,这
abs.tol Absolute tolerance. As from R 2.12.0, defaults to 0 so the absolute convergence test is not used. If the objective function is known to be non-negative, the previous default of
abs.tol绝对公差。从R 2.12.0,默认为0,所以不使用绝对收敛测试。如果目标函数是已知的非负的,以前的默认
rel.tol Relative tolerance. Defaults to
rel.tol相对宽容。默认为
x.tol X tolerance. Defaults to 1.5e-8.
x.tolX宽容。 1.5e-8默认。
xf.tol false convergence tolerance. Defaults to
xf.tol假收敛公差。默认为
step.min, step.max Minimum and maximum step size. Both
step.min, step.max最大和最小的步长。两
sing.tol singular convergence tolerance; defaults to
3奇异衔接sing.tol容忍;默认为
scale.init ...
scale.init ...
diff.g an estimated bound on the relative error in the
diff.g估计相对误差在约束
作者(S)----------Author(s)----------
(of <font face="Courier New,Courier" color="#666666"><b>R</b></font> port) Douglas Bates and Deepayan Sarkar.
参考文献----------References----------
<h3>See Also</h3> <code>optim</code> and <code>nlm</code>.
<code>constrOptim</code> for constrained optimization.
举例----------Examples----------
x <- rnbinom(100, mu = 10, size = 10)
hdev <- function(par) {
-sum(dnbinom(x, mu = par[1], size = par[2], log = TRUE))
}
nlminb(c(9, 12), hdev)
nlminb(c(20, 20), hdev, lower = 0, upper = Inf)
nlminb(c(20, 20), hdev, lower = 0.001, upper = Inf)
## slightly modified from the S-PLUS help page for nlminb[#略有修改,S-PLUS帮助nlminb页]
# this example minimizes a sum of squares with known solution y[这个例子,最大限度地减少了与已知的解y的平方的总和]
sumsq <- function( x, y) {sum((x-y)^2)}
y <- rep(1,5)
x0 <- rnorm(length(y))
nlminb(start = x0, sumsq, y = y)
# now use bounds with a y that has some components outside the bounds[现在使用AY有边界之外的一些部件的边界]
y <- c( 0, 2, 0, -2, 0)
nlminb(start = x0, sumsq, lower = -1, upper = 1, y = y)
# try using the gradient[尝试使用渐变]
sumsq.g <- function(x,y) 2*(x-y)
nlminb(start = x0, sumsq, sumsq.g,
lower = -1, upper = 1, y = y)
# now use the hessian, too[现在用的麻袋,太]
sumsq.h <- function(x,y) diag(2, nrow = length(x))
nlminb(start = x0, sumsq, sumsq.g, sumsq.h,
lower = -1, upper = 1, y = y)
## Rest lifted from optim help page[#截断解除OPTIM帮助页面]
fr <- function(x) { ## Rosenbrock Banana function[#的ROSENBROCK香蕉功能]
x1 <- x[1]
x2 <- x[2]
100 * (x2 - x1 * x1)^2 + (1 - x1)^2
}
grr <- function(x) { ## Gradient of 'fr'[#梯度“FR”]
x1 <- x[1]
x2 <- x[2]
c(-400 * x1 * (x2 - x1 * x1) - 2 * (1 - x1),
200 * (x2 - x1 * x1))
}
nlminb(c(-1.2,1), fr)
nlminb(c(-1.2,1), fr, grr)
flb <- function(x)
{ p <- length(x); sum(c(1, rep(4, p-1)) * (x - c(1, x[-p])^2)^2) }
## 25-dimensional box constrained[#25维框约束]
## par[24] is *not* at boundary[#杆[24] *不*在边界]
nlminb(rep(3, 25), flb,
lower=rep(2, 25),
upper=rep(4, 25))
## trying to use a too small tolerance:[#尝试使用过小的公差:]
r <- nlminb(rep(3, 25), flb, control = list(rel.tol=1e-16))
stopifnot(grepl("rel.tol", r$message))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|