# Log transform ele and bod
env.pars3 <- cbind(log(env$ele), env$oxy, log(env$bod))
colnames(env.pars3) <- c("ele.ln", "oxy", "bod.ln")
rownames(env.pars3) <- rownames(env2)
env.pars3.d1 <- dist(env.pars3)
(env.MHV2 <- betadisper(env.pars3.d1, gr))
permutest(env.MHV2)
This time the within-group covariance matrices are homogeneous. We can
proceed to the next step: test with Wilks’ lambda that the explanatory variables
have distinct means. We show two different ways to compute this test (H 0 : the
multivariate means of the groups are not distinct).
# First way: with function Wilks.test() of package rrcov, χ
2
Wilks.test(env.pars3, gr)
# Second way: with function manova() of stats, which uses
#
an F-test approximation
lw <- manova(env.pars3 ~ as.factor(gr))
summary(lw, test = "Wilks")
test
First example: let us compute identification functions and use them to attribute
two new objects to the classification.
# Computation of LDA - identification functions (on unstandardized
# variables)
env.pars3.df <- as.data.frame(env.pars3)
(spe.lda <- lda(gr ~ ele.ln + oxy + bod.ln, data = env.pars3.df))
# The result object contains the information necessary to interpret
# the LDA
summary(spe.lda)
# Display the group means for the 3 variables
spe.lda$means
# Extract the unstandardized identification functions (matrix C,
# eq. 11.33 in Legendre and Legendre 2012)
(C <- spe.lda$scaling)
# Classification of two new objects (identification)
# A new object is created with two sites:
#
(1) ln(ele) = 6.8, oxygen = 9 and ln(bod) = 0.8
# and (2) ln(ele) = 5.5, oxygen = 10 and ln(bod) = 1.0
newo <- data.frame(c(6.8, 5.5), c(9, 10), c(0.8, 1))
colnames(newo) <- colnames(env.pars3)
newo
(predict.new <- predict(spe.lda, newdata = newo))
6.5 Linear Discriminant Analysis (LDA)
265
env.pars3 <- cbind(log(env$ele), env$oxy, log(env$bod))
colnames(env.pars3) <- c("ele.ln", "oxy", "bod.ln")
rownames(env.pars3) <- rownames(env2)
env.pars3.d1 <- dist(env.pars3)
(env.MHV2 <- betadisper(env.pars3.d1, gr))
permutest(env.MHV2)
This time the within-group covariance matrices are homogeneous. We can
proceed to the next step: test with Wilks’ lambda that the explanatory variables
have distinct means. We show two different ways to compute this test (H 0 : the
multivariate means of the groups are not distinct).
# First way: with function Wilks.test() of package rrcov, χ
2
Wilks.test(env.pars3, gr)
# Second way: with function manova() of stats, which uses
#
an F-test approximation
lw <- manova(env.pars3 ~ as.factor(gr))
summary(lw, test = "Wilks")
test
First example: let us compute identification functions and use them to attribute
two new objects to the classification.
# Computation of LDA - identification functions (on unstandardized
# variables)
env.pars3.df <- as.data.frame(env.pars3)
(spe.lda <- lda(gr ~ ele.ln + oxy + bod.ln, data = env.pars3.df))
# The result object contains the information necessary to interpret
# the LDA
summary(spe.lda)
# Display the group means for the 3 variables
spe.lda$means
# Extract the unstandardized identification functions (matrix C,
# eq. 11.33 in Legendre and Legendre 2012)
(C <- spe.lda$scaling)
# Classification of two new objects (identification)
# A new object is created with two sites:
#
(1) ln(ele) = 6.8, oxygen = 9 and ln(bod) = 0.8
# and (2) ln(ele) = 5.5, oxygen = 10 and ln(bod) = 1.0
newo <- data.frame(c(6.8, 5.5), c(9, 10), c(0.8, 1))
colnames(newo) <- colnames(env.pars3)
newo
(predict.new <- predict(spe.lda, newdata = newo))
6.5 Linear Discriminant Analysis (LDA)
265
