The MADIFA: a Factorial Decomposition of the Mahalanobis Distances

Share:

Description

The MADIFA allows a factorial decomposition of the Mahalanobis distances. This method is presented here in the framework of niche-environment studies.

predict.madifa allows the computation of the Mahalanobis Distances based on a restricted number of factorial axes.
All other functions allow various graphical displays of the results of the MADIFA.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
madifa(dudi, pr, scannf = TRUE, nf = 2)
## S3 method for class 'madifa'
print(x, ...)
## S3 method for class 'madifa'
scatter(x, xax = 1, yax = 2, pts = FALSE, percent = 95,
               clabel = 1, side = c("top", "bottom", "none"),
               Adensity, Udensity, Aangle, Uangle, Aborder,
               Uborder, Acol, Ucol, Alty,
               Ulty, Abg, Ubg, Ainch, Uinch, ...)
## S3 method for class 'madifa'
hist(x, scores = TRUE, type = c("h", "l"), adjust = 1, Acol,
            Ucol, Aborder, Uborder, Alwd = 1, Ulwd = 1, ...)
## S3 method for class 'madifa'
predict(object, map, nf, ...)
s.madifa(x, xax = 1, yax = 2, cgrid = 1, clab = 1, ...)
## S3 method for class 'madifa'
plot(x, map, xax = 1, yax = 2, cont = FALSE, ...)

Arguments

dudi

a duality diagram, an object of class dudi

pr

a vector giving the utilization weights associated to each unit

scannf

logical. Whether the eigenvalues barplot should be displayed

nf

an integer indicating the number of kept factorial axes

x,object

an object of class madifa

xax

the column number for the x-axis

yax

the column number for the y-axis

pts

logical. Whether the points should be drawn. If FALSE, minimum convex polygons are displayed

percent

100 minus the proportion of outliers to be excluded from the computation of the minimum convex polygons

clabel

a character size for the columns

side

if "top", the legend of the kept axis is upside, if "bottom" it is downside, if "none" no legend

Adensity

the density of shading lines, in lines per inch, for the available pixels polygon. See polygon for more details

Udensity

the density of shading lines, in lines per inch, for the used pixels polygon. See polygon for more details

Aangle

the slope of shading lines, given as an angle in degrees (counter-clockwise), for the available pixels polygon

Uangle

the slope of shading lines, given as an angle in degrees (counter-clockwise), for the used pixels polygon

Aborder

the color for drawing the border of the available pixels polygon (or of the bars of the histogram) . See polygon for more details

Uborder

the color for drawing the border of the used pixels polygon (or of the bars of the histogram). See polygon for more details

Acol

the color for filling the available pixels polygon. if pts == FALSE, the color for the points corresponding to available pixels

Ucol

the color for filling the used pixels polygon. if pts == FALSE, the color for the points corresponding to used pixels

Alty

the line type for the available pixels polygon, as in par

Ulty

the line type for the used pixels polygon, as in par

Abg

if pts == TRUE, background color for open plot symbols of available pixels

Ubg

if pts == TRUE, background color for open plot symbols of used pixels

Ainch

if pts == TRUE, heigth in inches of the available pixels

Uinch

if pts == TRUE, heigth in inches of the largest used pixels

scores

logical. If TRUE, the histograms display the row scores of the MADIFA. If FALSE, they display the niche on the environmental variables (in this case, this is equivalent to histniche)

type

what type of plot should be drawn. Possible types are:
* "h" for histograms,
* "l" for kernel density estimates (see ?density).
By default, type = "h" is used. If type = "l" is used, the position of the mean of each distribution is indicated by dotted lines

adjust

if type = "l", a parameter used to control the bandwidth of the density estimates (see ?density)

Alwd

if type = "l", the line width of the kernel density estimates of the available pixels

Ulwd

if type = "l", the line width of the kernel density estimates of the used pixels

cgrid

a character size, parameter used with par("cex")* cgrid to indicate the mesh of the grid

clab

if not NULL, a character size for the labels, used with par("cex")*clab

map

an object of class SpatialPixelsDataFrame

cont

logical. Whether contour lines should be added to the maps

...

additional arguments to be passed to the functions print, scatter, and plot

Details

The Mahalanobis distances are often used in the context of niche-environment studies (Clark et al. 1993, see the function mahasuhab). Each environmental variable defines a dimension in a multidimensionnal space, namely the ecological space. The Mahalanobis distance between any resource unit in this space (e.g. the point defined by the values of environmental variables in a pixel of a raster map) and the centroid of the niche (the distribution of used resource units) can be used to give a value of eccentricity to this point.

For a given distribution of available resource units, for which a measure of Mahalanobis distances is desired, the MADIFA (MAhalanobis DIstances Factor Analysis) partitions the ecological space into a set of axes, so that the first axes maximises the average proportion of their squared Mahalanobis distances. Note that the sum of the squared scores of any resource unit on all the axes of the analysis is equal to the squared Mahalanobis distances for this resource unit. Thus, the MADIFA partitions the Mahalanobis distances into several axes of biological meaning (see examples). predict.madifa allows to compute approximate Mahalanobis distances from the axes of the MADIFA.

plot.madifa returns a graphical summary of the analysis: it returns graphs of (i) the eigenvalues of the analysis (each eigenvalue measures the average Mahalanobis distance explained by each factorial axis); (ii) the scores of the habitat variables (i.e. the coefficients associated to each environmental variable in the linear combination defining the axes) - note that as the ecological space is distorted to "sphericize" the niche, the factorial axes are no longer orthogonals, and the scores of the variables are distributed within an ellipsoid instead of an hypersphere of radius equal to one in classical PCA. The limits of this ellipsoid is displayed on this graph, to see the amount of distortion done by the analysis (further research needs yet to be done on this graph); (iii) The projection of the available and used points on the factorial plane of the MADIFA; (iv) The map of the Mahalanobis distances computed from the original environmental variables; (v) the map of the approximated Mahalanobis distances computed from the two axes displayed in this plot; the correlations between the original environmental variables and the factorial axes; (v) the map of the first factorial axis and (vi) the map of the second factorial axis.

hist.madifa returns a graph of the niche and the available resource units on the factorial axes of the analysis.

Value

madifa returns a list of class madifa containing the following components:

call

original call.

tab

a data frame with n rows and p columns.

pr

a vector of length n containing the number of points in each pixel of the map.

nf

the number of kept factorial axes.

eig

a vector with all the eigenvalues of the analysis.

lw

row weights, a vector with n components.

li

row coordinates, data frame with n rows and nf columns.

l1

row normed coordinates, data frame with n rows and nf columns.

cw

column weights, a vector with p components.

co

column coordinates, data frame with p rows and nf columns.

mahasu

a vector of length n containing the squared Mahalanobis distances for the n units.

cor

the correlation between the MADIFA axes and the original variable

predict.madifa returns a matrix of class asc.

Author(s)

Clement Calenge clement.calenge@oncfs.gouv.fr

References

Clark, J.D., Dunn, J.E. and Smith, K.G. (1993) A multivariate model of female black bear habitat use for a geographic information system. Journal of Wildlife Management, 57, 519–526.

Calenge, C., Darmon, G., Basille, M., Loison, A. and Jullien J.M. (2008) The factorial decomposition of the Mahalanobis distances in habitat selection studies. Ecology, 89, 555–566.

See Also

mahasuhab for a detailed description of the Mahalanobis distances, enfa and gnesfa for closely related methods.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
## Not run: 

data(bauges)

map <- bauges$map
locs <- bauges$loc

## We prepare the data for the MADIFA
tab <- slot(map, "data")
pr <- slot(count.points(locs, map), "data")[,1]


## We then perform the PCA before the MADIFA
pc <- dudi.pca(tab, scannf = FALSE)
(mad <- madifa(pc, pr, nf=7,
               scannf = FALSE))

#########################################
##                                     ##
## Graphical exploration of the MADIFA ##
##                                     ##
#########################################

hist(mad)

plot(mad, map)

## this plot represents:
##  - the eigenvalues diagram
##  - the scores of the columns on the axes
##  - a graph of the niche in the available space
##  - a map of the Mahalanobis distances computed
##    using all environmental variables
##  - a map of the Mahalanobis distances computed
##    using the two factorial axes used in the
##    previous graphs
##  - the correlation between habitat variables
##    and factorial axes
##  - the geographical maps of the two
##    factorial axes

## predict with just the first axis
pred <- predict(mad, map, nf=1)
image(pred)



#########################################
##                                     ##
## Mathematical properties of  MADIFA  ##
##                                     ##
#########################################

## mad$li is equal to mad$l1, up to a constant (mad$l1 is normed)
plot(mad$li[,1],mad$l1[,1])

## This constant is the square root of the corresponding eigenvalue:
## the variance of mad$l1 is equal to the eigenvalue
apply(mad$l1,2,function(x) sum(x^2))/nrow(mad$li)

## the variance of mad$l1 weighted by pr is equal to 1
apply(mad$l1,2,function(x) sum(mad$pr*x^2)/sum(mad$pr))

## Therefore, the eigenvalues are equal to the average of Mahalanobis
## distance for the available resource units on each axis
mean(mahalanobis(matrix(mad$l1[,1], ncol=1), 0, 1))
mad$eig[1]

## Computation of the Mahalanobis distances
ma1 <- mahasuhab(map, locs)

## The sum of squared scores for a given Resource unit is equal to the
## Mahalanobis distances
ma2 <- apply(mad$l1,1, function(x) sum(x^2))
plot(ma2, slot(ma1, "data")[,1])


## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.