spca_randtest: Monte Carlo test for sPCA

Description Usage Arguments Value Author(s) Examples

View source: R/spca_randtest.R

Description

The function spca_randtest implements Monte-Carlo tests for the presence of significant spatial structures in a sPCA object. Two tests are run, for global (positive autocorrelation) and local (negative autocorrelation) structures, respectively. The test statistics used are the sum of the absolute values of the corresponding eigenvalues.

Usage

1
spca_randtest(x, nperm = 499)

Arguments

x

A spca object.

nperm

The number of permutations to be used for the test.

Value

A list with two objects of the class 'randtest' (see as.randtest), the first one for 'global' structures (positivie autocorrelation) and the second for 'local' structures (negative autocorrelation).

Author(s)

Original code by Valeria Montano adapted by Thibaut Jombart.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
## Load data
data(sim2pop)

## Make spca
spca1 <- spca(sim2pop, type = 1, scannf = FALSE, plot.nb = FALSE)

spca1
plot(spca1)

## run tests (use more permutations in practice, e.g. 999)
tests <- spca_randtest(spca1, nperm = 49)

## check results
tests
plot(tests[[1]]) # global structures


## End(Not run)

adegenet documentation built on Oct. 10, 2021, 1:09 a.m.