找回密码
 注册
查看: 352|回复: 0

R语言 turboEM包 turboem()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-10-1 13:05:56 | 显示全部楼层 |阅读模式
turboem(turboEM)
turboem()所属R语言包:turboEM

                                        A suite of acceleration schemes for fixed-point iterations
                                         一套定点迭代的加速方案

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Globally-convergent, partially monotone, acceleration schemes for accelerating the convergence of any smooth, monotone, slowly-converging contraction mapping. It can be used to accelerate the convergence of a wide variety of iterations including the expectation-maximization (EM) algorithms and its variants, majorization-minimization (MM) algorithm, power method for dominant eigenvalue-eigenvector, Google's page-rank algorithm, and multi-dimensional scaling.



用法----------Usage----------


        turboem(par, fixptfn, objfn, method = c("em", "squarem", "pem", "decme", "qn"),
        boundary, pconstr = NULL, project = NULL, parallel = FALSE, ..., control.method = replicate(length(method),list()),
        control.run = list())



参数----------Arguments----------

参数:par
A vector of parameters denoting the initial guess for the fixed point.
一个向量的参数表示的固定点的初始猜测。


参数:fixptfn
A vector function, F that denotes the fixed-point mapping. This function is the most essential input in the package. It should accept a parameter vector as input and should return a parameter vector of same length. This function defines the fixed-point iteration: x[k+1] = F(x[k]). In the case of EM algorithm, F defines a single E and M step.  
向量函数,F,它表示固定点映。此功能是最重要的输入包中。它应该接受的参数矢量作为输入,并返回一个相同的长度的参数矢量。这个函数定义固定点迭代:x[k+1] = F(x[k])。在的情况下的EM算法,F定义了一个单一的E和M步骤。


参数:objfn
This is a scalar function, L, that denotes a “merit” function which attains its local minimum at the fixed-point of F.  This function should accept a parameter vector as input and should return a scalar value.  In the EM algorithm, the merit function L is the negative log-likelihood. In some problems, a natural merit function may not exist. However, this argument is required for all of the algorithms *except* Squarem (which defaults to Squarem-2 if objfn not provided) and EM.  
这是一个标量函数,表示“好处”功能达到当地最低固定点L的F“。这个函数应该接受一个参数向量作为输入,并返回一个标量值。在EM算法的优点功能L的负对数似然。在一些问题,一个自然的价值函数可能不存在。然而,该参数是必需的所有算法*的Squarem(默认为Squarem-2 objfn未提供)和EM除外。


参数:method
Specifies which algorithm(s) will be applied. Must be a vector containing one or more of c("em", "squarem", "pem", "decme", "qn").
指定的算法(S)将被应用。必须是一个向量,包含一个或多个c("em", "squarem", "pem", "decme", "qn")。


参数:boundary
Argument required for Dynamic ECME (decme) only. Function to define the subspaces over which the line search is conducted.
参数需要动态ECME(decme)只。函数来定义的子空间进行线搜索。


参数:pconstr
Optional function for defining boundary constraints on parameter values. Function maps a vector of parameter values to TRUE if constraints are satisfied. Note that this argument is only used for the Squarem (squarem), Parabolic EM (pem), and quasi-Newton (qn) algorithms, and it has no effect on the other algorithms.



参数:project
Optional function for defining a projection that maps an out-of-bound parameter value into the constrained parameter space. Requires the pconstr argument to be specified in order for the project to be applied.
可选的功能用于定义约束的参数空间投影,映射到外的绑定参数值。需要pconstr参数按顺序指定的project应用。


参数:parallel
Logical indicating whether the acceleration schemes will be run in parallel. Note that the parallel implementation is based on the foreach package, which depends on a parallel backend being registered prior to running turboem(). See *Details* of foreach.
逻辑表明是否将运行在并行加速计划。需要注意的是并行执行的foreach包,这取决于注册一个平行的后端运行之前,turboem()。请参阅*详细*foreach。


参数:control.method
If method = c(method1, method2, ...), then control.method = list(list1, list2, ...) where list1 is the list of control parameters for method1, list2 is the list of control parameters for method2, and so on. If length(method) == 1, then control.method is the list of control parameters for the acceleration scheme.   See *Details*.
如果method = c(method1, method2, ...),那么control.method = list(list1, list2, ...)其中list1是列表中的控制参数method1,list2是列表中的控制参数method2等。如果length(method) == 1,那么control.method是加速计划的控制参数列表。 *详细*。


参数:control.run
List of control parameters for convergence and stopping the algorithms. See *Details*.
算法的收敛和停止的控制参数列表。 *详细*。


参数:...
Arguments passed to fixptfn and  objfn.
传递参数fixptfn和objfn。


Details

详细信息----------Details----------

The function turboem is a general-purpose algorithm for accelerating the convergence of any slowly-convergent (smooth) fixed-point iteration.  
函数turboem是一个通用的算法,加快了收敛的任何慢慢收敛(平滑)固定点迭代。

The component lists of the control.method are used to specify any changes to default values of algorithm control parameters. Full names of control list elements must be specified, otherwise, user specifications are ignored. Default control parameters for method="squarem" are K=1, square=TRUE, version=3, step.min0=1, step.max0=1, mstep=4, kr=1, objfn.inc=1. Default control parameters for method="pem" are l=10, h=0.1, a=1.5, and version="geometric". Default control parameters for method="decme" are version="v2" and tol_op=0.01. Default control parameters for method="qn" are qn=5.
组件列表control.method用于指定任何变化,算法控制参数的默认值。控制列表中的元素的全名,否则,必须指定用户的规范将被忽略。默认的控制参数method="squarem"是K=1,square=TRUE,version=3,step.min0=1,step.max0=1,mstep=4,kr=1 ,objfn.inc=1。默认的控制参数method="pem"是l=10,h=0.1,a=1.5和version="geometric"。默认的控制参数method="decme"是version="v2"和tol_op=0.01。默认的控制参数method="qn"是qn=5。

Default values of control.run are: convtype = "parameter", tol = 1.0e-07, stoptype = "maxiter", maxiter = 1500, maxtime = 60, convfn.user = NULL, stopfn.user = NULL, trace = FALSE, keep.objfval = FALSE.
默认control.run:convtype = "parameter",tol = 1.0e-07,stoptype = "maxiter",maxiter = 1500,maxtime = 60,convfn.user = NULL,stopfn.user = NULL值,trace = FALSE,keep.objfval = FALSE。

There are two ways the algorithm will terminate. Either the algorithm will terminate if convergence has been achieved, or the algorithm will terminate if convergence has not been achieved within a pre-specified maximum number of iterations or maximum running time. The arguments convtype, tol, and convfn.user control the convergence criterion. The arguments stoptype, maxiter, maxtime, and stopfn.user control the alternative stopping criterion.
的方法有两种算法将终止。要么算法终止如果已达到收敛或收敛算法将终止,如果还没有实现在迭代或最大运行时间的预先指定的最大数目之内。的参数convtype,tol和convfn.user控制收敛标准。的参数stoptype,maxiter,maxtime和stopfn.user控制替代的停止标准。

Two types of convergence criteria have been implemented, with an option for the user to define his/her own convergence criterion. If convtype = "parameter", then the default convergence criterion is to terminate if sqrt(crossprod(new - old)) < tol, where new denotes the current value of the fixed point and old denotes the previous fixed-point value. If convtype = "objfn", then the default convergence criterion is to terminate if abs(new - old) < tol, where new denotes the current value of the objective function and old denotes the previous value of the objective function. If the user desires alternate convergence criteria,  convfn.user may be specified as a function with inputs new and old that maps to a logical taking the value TRUE if convergence is achieved and the value FALSE if convergence is not achieved.
有两种类型的趋同标准已经实施,选项为用户定义他/她自己的趋同标准。如果convtype = "parameter",然后在默认的收敛标准是终止如果sqrt(crossprod(new - old)) < tol,其中new表示当前值的固定点和old表示以前的固定点值。如果convtype = "objfn",然后在默认的收敛标准是终止abs(new - old) < tol,其中new表示当前值的目标函数和old表示先前的目标函数值。如果用户需要备用的趋同标准,convfn.user可以被指定为一个函数,输入new和old映射到一个逻辑采取的值为TRUE,如果收敛和值FALSE如果还没有达到收敛。

Two types of alternative stopping criteria have been implemented, with the option for the user to define his/her own stopping criterion. If stoptype = "maxiter", then the algorithm will terminate if convergence has not been achieved within maxiter iterations of the acceleration scheme. If stoptype = "maxtime", then the algorithm will terminate if convergence has not been achieved within maxtime seconds of running the acceleration scheme. Note: the running time of the acceleration scheme is calculated once every iteration. If the user desires different alternate stopping criteria than those implemented, stopfn.user may be specified as a function with no inputs that maps to a logical taking the value TRUE which leads to the algorithm being terminated or the value FALSE which leads to the algorithm proceeding as usual.
有两种类型的替代停止标准已经实施,选项为用户定义他/她自己的停车标准。如果stoptype = "maxiter",那么该算法将终止,如果没有收敛内实现maxiter迭代加速计划。如果stoptype = "maxtime",那么该算法将终止,如果没有收敛内实现maxtime秒的运行加速计划。注:加速计划的运行时间计算一次迭代。如果用户需要不同的备用停止实施这些标准比,stopfn.user可以指定的函数没有输入映射到一个逻辑值TRUE导致算法被终止或FALSE值的导致通常的算法诉讼。




convtype A character string equal to "parameter" or "objfn". "parameter" indicates that the convergence criterion is a function of the current and previous value of the fixed point. objfn indicates that the convergence criterion is a function of the current and previous value of the objective function.
convtypeA字符的字符串等于"parameter"或"objfn"。 "parameter"表明,收敛标准是当前和以前的函数值的固定点。 objfn表示收敛准则的当前和以前的目标函数值的函数。




tol A small, positive scalar that determines when convergence is achieved. See details above for convergence criteria currently implemented. Default is 1.e-07.
tol一个很小的正标量,确定何时实现收敛。详情请参阅以上的趋同标准目前实施。默认是1.e-07。




stoptype A character string equal to "maxiter" or "maxtime" that determines an alternative stopping rule for the algorithm. See details above for stopping rules currently implemented. Default is "maxiter".
stoptype一个字符串等于"maxiter"或"maxtime":,决定替代停止规则的算法。详情请参阅上面的停止规则实施。默认是"maxiter"。




maxiter If stoptype = "maxiter", specifies the number of iterations after which the algorithm will be terminated if convergence has not been achieved. Default is 1500.
maxiter如果stoptype = "maxiter",指定的迭代次数后,该算法将被终止,如果尚未实现收敛。默认值是1500。




maxtime If stoptype = "maxtime", specifies the running time (in seconds) after which the algorithm will be terminated if convergence has not been achieved. Default is 60.
maxtime如果stoptype = "maxtime",指定运行时间(以秒为单位)之后,该算法将终止并没有达到收敛。默认值是60。




convfn.user Optional, user-specified function for determining whether convergence has been achieved. Function should take as inputs new and old, where new is the current value (of the fixed point if convtype = "parameter" and of the objective function value if convtype = "objfn") and old is the previous value. Function should map to a logical taking the value TRUE if convergence is achieved (and hence the algorithm is terminated) and the value FALSE if convergence is not achieved. Default is NULL.
convfn.user可选的,用户指定的功能,以确定是否收敛已经实现了。功能应该作为输入new和old,其中new是当前值(固定点,如果convtype = "parameter"的目标函数值,如果convtype = "objfn" )和old是以前的值。功能应该映射到一个逻辑值TRUE,如果融合的实现(因此算法终止)和值FALSE如果不收敛。默认值是NULL。




stopfn.user Optional, user-specified function for determining whether to terminate the algorithm if convergence has not been achieved. See details above for how to specify. Default is NULL.
stopfn.user可选,决定是否终止算法收敛并没有达到用户指定的功能。详情请参阅如何指定以上。默认值是NULL。




trace A logical variable denoting whether some of the intermediate results of iterations should be displayed to the user. Default is FALSE.
trace的逻辑变量,指示一些迭代的中间结果是否应该被显示给用户。默认值是false。




keep.objfval A logical variable denoting whether the objective function value at each iteration should be stored. Default is FALSE.
keep.objfval逻辑型的变量在每次迭代的目标函数值,指示是否应存放。默认值是false。


值----------Value----------

turboem returns an object of class turbo. An object of class turbo is a list containing at least the following components:
turboem返回一个对象类turbo。一种的类turbo的对象是一个列表,包含至少以下组件:


参数:fail
Vector of logical values whose jth element indicates whether algorithm j failed (produced an error)
向量的j个元素的逻辑值表示是否算法j失败(产生一个错误)


参数:value.objfn
Vector of the value of the objective function L at termination for each algorithm.
目标函数L在终止为每个算法的值的向量。


参数:itr
Vector of the number of iterations completed for each algorithm.
向量的数目为每个算法完成的迭代。


参数:fpeval
Vector of the number of fixed-point evaluations completed for each algorithm.
向量的定点评价数为每个算法完成。


参数:objfeval
Vector of the number of objective function evaluations completed for each algorithm.
向量的目标函数评估的数目为每个算法完成。


参数:convergence
Vector of logical values whose jth element indicates whether algorithm j satisfied the convergence criterion before termination
矢量算法的j个元素的逻辑值表示是否j满足收敛条件终止前


参数:runtime
Matrix whose jth row contains the &ldquo;user&rdquo;, &ldquo;system&rdquo;, and &ldquo;elapsed&rdquo; time for running the jth algorithm.
矩阵的j日行包含“用户”,“系统”和“经过”的j个算法的运行时间。


参数:errors
Vector whose jth element is either NA or contains the error message from running the jth algorithm



参数:pars
Matrix whose jth row contains the fixed-point parameter values at termination for the jth algorithm.
矩阵的j个行包含定点终止的j个算法的参数值。


参数:trace.objfval
If control.run[["keep.objfval"]]=TRUE, contains a list whose jth component is a vector of objective function values across iterations for the jth algorithm
如果control.run[["keep.objfval"]]=TRUE,包含一个列表,其j个组件是一个矢量的各次迭代的目标函数值j个算法


参考文献----------References----------






参见----------See Also----------

turbo
turbo


实例----------Examples----------


###########################################################################[################################################## ########################]
# Also see the vignette by typing:[也看到了小插曲,请键入:]
#  vignette("turboEM")[小插曲(turboEM“)]
#[]
# EM algorithm for Poisson mixture estimation [EM算法的Poisson混合估计]

fixptfn <- function(p,y) {
# The fixed point mapping giving a single E and M step of the EM algorithm[固定点映射给一个单一的E和M步的EM算法]
# []
pnew <- rep(NA,3)
i <- 0length(y)-1)
zi <- p[1]*exp(-p[2])*p[2]^i / (p[1]*exp(-p[2])*p[2]^i + (1 - p[1])*exp(-p[3])*p[3]^i)
pnew[1] <- sum(y*zi)/sum(y)
pnew[2] <- sum(y*i*zi)/sum(y*zi)
pnew[3] <- sum(y*i*(1-zi))/sum(y*(1-zi))
p <- pnew
return(pnew)
}

objfn <- function(p,y) {
# Objective function whose local minimum is a fixed point [的目标函数局部极小值是一个固定点]
# negative log-likelihood of binary poisson mixture[负对数似然的二元Poisson混合]
i <- 0length(y)-1)
loglik <- y*log(p[1]*exp(-p[2])*p[2]^i/exp(lgamma(i+1)) +
                (1 - p[1])*exp(-p[3])*p[3]^i/exp(lgamma(i+1)))
return ( -sum(loglik) )
}

# Real data from Hasselblad (JASA 1969)[哈苏(JASA 1969年)的实时数据]
poissmix.dat <- data.frame(death = 0:9,
        freq = c(162,267,271,185,111,61,27,8,3,1))
y <- poissmix.dat$freq

# Use a preset seed so the example is reproducable. [使用预设的种子,这样的例子是重复性的。]
require("setRNG")
old.seed <- setRNG(list(kind = "Mersenne-Twister", normal.kind = "Inversion",
    seed = 54321))

p0 &lt;- c(runif(1),runif(2,0,4))  # random starting value[随机初始值]

# Basic EM algorithm, SQUAREM, and parabolic EM, with default settings[]
res1 <- turboem(par = p0, y = y, fixptfn = fixptfn, objfn = objfn,
        method = c("EM", "squarem", "pem"))

# To apply the dynamic ECME (decme) acceleration scheme, [应用动态ECME(decme)的加速方案,]
# we need to include a boundary function[我们需要包括边界功能]
boundary <- function(par, dr) {
        lower <- c(0, 0, 0)
        upper <- c(1, 10000, 10000)
        low1 <- max(pmin((lower-par)/dr, (upper-par)/dr))
        upp1 <- min(pmax((lower-par)/dr, (upper-par)/dr))
        return(c(low1, upp1))
}
res2 <- turboem(par = p0, y = y, fixptfn = fixptfn, objfn = objfn,
        boundary = boundary, method = c("EM", "squarem", "pem", "decme"))

# change some of the algorithm-specific default specifications (control.method), [一些特定于算法的默认规格(control.method),]
# as well as the global control parameters (control.run)[以及全球控制参数(control.run),]
res3 <- turboem(par = p0, y = y, fixptfn = fixptfn, objfn = objfn,
        boundary = boundary, method = c("em", "squarem", "squarem", "decme", "qn", "qn"),
        control.method = list(list(), list(K = 2), list(K = 3),
                list(version = "v3"), list(qn = 1), list(qn = 2)),
        control.run = list(tol = 1e-12, stoptype = "maxtime", maxtime = 1))

# Only the standard EM algorithm and SQUAREM *do not* require [只有标准的EM算法和SQUAREM *不*需要]
# providing the objective function. [提供的目标函数。]
res4 <- turboem(par = p0, y = y, fixptfn = fixptfn,
        method = c("em", "squarem", "squarem"),
        control.method = list(list(), list(K = 1), list(K = 2)))
# If no objective function is provided, the "squarem" method defaults to Squarem-2 (or if control parameter K &gt; 1, to Cyclem-2). Compare Squarem with and without objective function provided:[如果没有目标函数提供,“squarem”方法默认到Squarem-2(或者,如果控制参数K> 1时,到Cyclem-2)。目标函数并没有提供比较Squarem:]
res5 <- turboem(par = p0, y = y, fixptfn = fixptfn, method = "squarem")
res5
res6 <- turboem(par = p0, y = y, fixptfn = fixptfn, objfn = objfn, method = "squarem")
res6


转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-28 19:47 , Processed in 0.021851 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表