test_cwm: Testing the relationship between weighted-mean of species... In zdealveindy/weimea: Weighted Mean Analysis

Description

Function calculating relationship between weighted-mean of species attributes and sample attributes and performing standard (row based), modified (column based), or max test of significance.

Usage

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15``` ```test_cwm(cwm, env, method = c("cor"), wcor = FALSE, wstand = FALSE, wreg = NULL, dependence = "cwm ~ env", perm = 499, test = "max", parallel = NULL, p.adjust.method = "holm", adjustP = FALSE) ## S3 method for class 'testCWM' print(x, digits = max(3, getOption("digits") - 3), missing.summary = FALSE, adjustP = FALSE, eps.Pvalue = 0.001, ...) ## S3 method for class 'testCWM' coef(object, ...) ## S3 method for class 'testCWM' plot(x, alpha = 0.05, line = NA, cex.lab = 1.5, par.mar = c(0.5, 0.5, 0.5, 0.5), box.col = c("blue", "red"), box.lwd = 2, ...) ```

Arguments

 `cwm` An object of the class `cwm`. `env` Vector or matrix with variables. See details. `method` Statistical method used to analyse the relationship between cwm (of class `cwm`) and env (sample attributes); partial match to `'cor'`, `'lm'` and `'aov'`. `wcor` Logical; should the correlation be weighted by rowsums of `com` (extracted from `cwm`?). Default `FALSE`. `wstand` Logical; should the variables in correlation be first weighted-standardized? Default `FALSE`. If `wstand = TRUE`, both `env` and `traits` are weighted standardized prior to calcuation; weights are derived from `com` matrix (extracted from `cwm`); `env` is weighted by rowsums of `com`, while `traits` are weighted by colsums of `com`. `wreg` `NULL` (default) or numeric vector of weights used in regression (`method = 'lm'`). If weights are provided, weighted least squares are calculated instead of ordinary least squares. `dependence` Should `cwm` be dependent variable and `env` independent (`'cwm ~ env'`), or opposite? Applicable only for `method = 'lm'`. Partial match to `'cwm ~ env'` and `'env ~ cwm'`. `perm` Number of permutations. `test` Vector of character values. Which test should be conducted? Partial match to `'standard'` or `'rowbased'` for standard (row based) permutation test, `'modified'` or `'colbased'` for modified (column based) permutation test, `'max'` for max test (selecting the higher from `rowbased` and `colbased` result), and `'all'` including all three tests. See `Details`. `parallel` NULL (default) or integer number. Number of cores for parallel calculation of modified permutation test. Maximum number of cores should correspond to number of available cores on the processor. `p.adjust.method` A string indicating the method of P-value adjustement, see `p.adjust.methods` for possible choices. `adjustP` Logical, default FALSE. Should be the P-values adjusted? If `adjustP = TRUE`, the last column in the results is adjusted by method selected in `p.adjust.method`. `x, object` object of the class `"cwm"`, generated by function `cwm`. `digits` number of digits reported by `print` method on object of `"cwm"` class (default is 3). `missing.summary` Logical; should be the summary of values missing in `env`, `cwm` and `traits` be printed along to the result of `test_cwm` analysis? Default is `TRUE`. `eps.Pvalue` Values of P below this threshold will be printed as `< [eps]` in the output. `...` Other arguments for `print`, `summary`, `coef` or `plot` functions (some not implemented yet). `alpha, line, cex.lab, par.mar, box.col, box.lwd` Graphical parameters for `plot` function.

Details

Currently implemented statistical methods: `'cor'`. Plan to implement also: `'lm'` and `'aov'`. For fourth corner, please use `test_fourth`.

Argument `env` can be vector or matrix with one column. Only in the case of linear regression (`method = 'lm'`) it is possible to use matrix with several variables, which will all be used as independent variables in the model. For ANOVA and Kruskal-Wallis test, make sure that 'env' is `factor` (warning will be returned if this is not the case, but the calculation will be conducted).

Difference between `method = 'lm'` and `'aov'` is in the format of summary tables, returned by `summary.cwm` function. In case of 'aov', this summary is expressed in the traditional language of ANOVA rather than linear models.

Both `method = 'lm'` and `'slope'` are based on linear regression and calculated by function `lm`, but differ by test statistic: while 'lm' is using F value and is testing the strength of the regression (measured by r2), 'slope' is using the slope of the regression line (b). This statistic is added here for comparison with the fourth corner method.

Specific issue related to weighted mean is the case of missing species attributes. In current implementation, species with missing species attributes are removed from sample x species matrix prior to permutation of species attributes among species.

Value

Function `cwm` returns list of the class `"cwm"` (with `print` and `summary` methods), which contains the following components:

• `call` Call to the function.

• `out` Matrix with analysis results (coefficients, statistics, P-values).

• `miss` Matrix with counts of missing values in `env`, `cwm` and `traits`.

• `param` List with the setting of the function parameters (arguments).

`cwm`, `snc`
 ```1 2 3 4 5``` ```data (vltava) CWM <- cwm (com = vltava\$herbs\$spe, traits = vltava\$herbs\$traits) re <- test_cwm (cwm = CWM, env = vltava\$env[,c('pH', 'COVERE32')]) re plot (re) ```