Analysing a randomised complete block design with vegan
It has been a long time coming. Vegan now has in-built, native ability to use restricted permutation designs when testing effects in constrained ordinations and in range of other methods. This new-found functionality comes courtesy of Jari (mainly) and my efforts to have vegan permutation routines use the permute package. Jari also cooked up a standard interface that we can use to drop this and some extra features neatly into any function we want; this allows us to have permutation tests run on many CPU cores in parallel, splitting the computational burden and reducing the run time of tests, and also a mechanism that allows users to pass a matrix of user-defined permutations to be used in tests. These new features are now fully working in the development version of vegan, which you can find on github, and which should be released to CRAN shortly. Ahead of the release, I’m preparing some examples to show off the new capabilities; first off I look at data from a randomized, complete block design experiment analysed using RDA & restricted permutations.
To follow this example locally you’ll need to have version 2.1-43 or later of vegan installed. You can grab the sources from github and build it yourself, or grab a Windows binary from the Appveyor Continuous integration service that we’re using to test on that platform — you want the .zip
file from the Artefacts. Once you’ve sorted out the installation, we can begin.
We’ll need gdata, and its read.xls()
function, to read from the XLS format files that the data for the example come as.
The data set itself is quite simple and small, consisting of counts on 23 species from 16 plots, and arise from a randomised complete block designed experiment described by Špačková and colleagues (1998) and analysed by (Šmilauer and Lepš, 2014) in their recent book using Canoco v5.
The experiment tested the effects on seedling recruitment to a range of treatments
- control
- removal of litter
- removal of the dominant species Nardus stricta
- removal of litter and moss (mos couldn’t be removed without also removing litter)
The treatments were replicated replicated in four, randomised complete blocks.
The data are available from the accompanying website to the book Multivariate Analysis of Ecological Data using CANOCO 5 (Šmilauer and Lepš, 2014). They are supplied as XLS format files in a ZIP archive. We can read these into R directly from the website with a little bit of effort
The block
variable is currently coded as an integer and needs converting to a factor if we are to use it correctly in the analysis
The gradient lengths are short,
motivating the use of redundancy analysis (RDA). Additionally, we may be interested in how the raw abundance of seedlings change following experimental manipulation, o we may wish to focus on the proportional differences between treatments. The first case is handled naturaly by RDA. The second case will require some form of standardisation by samples, say by sample totals.
First, let’s test the first null hypothesis; that there is no effect of the treatment on seedling recruitment. This is a simple RDA. We should take into account the block
factor when we assess this model for significance. How we do this illustrates two potential approaches to performing permutation tests
design-based permutations, where how the samples are permuted follows the experimental design, or
model-based permutations, where the experimental design is included in the analysis directly and residuals are permuted by simple randomisation.
There is an important difference between the two approach, one which I’ll touch on shortly.
We’ll proceed by fitting the model, conditioning on block
to remove between block differences
There is a strong single, linear gradient in the data as evidenced by the relative magnitudes of the eigenvalues (here expressed as proportions of the total variance)
Design-based permutations
A design-based permutation test of these data would be on conditioned on the block
variable, by restricting permutation of sample only within the levels of block
. In this situation, samples are never permuted between blocks, only within. We can set up this type of permutation design as follows
Note that we could use the plots
argument instead of blocks
to restrict the permutations in the same way, but using blocks
is simpler. I also set the required number of permutations for the test here.
Constrained ordinations in vegan are tested using the anova()
function. New in the development version of the package is the permutations
argument, which is the key to supplying instructions on how you want to permute to anova()
. permutations
can take a number of different types of instruction
an object of class
"how"
, whch contains details of a restricted permutation design thatshuffleSet()
from the permute package will use to generate permutations from, ora number indicating the number of permutations required, in which case these are simple randomisations with no restriction, unless the
strata
argument is used, ora matrix of user-specified permutations, 1 row per permutation.
To perform the design-based permutation we’ll pass h
, created earlier, to anova()
Note that I’ve run this on three cores in parallel; this is another new feature of the development version of vegan and can considerably reduce the time needed to run permutation tests. I have four cores on my laptop but left one free for the other software I have running.
The overall permutation test indicates no significant effect of treatment on the abundance of seedlings. We can test individual axes by adding by = "axis"
to the anova()
call
This confirms the earlier impression that there is a single, linear gradient in the data set. A biplot shows that this axis of variation is associated with the Moss (& Litter) removal treatment. The variation between the other treatments lies primarily along axis two and is substantially less than that associated with the Moss & Litter removal.
In the above figure, I used scaling = 1
, so-called inter-sample distance scaling, as this best represents the centroid scores, which are computed as the treatment-wise average of the sample scores.
Model-based permutation
The alternative permutation approach, known as model-based permutations, and would employ free permutation of residuals after the effects of the covariables have been accounted for. This is justified because under the null hypothesis, the residuals are freely exchangeable once the effects of the covariables are removed. There is a clear advantage of model-based permutations over design-based permutations; where the sample size is small, as it is here, there tends to be few blocks and the resulting design-based permutation test relatively weak compared to the model-based version.
It is simple to switch to model-based permutations, be setting the blocks indicator in the permutation design to NULL
, removing the blocking structure from the design
Next we repeat the permutation test using the modified h
The estimated p value is slightly smaller now. The difference between treatments is predominantly in the Moss & Litter removal with differences between the control and the other treatments lying along the insignificant axes
Chages in relative seedling composition
As mentioned earlier, interest is also, perhaps predominantly, in whether any of the treatments have different species composition. To test this hypothesis we standardise by the sample (row) norm using decostand()
. Alternatively we could have used method = "total"
to work with proportional abundances. We then repeat the earlier steps, this time using only model-based permutations owing to their greater power.
The results suggest no difference in species composition under the experimental manipulation.
That’s it for this post. In the next example I’ll take a look at a more complex example, one where model-based permutations can’t be used to test all the hypotheses we might want to in an experimental design.
References
Šmilauer, P., and Lepš, J. (2014). Multivariate analysis of ecological data using CANOCO 5. 2 edition. Cambridge University Press.
Špačková, I., Kotorová, I., and Lepš, J. (1998). Sensitivity of seedling recruitment to moss, litter and dominant removal in an oligotrophic wet meadow. Folia geobotanica 33, 17–30. doi:10.1007/BF02914928.