data(dune)
data(dune.env)
## Automatic model building based on AIC but with permutation tests
step(cca(dune ~ 1, dune.env), reformulate(names(dune.env)), test="perm")
## see ?ordistep to do the same, but based on permutation P-values
ordistep(cca(dune ~ 1, dune.env), reformulate(names(dune.env)), perm.max=200)
## Manual model building
## -- define the maximal model for scope
mbig <- rda(dune ~ ., dune.env)
## -- define an empty model to start with
m0 <- rda(dune ~ 1, dune.env)
## -- manual selection and updating
add1(m0, scope=formula(mbig), test="perm")
m0 <- update(m0, . ~ . + Management)
add1(m0, scope=formula(mbig), test="perm")
m0 <- update(m0, . ~ . + Moisture)
## -- included variables still significant?
drop1(m0, test="perm")
add1(m0, scope=formula(mbig), test="perm")
Run the code above in your browser using DataLab