Replies: 2 comments
-
You can use library(vegan)
data(varespec, varechem)
set.seed(22)
mod <- metaMDS(varespec, trace=0)
ef <- envfit(mod ~ pH, varechem) # envfit for verification
surffit <- ordisurf(mod ~ pH, varechem) # standard smooth fit
linefit <- ordisurf(mod ~ pH, varechem, knots=1) # linear surface
plot(ef, add=TRUE) # verify that envfit arrow shows the gradient (is perpendicular to contour lines)
anova(linefit, surffit, test="F") # test: linear looks quite decent
# Analysis of Deviance Table
#
# Model 1: y ~ poly(x1, 1) + poly(x2, 1)
# Model 2: y ~ s(x1, x2, k = 10, bs = "tp", fx = FALSE)
# Resid. Df Resid. Dev Df Deviance F Pr(>F)
# 1 21.000 0.81021
# 2 16.752 0.51515 4.2481 0.29507 2.5522 0.07487 . |
Beta Was this translation helpful? Give feedback.
0 replies
-
Very helpful, thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
-
Hi!
I have some questions about procedures to compare fitting of environmental variables through envfit and ordisurf methods. I made a PCA on microbiome datasets and have a continuous variable which I fitted this way:
As I understand,
envfit
uses linear model to fit the variable into the 2 first PCs, whileordisurf
uses a GAM to do the same. I would like to compare both models to see if my variable fits better with GLM or GAM, or if there are no differences between models. I cannot apply AIC nor Chi tests between anenvfit
and anordisurf
object becauseenvfit
is notglm
class.Am I approaching this well? Is there another way to compare both models?
Thanks in advance
Adrian LG
Beta Was this translation helpful? Give feedback.
All reactions