Skip to contents

Plots the result of one of ecodive's permutation tests. By default, permanova(), anosim(), mantel() and mantel_partial() results show the permutation distribution of their statistic, with the observed value marked; mrpp() shows each group's mean within-group distance; permdisp() each group's dispersion; and procrustes_test() the Procrustes fit. type = "null" shows the permutation distribution for any of them. Nothing is recomputed: the plot is made from the stored results.

Usage

# S3 method for class 'ecodive_test'
plot(x, type = "null", ...)

# S3 method for class 'ecodive_mrpp'
plot(x, type = c("groups", "null"), ...)

# S3 method for class 'ecodive_permdisp'
plot(x, type = c("groups", "null"), ...)

# S3 method for class 'ecodive_procrustes_test'
plot(x, type = c("fit", "null"), ...)

Arguments

x

A permutation test result, of class ecodive_test: from permanova(), anosim(), mrpp(), mantel(), mantel_partial(), permdisp(), procrustes_test(), or dist_test().

type

What to draw: "null" for the permutation distribution of the statistic; or for mrpp() and permdisp(), "groups" (their default) for a bar for each group; or for procrustes_test(), "fit" (its default) for the Procrustes rotation, drawn by plot.ecodive_ord().

...

Passed on to the plotting function: graphics::hist() for "null", graphics::barplot() for "groups", and plot.ecodive_ord() for "fit". Such as main, sub, xlab, col or breaks; they replace the defaults made from x.

Value

x, invisibly.

Details

The title is the test's title (see ecodive_display): its name, and the metric of the distances it tested, as printed. The subtitle is its statistic, p-value and standardized effect size \(z\), as printed.

  • "null": a histogram of the statistic in each permutation (the f_perm, r_perm or delta_perm attribute), with a line at the observed statistic. The p-value is the proportion of permutations, with the observed one, at least as extreme as the observed statistic. It needs a test run with permutations above 0.

  • "groups" for mrpp(): the mean within-group distance of each group (class_delta), with lines at the observed \(\delta\) (their weighted mean) and the \(\delta\) expected by chance (expected_delta, the mean of all distances).

  • "groups" for permdisp(): each group's mean distance to its centroid or median (dispersions).

  • "fit" for procrustes_test(): the symmetric Procrustes rotation it tested (its procrustes field), with an arrow from each sample to the target ordination.

Examples

    dm <- bray(iris[, 1:4])

    # The pseudo-F of each permutation, and the observed F.
    res <- permanova(dm, 'Species', iris, permutations = 199)
    plot(res)


    # MRPP: each species' mean within-group distance.
    res <- mrpp(dm, 'Species', iris, permutations = 199)
    plot(res)

    plot(res, type = 'null')


    # PERMDISP: the dispersion of each species.
    plot(permdisp(dm, 'Species', iris, permutations = 199))
#> Warning: Some squared distances to group centres are negative, and were set to 0.


    # PROTEST: the Procrustes fit of two ordinations.
    res <- procrustes_test(pcoa(dm, n_axes = 2), pca(iris[, 1:4], n_axes = 2))
    plot(res)