data(bauges)
map <- bauges$map
locs <- bauges$loc
## We prepare the data for the analysis
tab <- slot(map, "data")
pr <- slot(count.points(locs, map), "data")[,1]
## We then perform the PCA before the analysis
pc <- dudi.pca(tab, scannf = FALSE)
(dun <- dunnfa(pc, pr, nf=2,
scannf = FALSE))
## We should keep one axis:
barplot(dun$eig)
## The correlation of the variables with the first two axes:
s.arrow(dun$cor)
## A factorial map of the niche (centering on the available points)
scatterniche(dun$liA, dun$pr, pts=TRUE)
## a map of the reduced rank Mahalanobis distances
## (here, with one axis)
dun2 <- dunnfa(pc, pr, nf=1,
scannf = FALSE)
df <- data.frame(MD=dun2$mahasu)
coordinates(df) <- coordinates(map)
gridded(df) <- TRUE
image(df)
## Compute the specialization on the row scores of
## the analysis:
apply(dun$liA, 2, function(x) {
varav <- sum((x - mean(x))^2) / length(x)
meanus <- sum(dun$pr*x)/sum(dun$pr)
varus <- sum(dun$pr * (x - meanus )^2)/sum(dun$pr)
return(varav/varus)
})
## The eigenvalues:
dun$eig
Run the code above in your browser using DataLab