User Tools

Site Tools


en:history:2015-04-17-anadatr

2015-04-17 Constrained ordination and variation partitioning

anadatr17042015.R
# Forward selection - use of the function ordiR2step
 
# use data from Carpathian wetlands
vasc <- read.delim ('https://raw.githubusercontent.com/zdealveindy/anadat-r/master/data/vasc_plants.txt', row.names = 1)
chem <- read.delim ('https://raw.githubusercontent.com/zdealveindy/anadat-r/master/data/chemistry.txt', row.names = 1)
 
# test the significance of global model first
rda.all <- rda (vasc~. , data=chem)
anova (rda.all)
 
# define also null model (no explanatory variables, but formula interface)
rda.0 <- rda ( vasc~1, data=chem)
 
# use the function ordiR2step, similarly to ordistep
ordiR2step (rda.0, scope= formula (rda.all), direction= "forward")
 
 
# Variation partitioning using data about fertilization
# Data are in Excel file: http://regent.prf.jcu.cz/maed2/, Chapter 14, zip file
 
# import data via clipboard from Excel file (alternatively http://www.davidzeleny.net/anadat-r/doku.php/en:data:barley)
fert.spe <- read.delim ('clipboard', row.names = 1)
fert.env <- read.delim ('clipboard', row.names = 1)
 
names (fert.env)
rda.all <- rda (fert.spe ~ dose + cover, data = fert.env)
varpart (fert.spe, ~dose, ~cover, data = fert.env )
 
rda.dose <- rda ( fert.spe ~ dose, data = fert.env)
rda.cover <- rda (fert.spe ~ cover, data = fert.env)
rda.dose.cover <- rda (fert.spe ~ dose + Condition (cover), data = fert.env)
rda.cover.dose <- rda (fert.spe ~ cover + Condition (dose), data = fert.env)
 
anova (rda.all)
anova (rda.dose)
anova (rda.cover)
anova (rda.dose.cover)
anova (rda.cover.dose)
 
ordiplot (rda.all, display = c('sites', 'cn'), type = 't')
 
# Example for RDA and MC permutation test - experiment with seedlings
seed.spe <- read.delim ('https://raw.githubusercontent.com/zdealveindy/anadat-r/master/data/seedl-spe.txt', row.names = 1)
seed.env <- read.delim ('https://raw.githubusercontent.com/zdealveindy/anadat-r/master/data/seedl-env.txt', row.names = 1)
 
# use DCA to check whether to apply linear or unimodal ordination method
decorana (seed.spe)  # short first axis - RDA
 
# specify RDA model using formula interface, block should be factor (not quantitative), and used as covariable
rda.seed <- rda(seed.spe ~ treatment + Condition (as.factor(block)), data=seed.env)
rda.seed
 
# Model based test of significance
anova(rda.seed)
 
ordiplot (rda.seed, type= "t")
en/history/2015-04-17-anadatr.txt · Last modified: 2018/03/30 23:04 (external edit)