permat(vegan)
permat()所属R语言包:vegan
Matrix Permutation Algorithms for Presence-Absence and Count Data
矩阵排列的算法存在不存在和计数资料
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Individual (for count data) or incidence (for presence-absence data) based null models can be generated for community level simulations. Options for preserving characteristics of the original matrix (rows/columns sums, matrix fill) and restricted permutations (based on strata) are discussed in the
个人(适用于计数数据)或发病率存在不存在数据的零模型可以产生社区一级的模拟。在保持原矩阵(行/列求和,矩阵填充)及受限制排列(根据地层)的特点进行了讨论选项
用法----------Usage----------
permatfull(m, fixedmar = "both", shuffle = "both", strata = NULL,
mtype = "count", times = 99)
permatswap(m, method = "quasiswap", fixedmar="both", shuffle = "both",
strata = NULL, mtype = "count", times = 99, burnin = 0, thin = 1)
## S3 method for class 'permat'
print(x, digits = 3, ...)
## S3 method for class 'permat'
summary(object, ...)
## S3 method for class 'summary.permat'
print(x, digits = 2, ...)
## S3 method for class 'permat'
plot(x, type = "bray", ylab, xlab, col, lty,
lowess = TRUE, plot = TRUE, text = TRUE, ...)
## S3 method for class 'permat'
lines(x, type = "bray", ...)
## S3 method for class 'permat'
as.ts(x, type = "bray", ...)
## S3 method for class 'permat'
as.mcmc(x)
参数----------Arguments----------
参数:m
A community data matrix with plots (samples) as rows and species (taxa) as columns.
一个社区图(样本)数据矩阵的行和列的品种(类群)。
参数:fixedmar
character, stating which of the row/column sums should be preserved ("none", "rows", "columns", "both").
字符,说明应该保留的行/列和("none", "rows", "columns", "both")。
参数:strata
Numeric vector or factor with length same as nrow(m) for grouping rows within strata for restricted permutations. Unique values or levels are used.
数字nrow(m)层内分组行的受限制的排列相同长度的向量或因子。唯一值或水平使用。
参数:mtype
Matrix data type, either "count" for count data, or "prab" for presence-absence type incidence data.
矩阵数据类型,是"count"用于计数数据,或"prab"存在缺如型的发病率数据。
参数:times
Number of permuted matrices.
置换矩阵的数量。
参数:method
Character for method used for the swap algorithm ("swap", "tswap", "quasiswap", "backtrack") as described for function commsimulator. If mtype="count" the "quasiswap", "swap", "swsh" and "abuswap" methods are available (see details).
字符为交换算法("swap","tswap","quasiswap","backtrack")所描述的功能commsimulator的使用方法。如果mtype="count""quasiswap","swap","swsh"和"abuswap"方法是可用的(见详情)。
参数:shuffle
Character, indicating whether individuals ("ind"), samples ("samp") or both ("both") should be shuffled, see details.
字符,这表明无论是个人("ind"),样品("samp")或两者("both")应洗牌,查看详情。
参数:burnin
Number of null communities discarded before proper analysis in sequential ("swap", "tswap") methods.
正确的分析顺序("swap", "tswap")方法之前丢弃的空社区的数量。
参数:thin
Number of discarded permuted matrices between two evaluations in sequential ("swap", "tswap") methods.
数丢弃的置换矩阵之间的顺序("swap", "tswap")方法的评估。
参数:x, object
Object of class "permat"
对象的类"permat"
参数:digits
Number of digits used for rounding.
用于四舍五入的数字。
参数:ylab, xlab, col, lty
graphical parameters for the plot method.
图形参数为plot方法。
参数:type
Character, type of plot to be displayed: "bray" for Bray-Curtis dissimilarities, "chisq" for Chi-squared values.
字符,请键入要显示的图:"bray"布雷柯蒂斯相异,"chisq"卡方值。
参数:lowess, plot, text
Logical arguments for the plot method, whether a locally weighted regression curve should be drawn, the plot should be drawn, and statistic values should be printed on the plot.
逻辑参数plot方法,是否应制定一个局部加权回归曲线,该图应制定,并在图上应印有统计值。
参数:...
Other arguments passed to methods.
其他参数传递给方法。
Details
详细信息----------Details----------
The function permatfull is useful when matrix fill is allowed to vary, and matrix type is count. The fixedmar argument is used to set constraints for permutation. If none of the margins are fixed, cells are randomised within the matrix. If rows or columns are fixed, cells within rows or columns are randomised, respectively. If both margins are fixed, the r2dtable function is used that is based on Patefield's (1981) algorithm. For presence absence data, matrix fill should be necessarily fixed, and permatfull is a wrapper for the function commsimulator. The r00, r0, c0, quasiswap algorithms of commsimulator are used for "none", "rows", "columns", "both" values of the fixedmar argument, respectively
的功能permatfull是有用的,当基质填充改变,和矩阵类型是count。 fixedmar参数是用来设置限制的置换。如果none的利润是固定的,单元被随机矩阵内。如果rows或columns是固定的,单元内的行或列是随机的,。是固定的,如果both边距用于r2dtable函数]是基于Patefield(1981)的算法。存在缺乏数据,矩阵填充一定是固定的,和permatfull是一个包装的功能commsimulator。 r00, r0, c0, quasiswap算法commsimulator"none", "rows", "columns", "both" fixedmar参数值,分别用于
The shuffle argument only have effect if the mtype = "count" and permatfull function is used with "none", "rows", "columns" values of fixedmar. All other cases for count data are individual based randomisations. The "samp" and "both" options result fixed matrix fill. The "both" option means that individuals are shuffled among non zero cells ensuring that there are no cell with zeros as a result, then cell (zero and new valued cells) are shuffled.
shuffle参数生效,如果mtype = "count"和permatfull函数"none", "rows", "columns"值的fixedmar的使用的。所有其他情况下,用于计数数据是个人基于随机化。 "samp"和"both"选项固定矩阵填写。 "both"选项装置,个人混洗在非零单元中确保有结果没有单元与零的,那么单元(零和新值的单元)的混洗。
The function permatswap is useful when with matrix fill (i.e. the proportion of empty cells) and row/columns sums should be kept constant. permatswap uses different kinds of swap algorithms, and row and columns sums are fixed in all cases. For presence-absence data, the swap and tswap methods of commsimulator can be used. For count data, a special swap algorithm ('swapcount') is implemented that results in permuted matrices with fixed marginals and matrix fill at the same time.
函数permatswap是有用时,矩阵填充(即空单元格的比例)和行/列的款项应保持不变。 permatswap在所有情况下使用不同的交换算法,以及行和列的总和是固定的。对于存在不存在数据,swap和tswapcommsimulator方法可以使用。用于计数数据的一个特殊的交换算法(swapcount)来实现,在具有固定的勉强和矩阵的置换矩阵的结果填写在同一时间。
The 'quasiswapcount' algorithm (method="quasiswap" and mtype="count") uses the same trick as Carsten Dormann's swap.web function in the package bipartite. First, a random matrix is generated by the r2dtable function retaining row and column sums. Then the original matrix fill is reconstructed by sequential steps to increase or decrease matrix fill in the random matrix. These steps are based on swapping 2x2 submatrices (see 'swapcount' algorithm for details) to maintain row and column totals. This algorithm generates independent matrices in each step, so burnin and thin arguments are not considered. This is the default method, because this is not sequential (as swapcount is) so independence of subsequent matrices does not have to be checked.
卡斯滕·杜曼的method="quasiswap"函数的quasiswapcount“的算法(mtype="count"和swap.web)的使用同样的伎俩,在包bipartite。首先,将所产生的随机矩阵r2dtable函数保留的行和列和。然后,在原始矩阵中填充重建通过顺序步骤,以增加或减少填写随机矩阵的矩阵。这些步骤是基于2×2子矩阵(见“swapcount算法的详细信息)交换,以保持行和列的数量。该算法生成独立的矩阵中的每一个步骤,所以burnin和thin参数不考虑。这是默认的方法,因为这是不连续的(swapcount是),所以随后的矩阵的独立性没有进行检查。
The swapcount algorithm (method="swap" and mtype="count") tries to find 2x2 submatrices (identified by 2 random row and 2 random column indices), that can be swapped in order to leave column and row totals and fill unchanged. First, the algorithm finds the largest value in the submatrix that can be swapped (d) and whether in diagonal or antidiagonal way. Submatrices that contain values larger than zero in either diagonal or antidiagonal position can be swapped. Swap means that the values in diagonal or antidiagonal positions are decreased by d, while remaining cells are increased by d. A swap is made only if fill doesn't change. This algorithm is sequential, subsequent matrices are not independent, because swaps modify little if the matrix is large. In these cases many burnin steps and thinning is needed to get independent random matrices. Although this algorithm is implemented in C, large burnin and thin values can slow it down considerably. WARNING: according to simulations, this algorithm seems to be biased and non random, thus its use should be avoided!
swapcount的算法(method="swap"和mtype="count")的尝试,以2×2子矩阵(确定的2的随机行和2个随机列索引),可换为了留下列和行的总和并填写不变。首先,算法发现可换(d),以及是否在对角线或antidiagonal的方式的子矩阵中的最大值。包含在任一的对角线或antidiagonal位置的值大于零的子矩阵可以调换。交换意味着在对角线或antidiagonal位置的值被减少了d的,而剩余的单元增加d。交换时,如果填充不会改变。这个算法是按顺序进行的,后续的矩阵是不是独立的,因为掉期修改一点如果矩阵是大。在这种情况下,许多燃尽的步骤和细化,需要得到独立的随机矩阵。虽然这种算法是用C实现的,大燃尽的和薄的值可以减缓下来相当。警告:根据模拟,这种算法似乎是有偏见和非随机的,因此它应避免使用!
The algorithm "swsh" in the function permatswap is a hybrid algorithm. First, it makes binary quasiswaps to keep row and column incidences constant, then non-zero values are modified according to the shuffle argument (only "samp" and "both" are available in this case, because it is applied only on non-zero values).
该算法"swsh"中的功能permatswap是一个混合算法。首先,它使二进制quasiswaps以行和列的发生率保持恒定,然后非零值被修改根据shuffle参数(仅"samp"和"both"的是在这种情况下,因为它被施加仅在非零值)。
The algorithm "abuswap" produces two kinds of null models (based on fixedmar="columns" or fixedmar="rows") as described in Hardy (2008; randomization scheme 2x and 3x, respectively). These preserve column and row occurrences, and column or row sums at the same time.
该算法"abuswap"产生两种零模型(基于fixedmar="columns"或fixedmar="rows")在哈代(2008;随机化计划的2倍和3倍,分别)。这些保留的行和列的事件,并同时列或行的款项。
Constraints on row/column sums, matrix fill, total sum and sums within strata can be checked by the summary method. plot method is for visually testing the randomness of the permuted matrices, especially for the sequential swap algorithms. If there are any tendency in the graph, higher burnin and thin values can help for sequential methods. New lines can be added to existing plot with the lines method.
summary方法可以检查约束,矩阵的行/列金额填充,总金额和款项层内。 plot方法是用于视觉测试的置换矩阵的随机性,尤其是对的顺序交换算法。如果图中的任何倾向,较高的burnin和thin值可以帮助序贯法。新的生产线,可以添加到现有的图与lines方法。
Unrestricted and restricted permutations: if strata is NULL, functions perform unrestricted permutations. Otherwise, it is used for restricted permutations. Each strata should contain at least 2 rows in order to perform randomization (in case of low row numbers, swap algorithms can be rather slow). If the design is not well balanced (i.e. same number of observations within each stratum), permuted matrices may be biased because same constraints are forced on submatrices of different dimensions. This often means, that the number of potential permutations will decrease with their dimensions. So the more constraints we put, the less randomness can be expected.
不受限制和受限制的排列:如果strata NULL,功能进行无限制的排列。否则,它被用于限制排列。每个阶层应含有至少2个中的行,以执行随机化(在低的行数的情况下,交换算法可以是相当慢)。如果设计不均衡(即相同的若干意见各阶层内),置换矩阵可能失之偏颇,因为同样的限制而被迫不同尺寸的子矩阵。这通常意味着,潜在的排列的数目将与它们的尺寸减小。因此,我们把更多的约束,随机性可以预期的。
The plot method is useful for graphically testing for trend and independence of permuted matrices. This is especially important when using sequential algorithms ("swap", "tswap", "abuswap").
plot方法是有用的图形化测试的趋势和置换矩阵的独立性。这是特别重要的,当使用顺序算法("swap", "tswap", "abuswap")。
The as.ts method can be used to extract Bray-Curtis dissimilarities or Chi-squared values as time series. This can further used in testing independence (see Examples). The method as.mcmc is useful for accessing diagnostic tools available in the coda
as.ts方法可用于提取布雷柯蒂斯相异或卡方值时间序列。这可以进一步在测试独立使用(见实施例)。的方法as.mcmc是有用的诊断工具,可在coda访问
值----------Value----------
Functions permatfull and permatswap return an object of class "permat" containing the the function call (call), the original data matrix used for permutations (orig) and a list of permuted matrices with length times (perm).
功能permatfull和permatswap返回一个对象类"permat"包含的函数调用(call),用于置换的原始数据矩阵(orig)置换矩阵的列表长度times(perm)。
The summary method returns various statistics as a list (including mean Bray-Curtis dissimilarities calculated pairwise among original and permuted matrices, Chi-square statistics, and check results of the constraints; see Examples). Note that when strata is used in the original call, summary calculation may take longer.
summary方法返回的各种统计数据的列表(包括平均布雷柯蒂斯相异的计算两两之间的原件和置换矩阵,卡方统计量,并检查结果的约束,见示例)。请注意,当strata概览计算中使用的原始呼叫,可能需要更长的时间。
The plot creates a plot as a side effect.
plot创建一个图的副作用。
The as.ts method returns an object of class "ts".
as.ts方法返回一个对象的类"ts"。
(作者)----------Author(s)----------
P茅ter S贸lymos,
<a href="mailto:solymos@ualberta.ca">solymos@ualberta.ca</a> and Jari Oksanen
参考文献----------References----------
given on help page of <code>commsimulator</code>.
local communities: statistical performances of different null models and test statistics on a locally neutral community. Journal of Ecology 96, 914–926.
generating r x c tables with given row and column totals. Applied Statistics 30, 91–97.
参见----------See Also----------
For other functions to permute matrices: commsimulator, r2dtable, sample, swap.web.
对于其它功能,重排矩阵:commsimulator,r2dtable,sample,swap.web。
For the use of these permutation algorithms: oecosimu, adipart, hiersimu.
对于使用这些置换算法:oecosimu,adipart,hiersimu。
For time-series diagnostics: Box.test, lag.plot, tsdiag, ar,
时间序列诊断:Box.test,lag.plot,tsdiag,ar,
实例----------Examples----------
## A simple artificial community data matrix.[#一个简单的人工群落数据矩阵。]
m <- matrix(c(
1,3,2,0,3,1,
0,2,1,0,2,1,
0,0,1,2,0,3,
0,0,0,1,4,3
), 4, 6, byrow=TRUE)
## Using the quasiswap algorithm to create a [#使用quasiswap的算法,创建一个]
## list of permuted matrices, where[#列表置换矩阵,其中]
## row/columns sums and matrix fill are preserved:[#行/列金额及基质填充将被保留:]
x1 <- permatswap(m, "quasiswap")
summary(x1)
## Unrestricted permutation retaining[#无限制的排列保留]
## row/columns sums but not matrix fill:[#行/列的款项,但不矩阵填充:]
x2 <- permatfull(m)
summary(x2)
## Unrestricted permutation of presence-absence type[#无限制的排列存在不存在]
## not retaining row/columns sums:[#不保留行/列金额:]
x3 <- permatfull(m, "none", mtype="prab")
x3$orig ## note: original matrix is binarized![#注:原矩阵进行二值化!]
summary(x3)
## Restricted permutation,[#限制排列,]
## check sums within strata:[#检查层内的款项:]
x4 <- permatfull(m, strata=c(1,1,2,2))
summary(x4)
## NOTE: 'times' argument usually needs to be >= 99[#注:“时代”的说法,通常需要> = 99]
## here much lower value is used for demonstration[#这里要低得多值用于演示]
## Not sequential algorithm[#不连续的算法]
data(BCI)
a <- permatswap(BCI, "quasiswap", times=19)
## Sequential algorithm[#顺序算法]
b <- permatswap(BCI, "abuswap", fixedmar="col",
burnin=0, thin=100, times=19)
opar <- par(mfrow=c(2,2))
plot(a, main="Not sequential")
plot(b, main="Sequential")
plot(a, "chisq")
plot(b, "chisq")
par(opar)
## Extract Bray-Curtis dissimilarities[#提取布雷柯蒂斯相异。]
## as time series[#随着时间的系列]
bc <- as.ts(b)
## Lag plot[#滞积]
lag.plot(bc)
## First order autoregressive model[#一阶自回归模型]
mar <- arima(bc, c(1,0,0))
mar
## Ljung-Box test of residuals[#的Ljung盒测试的残差]
Box.test(mar$residuals)
## Graphical diagnostics[#图形诊断]
tsdiag(mar)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|