[R-sig-eco] ordiR2step() does not add variables
Ralf Schäfer
senator at ecotoxicology.de
Mon Jan 30 16:13:20 CET 2017
Dear all,
we encountered a problem with vegan::ordiR2step() with the RIKZ data set of Analysing ecological data.
We have posted this on SO, but may be of interest to several people on this list.
http://stackoverflow.com/questions/41937957/veganordir2step-doesnt-find-best-fit-model
Reproducible example:
library(vegan)
# data
RIKZ <- read.table("http://www.uni-koblenz-landau.de/en/campus-landau/faculty7/environmental-sciences/landscape-ecology/Teaching/RIKZ_data/at_download/file", header = TRUE)
# data preparation
Species <- RIKZ[ ,2:5]
ExplVar <- RIKZ[ , 9:15]
Species_fin <- Species[ rowSums(Species) > 0, ]
ExplVar_fin <- ExplVar[ rowSums(Species) > 0, ]
# rda
RIKZ_rda <- rda(Species_fin ~ . , data = ExplVar_fin, scale = TRUE)
# stepwise model building: ordiR2step()
step_both_R2 <- ordiR2step(rda(Species_fin ~ salinity, data = ExplVar_fin, scale = TRUE), scope = formula(RIKZ_rda), direction = "both", R2scope = TRUE, Pin = 0.05, steps
= 1000)
Basically, ordiR2step() stops without adding the variable exposure to the model.
However, if setting R2scope to FALSE:
step_both_R2 <- ordiR2step(rda(Species_fin ~ salinity, data = ExplVar_fin, scale = TRUE), scope = formula(RIKZ_rda), direction = "both", R2scope = FALSE, Pin = 0.05, steps
= 1000)
exposure is added, but the function fails with:
Error in terms.formula(tmp, simplify = TRUE): invalid model formula in ExtractVars
However, we compared a data set for which the function runs properly and couldn’t find a reason why it is failing for this one.
Any help appreciated
Ralf
More information about the R-sig-ecology
mailing list