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

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

[复制链接]
发表于 2012-9-29 21:05:21 | 显示全部楼层 |阅读模式
TuneWithExitPoll(RxCEcolInf)
TuneWithExitPoll()所属R语言包:RxCEcolInf

                                        Tuning Function for Ecological Inference for Sets of R x C
                                         集生态推理的R X C调谐功能

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

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

This function tunes the markov chain monte carlo algorithm used to fit a hierarchical model to data from two sources:  (i) ecological data in which the underlying contigency tables can have any number of rows or columns, and (ii data from a survey samlpe of some of the contingency tables.  The user supplies the data and may specify hyperprior values.  The function's primary output is a vector of multipliers, called rhos, used to adjust the covariance matrix of the multivariate t_4 distribution used to propose new values of intermediate-level parameters (denoted THETAS).
此功能调整马尔可夫链蒙特卡罗算法,用于适合的层次结构模型,数据有两个来源:(一)生态数据,其中的基础contigency表可以有任意数量的行或列,(二从一项调查samlpe的资料的应急表。用户提供的数据,并可能指定hyperprior值。该函数的主要输出是一个向量乘法器,rhos,调整的多元t_4分布的协方差矩阵提出新的价值观的中间级别的参数(记THETAS)。


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


TuneWithExitPoll(fstring, exitpoll, data = NULL, num.runs = 12,
                 num.iters = 10000, rho.vec = rep(0.05, ntables),
                 kappa = 10, nu = (mu.dim + 6), psi = mu.dim,
                 mu.vec.0 = rep(log((0.45/(mu.dim - 1))/0.55), mu.dim),
                 mu.vec.cu = runif(mu.dim, -3, 0), nolocalmode = 50,  
                 sr.probs = NULL, sr.reps = NULL, numscans = 1,
                 Diri = 100, dof = 4, debug = 1)



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

参数:fstring
String: model formula of contingency tables' column totals versus row totals. Must be in specified format (an R character string and NOT a true R formula).
字符串:模型公式的列联表的列的数量与行总计。必须在指定的格式(R字符的字符串,而不是一个真正的R公式)。


参数:exitpoll
Matrix of dimensions I = number of contingency tables = number of rows in data by (R * C) = number of cells in each contingency table:  The results of a survey sample of some of the contingency tables.  Must be in specified format.  See Details.
矩阵尺寸I数=列联表的行数在data(R * C)=每列联表中的单元数量:调查样本的一些列联表的结果。必须在指定的格式。查看详细信息。


参数:data
Data frame.
数据框。


参数:num.runs
Positive integer:  The number of runs or times (each of num.iters iterations) the tuning algorthm will be implemented.
正整数的数目的运行或次(每的num.iters迭代),将实施调整algorthm,。


参数:num.iters
Positive integer:  The number of iterations in each run of the tuning algorithm.
正整数:在每次运行调整算法的迭代。


参数:rho.vec
Vector of dimension I = number of contigency tables = number of rows in data: initial values of multipliers (usually in (0,1)) to the covariance matrix of the proposal distribution for the draws of the intermediate level parameters.  The purpose of this Tune function is to adjust these values so as to achieve acceptance ratios of between .2 and .5 in the MCMC draws of the THETAs.
矢量尺寸I数= contigency表中的行数data:初始值的乘数(通常是在(0,1))的建议分布的协方差矩阵的画的中间级别的参数。这Tune功能的目的是调整这些值,从而达到接受的比值在0.2和0.5之间的MCMC绘制的THETA的。


参数:kappa
Scalar:  The diagonal of the covariance matrix for the (normal) hyperprior distribution for the mu parameter.
标量:(正常)hyperpriormu参数分布的协方差矩阵的对角线。


参数:nu
Scalar:  The degrees of freedom for the (Inverse-Wishart) hyperprior distriution for the SIGMA parameter.
标量的自由度为SIGMA参数的的(反威沙特)hyperprior distriution的。


参数:psi
Scalar:  The diagonal of the matrix parameter of the (Inverse-Wishart) hyperprior distribution for the SIGMA parameter.
标量:对角线的矩阵参数(逆-威沙特的)hyperprior分布SIGMA参数。


参数:mu.vec.0
Vector:  mean of the (normal) hyperprior distribution for the mu parameter.
向量:指(正常)hyperprior的分布mu参数。


参数:mu.vec.cu
Vector of dimension R*(C-1), where R(C) is the number of rows(columns) in each contigency table:  Optional starting values for mu parameter.
向量的维R*(C-1),其中R(C)的行数(列)在每个contigency表:可选mu参数的初始值。


参数:nolocalmode
Positive integer:  How often an alternative drawing method for the contigency table internal cell counts will be used. Use of default value recommended.
正整数:多久为contigency表内部的单元计数的另一种绘图方法将被使用。使用默认值建议。


参数:sr.probs
Matrix of dimension I x R:  Each value represents the probability of selecting a particular contingency table's row as the row to be calculated deterministically in (product multinomial) proposals for Metropolis draws of the internal cell counts.  For example, if R = 3 and row 2 of position sr.probs = c(.1, .5, .4), then in the third contingency table (correspoding to the third row of data), the proposal algorithm for the interior cell counts will calculate the third contingency table's first row deterministically with probability .1, the second row with probability .5, and the third row with probability .4.  Use of default (generated internally) recommended.
维矩阵IXR:每个值代表的概率,选择一个特定的应变表的行,作为行计算确定性在(产品多项式)都市建议利用内部单元计数。例如,如果R = 3和第2行的位置sr.probs= C(0.1,0.5,0.4),然后在第三列联表(correspodingdata)到第三行,用于室内的单元计数,将计算出的第三应变表的第一行的建议算法确定性的概率为0.1的概率为0.5,,第二行和第三行的概率是0.4。建议使用默认值(内部产生)。


参数:sr.reps
Matrix of dimension I x R:  Each value represents the number of times the (product multinomial proposal) Metropolis algorithm will be attempted when, in drawing the internal cell counts, the proposal for the corresponding contingency table row is to be calculated deterministically.  sr.reps has the same structure as sr.probs, i.e., position [3,1] of sr.reps corresponds to the third contingency table's first row.  Use of default (generated internally) recommended.
矩阵的维IXR:每个值表示的次数(产品多项建议)Metropolis算法将尝试时,在制定内部的单元计数,相应的应急表行的建议是确定性计算。 sr.reps具有相同的结构,[3,1] sr.reps作为sr.probs,即,位置对应于第三列联表的第一行。建议使用默认值(内部产生)。


参数:numscans
Positive integer:  How often the algorithm to draw the contingency table internal cell counts will be implemented before new values of the other parameters are drawn.  Use of default value recommended.
正整数多久实施前的其他参数的新值的算法绘制列联表的内部单元计数绘制。使用默认值建议。


参数:Diri
Positive integer:  How often a product Dirichlet proposal distribution will be used to draw the contingency table row probability vectors (the THETAS).
正整数:往往是一个产品狄利克雷分配提案将被用于绘制列联表行的概率向量(THETAS)。


参数:dof
Positive integer:  The degrees of freedom of the multivariate t proposal distribution used in drawing the contingency table row probability vectors (the THETAS).
正整数:度自由的多元t的分配提案用于绘制列联表行的概率向量(THETAS)的。


参数:debug
Integer:  Akin to verbose in some packages.  If set to 1, certain status information (including rough notification regarding the number of iterations completed) will be written to the screen.
整数:类似于verbose的一些包。如果一定的状态信息(包括粗糙的通知,关于完成的反复数)设置为1,将被写入到屏幕上。


Details

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

TuneWithExitPoll is a necessary precursor function to AnalyzeWithExitPoll, the workhorse function in fitting the R x C ecological inference model described in Greiner & Quinn (2009) to ecological data augmented by data from surveys of some of the contingency tables.  Details and terminology of the basic (i.e., without a survey sample) data structure and ecological inference model are discussed in the documentation accompanying the Analyze function.  The purpose of TuneWithExitPoll, as prepatory to AnalyzeWithExitPoll, is the same as the purpose of Tune as prepatory to Analyze.  See the documentation for Tune for a full explanation.
TuneWithExitPoll是一个必要的先导功能,AnalyzeWithExitPoll,主力函数拟合的R X C生态,在格雷纳和奎因(2009)对生态数据的推理模型描述增强调查的一些数据列联表。 Analyze函数附带的文档中详细描述和术语的基本(即,没有调查样本)的数据结构和生态推理模型进行了讨论。的目的TuneWithExitPoll,AnalyzeWithExitPoll筹备的,相同目的,Tune作为筹备的Analyze。请参阅文档Tune更全面的解释。

In the present implementation, the AnalyzeWithExitPoll, and thus TuneWithExitPoll, presume that the survey consisted of a simple random sample from the in-sample contingency tables. Future implementations will allow incorporation of more complicated survey sampling schemes.
在目前的实现中,AnalyzeWithExitPoll,从而TuneWithExitPoll,假定该调查包括一个简单的随机抽样样本列联表。未来实现更复杂的抽样调查方案将允许成立。

The arguments to TuneWithExitPoll are essentially identical to those of Tune with the major exception of exitpoll.  exitpoll feeds the results of the survey sample to the function, and a particular format is required. Specifically, exitpoll must have the same number of rows as data, meaning one row for each contigency table in the dataset.  It must have R * C columns, meaning one column for each cell in one of the ecological data's contingency tables.  The first row of exitpoll must correspond to the first row of data, meaning that the two rows must contain information from the same contingency table.  The second row of exitpoll must contain information from the contingency table represented in the second row of data.  And so on.  Finally, exitpoll must have counts from the sample of the contingency table in vectorized row major format.
TuneWithExitPoll的参数到Tune主要的例外exitpoll基本上是相同的。 exitpoll并将结果在调查样本中的功能,和一个特定的格式要求。具体来说,exitpoll必须有相同的行数data,这意味着一列为每个contigency表的数据集。它必须有R * C列,这意味着一列中的每个单元的生态数据的列联表。的第一行exitpoll必须对应,这意味着两行的信息必须包含相同的应变表的第一行中data。第二排exitpoll必须包含的信息从列联表的data在第二行表示。等。最后,exitpoll必须有矢量化行的主要格式列联表中的样本计数。

To illustrate with a voting example:  Suppose the contingency tables have two rows, labeled bla and whi, and three columns, denoted Dem, Rep, and Abs. In other words, the fstring argument would be "Dem, Rep, Abs ~   bla, whi".  Suppose there are 100 contingency tables.  The data will be of dimension 100 \times 5, with each row consisting of the row and column totals from that particular contigency table. exitpoll will be of dimension 100 \times 6.  Row 11 of the exitpoll will consist of the following:  in position 1, the number of blacks voting Democrat observed in the sample of contingency table 11; in position 2, the number of blacks voting Republican observed in the sample of contigency table 11; in position 3, the number of blacks Abstaining from voting observed in the sample of contingency table 11; in position 4, the number of whites voting Democrat observed in the sample of contingency table 11; etc.
一个投票的例子来说明:假设应急表中有两行,标有喇嘛和WHI,三列,表示民主党,代表和ABS。换句话说,fstring参数是"Dem, Rep, Abs ~   bla, whi"。假设有100列联表。 data将维度100 \times 5,与每一行组成的从该特定contigency表中的行和列的总数。 exitpoll是的尺寸100 \times 6。 11排的exitpoll将包括以下内容:在位置1,黑人投票的民主党人列联表11中观察到的样本在位置2,黑人投票共和党中观察到的样本contigency表11,在位置3,黑人弃权投票观察样品中的列联表11的数量;在第4位,数的白人投票的民主党人列联表11中观察到的样本等。

For tables in which there was no sample taken (i.e., out-of-sample tables), the corresponding row of exitpoll should have a vector of 0s.
对于表中有没有样本(即样本表),相应的行exitpoll应该有一个向量的0。


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

A list with the following elements.
一个包含下列元素的列表。


参数:rhos
A vector of length I = number of contingency tables:  each element of the rhos vector is a multiplier used in the proposal distribution of for draws from the conditional posterior of the THETAs, as described above.  Feed this vector into the Analyze function.
长度的向量I=应变表数目:每个元素rhos向量是一个乘法器中使用的建议分布绘制从如上文所述的条件后验THETAs。饲料到Analyze函数向量。


参数:acc.t
Matrix of dimension I x num.runs:  Each column of acc.t contains the acceptance fractions for the Metropolis-Hastings algorithm, with a multivariate t_4 proposal distribution, used to draw from the conditional posterior of the THETAs.  If Tune has worked properly, all elements of the final column of this matrix should be between .2 and .5.
矩阵的维IXnum.runs:acc.t每一列包含了一个多变量t_4建议分布,接受分数的Metropolis-Hastings算法,用于绘制的条件后的THETA的。 Tune如果正常工作,这个矩阵的最后一列的所有元素应该是在0.2和0.5之间。


参数:acc.Diri
Matrix of dimension I x num.runs:  Each column of acc.t contains the acceptance fractions for the Metropolis-Hastings algorithm, with independent Dirichlet proposals, used to draw from the conditional posterior of the THETAs.  Tune does not alter this algorithm.
矩阵的维IXnum.runs:acc.t每一列包含接受分数的Metropolis-Hastings算法,具有独立的狄利克雷建议,用于绘制的条件后 X>。 THETA不改变这种算法。


参数:vld.NNs
A list of length num.runs:  Each element of vld.NNs is a matrix of dimension I by R, with each element of the list corresponding to one of the num.iters sets of iterations run by Tune.  To draw from the conditional posterior of the internal cell counts of a contigency table, the Tune function draws R-1 vectors of lenth C from multinomial distributions.  In then calculates the counts in the additional row (denote this row as r') deterministically.  This procedure can result in negative values in row r', in which case the overall proposal for the interior cell counts is outside the parameter space (and thus invalid). Each matrix of vld.NNs keeps track of the percentage of proposals drawn in this manner that are valid (i.e., not invalid).  Each row of such a matrix corresponds to a contingency table.  Each column in the matrix corresponds to a row in the a contingency table.  Each entry specifies the percentage of multinomial proposals that are valid when the specified contingency table row serves as the r' row.  For instance, in position 5,2 of vld.NNs is the fraction of valid proposals for the 5th contingency table when the second contigency table row is the r'th row.  A value of “NaN” means that Tune chose to use a different (slower) method of drawing the internal cell counts because it suspected that the multinomial method would behave badly.
的列表的长度num.runs:每个元件的vld.NNs是一个矩阵的维度I由R,与列表中的每个元素对应于其中的num.iters 运行Tune的迭代套。要绘制的内部单元计数的contigency表的条件后,Tune函数绘制R-1向量;长度ç多项式分布。在计算额外的行计数(R)表示该行确定的。此过程可以导致在行r,在这种情况下的整体方案的内部单元计数以外的参数空间(并因此是无效的)的负值。每个矩阵vld.NNs跟踪以这种方式得出的提案,是有效的(即,不无效)的百分比。这样的矩阵的每一行对应于一个应急表。在矩阵中的每一列联表中的行。每个条目指定的百分比是有效的多项建议,在指定的列联表行作为R行。例如,在位置5,2的vld.NNs是当所述第二contigency表行是rth行第五列联表的有效的建议的馏分。 “南”的值意味着Tune选择使用一个不同的(更慢)制定的内部单元计数的方法,因为它怀疑,多项式法的行为严重。


参数:acc.NNs
A list of length num.runs:  Same as vld.NNs, except the entries represent the fraction of proposals accepted (instead of the fraction that are in the permissible parameter space).
条目的列表的长度num.runs:vld.NNs相同,除了表示接受的提案(而不是,在允许的参数空间的馏分)的馏分。


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


D. James Greiner, Paul D. Baines, \& Kevin M. Quinn



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

Inference:  Bounds, Correlations, Flexibility, and Transparency of

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


## Not run: [#不运行:]
SimData <- gendata.ep()    #  simulated data[模拟数据]
FormulaString <- "Dem, Rep, Abs ~ bla, whi, his"
EPInvTune <-  TuneWithExitPoll(fstring = FormulaString,
                               data = SimData$GQdata,
                               exitpoll=SimData$EPInv$returnmat.ep,
                               num.iters = 10000,
                               num.runs = 15)

## End(Not run)[#(不执行)]

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-28 20:51 , Processed in 0.023835 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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