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

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

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

                                        The particle filtering algorithm
                                         粒子滤波算法

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

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

Function for doing particle filtering given the state equation (via generateNextStreamFunc), and the observation equation density (via logObsDensFunc).
做粒子滤波给出的状态方程中的作用(通过generateNextStreamFunc),并观测方程密度(通过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----------


particleFilter(nStreams,                           
               nPeriods,                           
               dimPerPeriod,                       
               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。


参数:generateNextStreamsFunc
function of six arguments (currentPeriod, lag1Streams, lag1LogWeights, streamIndices,     startingStreams, ...).
function的六个参数(currentPeriod, lag1Streams, lag1LogWeights, streamIndices,     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 generateNextStreamsFunc, logObsDensFunc, resampCriterionFunc, resampFunc, summaryFunc and MHUpdateFunc.
可选参数被传递到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: “particleFilter”.
过滤器类型::“particleFilter。


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


可选功能: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  -




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: this function should distinguish the cases currentPeriod == 1 and currentPeriod > 1 inside of
注意:此功能区分的情况下,currentPeriod == 1和currentPeriod > 1内的


可选功能: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-many MH steps for each of the streams in the rows of the argument
acceptanceRates的矢量的长度nStreams,nMHSteps-许多MH步骤表示的接受率的参数的行中的每一个的流




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 the builtin Metropolis Hastings updating function, which generates proposals for currentPeriod
MHUpdateFunc内置的大都市黑斯廷斯更新功能,产生建议currentPeriod




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

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

summaryFunc and MHUpdateFunc</dt> are only necessary when user wants to try out new resampling schemes, enhanced summary generation procedures or more efficient MH updating rules, as part of their research. The default builtins take care of the
summaryFunc和MHUpdateFunc </ dt的>是必要的,当用户想尝试新的重采样计划,加强汇总生成程序或更有效的MH更新规则,作为他们的研究的一部分。默认的内建命令的照顾

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 stream ids accpeted (at each period) if resampling was done or
propUniqueStreamIds的向量长度nPeriods。独特的流ID的值不是比例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----------

scientific computing. Springer. Page 66.</CITE>

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

auxiliaryParticleFilter
auxiliaryParticleFilter


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


MSObj  <- MarkovSwitchingFuncGenerator(-13579)
smcObj <-
    with(MSObj,
     {
         particleFilter(nStreams                = 5000,
                        nPeriods                = nrow(yy),
                        dimPerPeriod            = ncol(yy),
                        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(-97531)
smcObj <-
    with(MSObj,
     {
         particleFilter(nStreams                = 5000,
                        nPeriods                = nrow(yy),
                        dimPerPeriod            = ncol(yy),
                        generateNextStreamsFunc = generateNextStreamsFunc,
                        logObsDensFunc          = logObsDensFunc,
                        nMHSteps                = 10,
                        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 04:45 , Processed in 0.039661 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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