data(bauges)
map <- bauges$kasc
locs <- bauges$loc
## We prepare the data for the analysis
(datadun1 <- data2enfa(map, locs))
## We then perform the PCA before the analysis
pc <- dudi.pca(datadun1$tab, scannf = FALSE)
(dun <- dunnfa(pc, datadun1$pr, nf=2,
scannf = FALSE))
## We should keep only 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 Maalanobis distances
## (here, with one axis)
dun2 <- dunnfa(pc, datadun1$pr, nf=1,
scannf = FALSE)
kas <- getkasc(df2kasc(data.frame(dun2$mahasu,dun2$mahasu),
datadun1$index, map), 1)
image(kas)
## 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