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

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

[复制链接]
发表于 2012-9-30 10:19:42 | 显示全部楼层 |阅读模式
auxiliaryParticleFilter(SMC)
auxiliaryParticleFilter()所属R语言包:SMC

                                        The auxiliary particle filtering algorithm
                                         辅助粒子滤波算法

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

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

Function for doing auxiliary particle filtering given the state equation (via generateNextStreamsFunc), the stream representative generation rule (via generateStreamRepsFunc), and the observation equation density (via logObsDensFunc).
做辅助粒子滤波的状态方程的功能(通过generateNextStreamsFunc),流代表的产生规则(通过generateStreamRepsFunc),观测方程密度(通过logObsDensFunc)。

See the sections Details, Required Functions and Optional Functions for explanation on the arguments and the return values of the arguments that are themselves functions.
请参阅章节详细信息,所需要的功能和可选功能,解释的参数和返回值参数,功能。


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


auxiliaryParticleFilter(nStreams,                          
                        nPeriods,                          
                        dimPerPeriod,                     
                        generateStreamRepsFunc,            
                        generateNextStreamsFunc,            
                        logObsDensFunc,                    
                        resampCriterionFunc = NULL,  
                        resampFunc          = NULL,
                        summaryFunc         = NULL,  
                        nMHSteps            = 0,     
                        MHUpdateFunc        = NULL,  
                        nStreamsPreResamp   = NULL,  
                        returnStreams       = FALSE,
                        returnLogWeights    = FALSE,
                        verboseLevel        = 0,     
                        ...)                                             



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

参数:nStreams
integer > 0.
integer> 0。


参数:nPeriods
integer > 0.
integer> 0。


参数:dimPerPeriod
integer > 0.
integer> 0。


参数:generateStreamRepsFunc
function of five arguments (currentPeriod, lag1Streams, lag1LogWeights, streamIndices,     ...).
function的五个参数(currentPeriod, lag1Streams, lag1LogWeights, streamIndices,     ...)。


参数:generateNextStreamsFunc
function of seven arguments (currentPeriod, lag1Streams, lag1LogWeights, streamIndices,     streamReps, startingStreams, ...).
function的七个参数(currentPeriod, lag1Streams, lag1LogWeights, streamIndices,     streamReps, startingStreams, ...)。


参数:logObsDensFunc
function of three arguments (currentPeriod, currentStreams, ...).
function的三个参数(currentPeriod, currentStreams, ...)。


参数:resampCriterionFunc
function of four arguments (currentPeriod, currentStreams, currentLogWeights, ...).
function的四个参数(currentPeriod, currentStreams, currentLogWeights, ...)。


参数:resampFunc
function of four arguments (currentPeriod, currentStreams, currentLogWeights, ...).
function的四个参数(currentPeriod, currentStreams, currentLogWeights, ...)。


参数:summaryFunc
function of four arguments (currentPeriod, currentStreams, currentLogWeights, ...).
function的四个参数(currentPeriod, currentStreams, currentLogWeights, ...)。


参数:nMHSteps
integer >= 0.
integer>= 0。


参数:MHUpdateFunc
function of six arguments (currentPeriod, nMHSteps, currentStreams, lag1Streams,       lag1LogWeights, ...).
function的六个参数(currentPeriod, nMHSteps, currentStreams, lag1Streams,       lag1LogWeights, ...)。


参数:nStreamsPreResamp
integer > 0.
integer> 0。


参数:returnStreams
logical.
logical。


参数:returnLogWeights
logical.
logical。


参数:verboseLevel
integer, a value >= 2 produces a lot of output.
integer,一个值>=2产生大量的输出。


参数:...
optional arguments to be passed to generateStreamRepsFunc, generateNextStreamsFunc, logObsDensFunc, resampCriterionFunc, resampFunc, summaryFunc and MHUpdateFunc.  
可选参数被传递到generateStreamRepsFunc,generateNextStreamsFunc,logObsDensFunc,resampCriterionFunc,resampFunc,summaryFunc和MHUpdateFunc。


Details

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

We introduce the following terms, which will be used in the sections Required Function and Optional Function below:
我们引进所需的功能和可选功能下面的章节中,将被用于以下条款:




stream the state vector also called the particle, the hidden state or the latent variable. Below we will use the terms
stream的状态向量也被称为粒子的隐藏状态或潜在的变量。下面我们将使用术语




dimPerPeriod the dimension of the space, the state
dimPerPeriod的空间,国家的维


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

This function returns a list with the following components:
这个函数返回一个列表,有以下组件:


参数:draws
a list with the following components: summary, propUniqueStreamIds, streams, logWeights, acceptanceRates. See the section Note for more details.
以下部分组成:summary,propUniqueStreamIds,streams,logWeights,acceptanceRates的列表。有关详细信息,请参阅注意。


参数:nStreams
the nStreams argument.
nStreams参数。


参数:nPeriods
the nPeriods argument.
nPeriods参数。


参数:dimPerPeriod
the dimPerPeriod argument.
dimPerPeriod参数。


参数:nStreamsPreResamp
the nStreamsPreResamp argument.
nStreamsPreResamp参数。


参数:nMHSteps
the nMHSteps argument.
nMHSteps参数。


参数:filterType
type of the filter: “auxiliaryParticleFilter”.
过滤器类型::“auxiliaryParticleFilter。


参数:time
the time taken by the run.   
所用的时间运行。


所需的功能:generateStreamRepsFunc----------Required function: generateStreamRepsFunc----------




Arguments: The following argument(s) require some
参数:以下参数(S)需要一些




lag1Streams a matrix of dimension nStreams x dimPerPeriod of streams for
lag1Streams维的矩阵nStreamsxdimPerPeriod流




lag1LogWeights a vector of length nStreams of log weights corresponding to the streams in the argument matrix
lag1LogWeights矢量的长度nStreams流中的参数矩阵的权重相应的log




streamIndices a vector of length nStreams for which the stream representatives (μ_t^k of Pitt and Shephard, 1999) for currentPeriod are to be generated. See
streamIndices一个向量的长度nStreams流代表(μ_t^k皮特和谢泼德,1999年)currentPeriod要生成。看




Return value: a matrix of dimension nStreamIndices x dimPerPeriod. The rows of this matrix contain the stream representative for period currentPeriod, given the state vectors to be found in the streamIndices rows of the argument lag1Streams matrix. Here nStreamIndices is the length of the argument
返回值:矩阵的尺寸nStreamIndicesxdimPerPeriod。这个矩阵的行包含流期间代表currentPeriod“的状态的向量被发现在streamIndices行参数lag1Streams矩阵。这是nStreamIndices的长度的参数




Note: The following points are in order:
注:以下几点:




– this function should distinguish the cases currentPeriod == 1 and currentPeriod > 1 inside of
- 此功能的情况下,应区分currentPeriod == 1和currentPeriod > 1内的




&ndash; for details on the stream representatives (i.e., &mu;_t^k), see of Pitt and Shephard, 1999. The quantity &mu;_t^k could be the mean, the mode, a draw or some other likely value associated with the state density for period currentPeriod (i.e., <i>f(&alpha;_t \mid &alpha;_{t -
- 细节上的流代表(即&mu;_t^k),皮特和谢泼德,1999年。的数量&mu;_t^k可能是平均值,模式,平局或期间currentPeriod(即<I>(α_t\中旬α_的态密度与其他一些可能的值{T  -




&ndash; this function is called by setting streamIndices to 1:nStreams, i.e., stream representatives for all the streams in the argument lag1Streams matrix is
- 这个函数被调用,通过设置streamIndices到1:nStreams,即流代表所有的流参数lag1Streams矩阵是


可选功能:generateNextStreamsFunc----------Optional function: generateNextStreamsFunc----------




Arguments: The following argument(s) require some
参数:以下参数(S)需要一些




lag1Streams a matrix of dimension nStreams x dimPerPeriod of streams for
lag1Streams维的矩阵nStreamsxdimPerPeriod流




lag1LogWeights a vector of length nStreams of log weights corresponding to the streams in the argument matrix
lag1LogWeights矢量的长度nStreams流中的参数矩阵的权重相应的log




streamIndices a vector of length >= nStreams which are to be updated from currentPeriod -
streamIndices的矢量的长度>=nStreams被更新从<code> currentPeriod  -




streamReps a matrix of dimension nStreams x dimPerPeriod of the stream representatives
streamReps维的矩阵nStreamsxdimPerPeriod的流代表




startingStreams a matrix of dimension nStreams x dimPerPeriod to be used for currentPeriod = 1. If this is NULL, then the function should provide a way to generate streams for
startingStreams的维度的矩阵nStreamsxdimPerPeriod用于currentPeriod = 1。如果这是NULL,那么这个函数应该提供一种方法来生成流的




Return value: a matrix of dimension nStreamIndices x dimPerPeriod. The rows of this matrix contain the state vectors for period currentPeriod, given the state vectors to be found in the streamIndices rows of the argument lag1Streams matrix. Here nStreamIndices
返回值:矩阵的尺寸nStreamIndicesxdimPerPeriod。这个矩阵中的行的状态向量期currentPeriod,国家在streamIndices的说法lag1Streams矩阵的行向量被发现。这是nStreamIndices




Note: The following points are in order:
注:以下几点:




&ndash; this function should distinguish the cases currentPeriod == 1 and currentPeriod > 1 inside of
- 此功能的情况下,应区分currentPeriod == 1和currentPeriod > 1内的




&ndash; this function is called by setting streamIndices such that nStreamIndices takes either of the two values nStreams or nStreamsPreResamp in different
- 这个函数被调用的设置streamIndicesnStreamIndices接受的两个值nStreams或nStreamsPreResamp在不同的


可选功能:logObsDensFunc----------Optional function: logObsDensFunc----------




Arguments: The following argument(s) require some
参数:以下参数(S)需要一些




currentStreams a matrix with dimPerPeriod columns, the rows containing the streams for
currentStreams矩阵dimPerPeriod列,行流




Return value: a vector of length nCurrentStreams, where nCurrentStreams refers to the number of rows of the currentStreams matrix argument. This vector contains the observation equation density values for currentPeriod in
返回值:一个向量的长度nCurrentStreams,其中nCurrentStreams指currentStreams矩阵参数的行的数量。这个向量包含观测方程密度值currentPeriod




Note: nCurrentStreams might be >=
注:nCurrentStreams是>=


可选功能:resampCriterionFunc----------Optional function: resampCriterionFunc----------




Arguments: The following argument(s) require some
参数:以下参数(S)需要一些




currentStreams a matrix with dimPerPeriod columns, the rows containing the updated streams for
currentStreams矩阵dimPerPeriod列,行包含更新的流




currentLogWeights a vector of log weights corresponding to the streams in the argument matrix
currentLogWeights一个矢量流的参数矩阵对应的log重




Return value: TRUE or FALSE reflecting the
返回值:TRUE或FALSE反映




Note: The following points are in order:
注:以下几点:




&ndash; resampling schemes manily depend on currentLogWeights, the other two arguments might come in handy for implementing period or stream specific resampling
- 重采样的计划马尼雷取决于currentLogWeights,其他两个参数可能会派上用场,用于实施特定期间或流重采样




&ndash; if nStreamsPreResamp > nStreams, then this
- 如果nStreamsPreResamp>nStreams,然后


可选功能:resampFunc----------Optional function: resampFunc----------




Arguments: see the sub-section Arguments: for section
参数:分节参数:部分




Return value: a named list with the following
返回值:命名列表以下




currentStreams a matrix of dimension nStreams x dimPerPeriod. The rows of this matrix contain the streams for period currentPeriod + 1 that were resampled from those of the argument currentStreams matrix,
currentStreams矩阵的尺寸nStreamsxdimPerPeriod。这个矩阵的行包含流期currentPeriod + 1的说法currentStreams矩阵重采样,




currentLogWeights The log weights vector of length nStreams, associated with the streams that were resampled in the returned currentStreams matrix. Note, after the
currentLogWeightslog的权重向量的长度nStreams,在返回的currentStreams矩阵重采样与流相关的。请注意,后




Note: the components of the list returned by this function and the arguments to this function have two common names, namely, currentStreams and currentLogWeights. These entities have different meanings, as explained above. For example, the argument matrix currentStreams could possibly have >= nStreams rows, whereas the returned currentStreams has exactly nStreams number of
注:通过此功能和参数给这个函数返回的列表的组件有两个共同的名字,即,currentStreams和currentLogWeights。这些实体具有不同的含义,如上面所解释的。例如,参数矩阵currentStreams可能有>=nStreams行,而返回的currentStreams具有完全nStreams数量


可选功能:summaryFunc----------Optional function: summaryFunc----------




Arguments: The following argument(s) require some
参数:以下参数(S)需要一些




currentStreams a matrix of dimension nStreams x dimPerPeriod of streams for
currentStreams维的矩阵nStreamsxdimPerPeriod流




currentLogWeights a vector of log weights corresponding to the streams in the argument matrix
currentLogWeights一个矢量流的参数矩阵对应的log重




Return value: a vector of length of dimSummPerPeriod of summaries for currentPeriod given the
返回值:一个矢量的长度dimSummPerPeriod摘要currentPeriod给定的


可选功能:MHUpdateFunc----------Optional function: MHUpdateFunc----------




Arguments: The following argument(s) require some
参数:以下参数(S)需要一些




nMHSteps the number of Metropolis Hastings (MH) steps
nMHSteps的数量都会黑斯廷斯(MH)的步骤




currentStreams a matrix of dimension nStreams x dimPerPeriod of streams for
currentStreams维的矩阵nStreamsxdimPerPeriod流




lag1Streams a matrix of dimension nStreams x dimPerPeriod of streams for
lag1Streams维的矩阵nStreamsxdimPerPeriod流




lag1LogWeights a vector of length nStreams of log weights corresponding to the streams in the argument matrix
lag1LogWeights矢量的长度nStreams流中的参数矩阵的权重相应的log




Return value: a named list with the following
返回值:命名列表以下




currentStreams a matrix of dimension nStreams x dimPerPeriod. The rows of this matrix contain the streams for period currentPeriod that are (possibly) MH-updated versions of the rows of the argument
currentStreams矩阵的尺寸nStreamsxdimPerPeriod。此矩阵的各行中包含的流期间currentPeriod,(可能)MH更新版本的参数的行




acceptanceRates a vector of length nStreams, representing the acceptance rates of the nMHSteps MH steps for each of the streams in the rows of the argument
acceptanceRates的矢量长度nStreams,较nMHStepsMH步骤的参数的行中的每一个的流的接受率




Note: a positive value of nMHSteps performs as many MH steps on the rows of the argument currentStreams matrix. This is done to reduce the possible degeneracy after the
注:正值nMHSteps MH步骤进行尽可能多的参数currentStreams矩阵的行。这样做是为了减少可能的简并后的


警告----------Warning----------

Using very small values (<= 1e3) for nStreams might not give reliable results.
使用非常小的值(<=1e3)nStreams可能不能得到可靠的结果。


注意----------Note----------

The effect of leaving the default value NULL for some of the arguments above are as follows:
保留默认值NULL上面的参数的影响如下:




resampCriterionFunc the builtin resampling criterion, namely, resample when square of the coefficient of variation of
resampCriterionFunc内建的重采样的标准,即,重新取样的变异系数为正方形时




resampFunc the builtin resampling function, which resamples streams with probability proportional to their weights,
resampFunc内建的重采样功能,重新取样流的概率为权重成正比,




summaryFunc the builtin summary function, which returns the weighted average of each of the dimPerPeriod
summaryFunc内建的汇总函数,这平均每dimPerPeriod的返回加权




MHUpdateFunc unlike, particleFilter, there is no builtin Metropolis Hastings updating function, which generates proposals for currentPeriod streams using those of currentPeriod - 1. The user needs to implement this function if
MHUpdateFunc不像,particleFilter,有没有内建大都会赫斯廷斯更新功能,其中生成建议currentPeriod流使用那些currentPeriod - 1。用户需要实现这个功能,如果




nStreamsPreResamp it is set to nStreams.
nStreamsPreResamp设置为nStreams。

Also, the following point is worth noting:
此外,下面的点值得注意的是:

summaryFunc</dt> are only necessary when user wants to try out new resampling schemes or enhanced summary generation procedures, as part of their research. The default builtins take care of the
summaryFunc</ dt的是只需要当用户想尝试新的重采样计划或增强的汇总生成程序,因为他们的研究的一部分。默认的内建命令的照顾

This function returns a list with component called draw. The detailed description of this component, as promised in section Value, is as follows. It is a list itself with the following components:
此函数返回一个列表与组件称为draw。所承诺的部分价值,该组件的详细描述,如下所示。它是一个列表本身与以下组件:




summary a matrix of dimension nPeriods
summary一个矩阵的尺寸nPeriods




propUniqueStreamIds a vector of length nPeriods. The values are either proportions of unique streams accpeted (at each period) if resampling was done or
propUniqueStreamIds的向量长度nPeriods。的值要么是独特的已流accpeted(在每个时期)的比例,如果是重采样




streams an array of dimension nStreams x dimPerPeriod x
streams阵列的尺寸nStreamsxdimPerPeriodx




logWeights a matrix of dimension nStreams x nPeriods. This is returned if
logWeights矩阵的尺寸nStreamsxnPeriods。这是返回




acceptanceRates a matrix of dimension nStreams x nPeriods. This is returned if
acceptanceRates矩阵的尺寸nStreamsxnPeriods。这是返回


(作者)----------Author(s)----------


Gopi Goswami <a href="mailto:goswami@stat.harvard.edu">goswami@stat.harvard.edu</a>



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

Simulation: Auxiloary Particle Filters. Journal of the American Statistical Association 94(446): 590-599.</CITE>

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

particleFilter
particleFilter


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


MSObj  <- MarkovSwitchingFuncGenerator(-2468)
smcObj <-
    with(MSObj,
     {
         auxiliaryParticleFilter(nStreams                = 5000,
                                 nPeriods                = nrow(yy),
                                 dimPerPeriod            = ncol(yy),
                                 generateStreamRepsFunc  = generateStreamRepsFunc,
                                 generateNextStreamsFunc = generateNextStreamsFunc,
                                 logObsDensFunc          = logObsDensFunc,
                                 returnStreams           = TRUE,
                                 returnLogWeights        = TRUE,
                                 verboseLevel            = 1)
     })
print(smcObj)
print(names(smcObj))
with(c(smcObj, MSObj),
{
     par(mfcol = c(2, 1))
     plot(as.ts(yy),
          main     = expression('The data and the underlying regimes'),
          cex.main = 0.8,
          xlab     = 'period',
          ylab     = 'data and the regime means',
          cex.lab  = 0.8)
     lines(as.ts(mu), col = 2, lty = 2)
     plot(as.ts(draws$summary[1, ]),
          main     = expression('The underlying regimes and their estimates'),
          cex.main = 0.8,
          xlab     = 'period',
          ylab     = 'regime means',
          cex.lab  = 0.8)
     lines(as.ts(mu), col = 2, lty = 2)        
})

MSObj  <- MarkovSwitchingFuncGenerator(-8642)
smcObj <-
    with(MSObj,
     {
         auxiliaryParticleFilter(nStreams                = 5000,
                                 nPeriods                = nrow(yy),
                                 dimPerPeriod            = ncol(yy),
                                 generateStreamRepsFunc  = generateStreamRepsFunc,
                                 generateNextStreamsFunc = generateNextStreamsFunc,
                                 logObsDensFunc          = logObsDensFunc,
                                 returnStreams           = TRUE,
                                 returnLogWeights        = TRUE,
                                 verboseLevel            = 1)
     })
print(smcObj)
print(names(smcObj))
with(c(smcObj, MSObj),
{
     par(mfcol = c(2, 1))
     plot(as.ts(yy),
          main     = expression('The data and the underlying regimes'),
          cex.main = 0.8,
          xlab     = 'period',
          ylab     = 'data and the regime means',
          cex.lab  = 0.8)
     lines(as.ts(mu), col = 2, lty = 2)
     plot(as.ts(draws$summary[1, ]),
          main     = expression('The underlying regimes and their estimates'),
          cex.main = 0.8,
          xlab     = 'period',
          ylab     = 'regime means',
          cex.lab  = 0.8)
     lines(as.ts(mu), col = 2, lty = 2)        
})

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-5-29 07:36 , Processed in 0.041588 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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