Cumulative abundance surface (CAS)
CAS.Rd
Functions to calculate cumulative abundance surfaces (CASs), to build matrices from them, and to summarize several CASs.
Usage
CAS(x, transform=NULL, verbose=FALSE)
CASmargin(CAS, margin=1, verbose=FALSE)
CAS2matrix(CAS, type="cumulative",classWeights=NULL)
CAScenters(CAS, y=NULL)
CASquantile(CAS, q = 0.5, y = NULL)
Arguments
- x
An object of class 'doublestratifiedvegdata' (see function
stratifyvegdata
).- transform
A function or the name of a function to be applied to each cumulative abundance value.
- verbose
A logical flag to indicate extra output.
- CAS
An object of class '
CAS
'.- margin
Indicates whether marginalization should be done in primary (
margin = 1
) or secondary (margin = 2
) size classes.- type
The type of information that the resulting matrix should contain (either
"cummulative"
or"total"
).- classWeights
A numerical matrix containing the weight for each combination of size classes. If
NULL
, then all classes are assumed to have the same weight.- y
A vector used as a factor to calculate average or quantile surfaces per each level. Alternatively, an object of class
vegclust
for which CAS centroids or medoids are desired.- q
Probability value for which the quantile is desired. By default the median is given.
Details
Function CAS
replaces the abundance value of each combination of size classes by the sum of abundances in this and larger size classes. This creates a cumulative abundance surface (similar to a bivariant cummulative distribution function). Function CASmargin
takes an object of class 'CAS
' and returns an object of class 'CAP
' that corresponds marginal profile in either the primary or the secondary size classes. Function CAS2matrix
takes an object of class 'CAS
' and returns a data matrix, where values differ depending on parameter type
: (1) type="cummulative"
simply reshapes the 'CAS
' object (a list) into a matrix with as many rows as plot records and where columns are organized in blocks (there are as many blocks as species and each block has as many columns as combinations of size classes); (2) type="total"
returns a plot-by-species matrix where each value is the total abundance of the species in the plot (i.e. the CAS value at the ground level). When provided, classWeights
are used to weight size classes of the cumulative abundance surfaces (for (1) only). Function CAScenters
calculates the average abundance surface for a set of plot records. If y
is a factor, it is used to speficy groups of samples for which average profiles are to be calculated. If y
is an object of class 'vegclust
' then the function returns the CAS centroids or medoids corresponding to the clustering result. Function CASquantile
calculates a quantile surface for a set of CASs. The usage of y
is the same as for CAScenters
.
Value
Function CAS
returns an object of class 'CAS
', similar to objects of class 'doublestratifiedvegdata
' but where abundance values of upper size classes have beed added to those of lower size classes. Function CAS2matrix
returns a matrix with species as rows (columns depend on the value of type
). Functions CAScenters
and CASquantile
return an object of class 'CAS
'.
References
De Cáceres, M., Legendre, P. & He, F. (2013) Dissimilarity measurements and the size structure of ecological communities. Methods in Ecology and Evolution 4: 1167-1177.
De Cáceres, M., Coll, L., Martín-Alcón, S., González-Olabarria, J.R. (submitted) A general method for the classification of forest stands using structure and composition.
Examples
## Load tree data
data(treedata)
## Define stratum thresholds (4 strata)
heights = seq(0,4, by=0.5)
diameters = seq(0,2, by=0.5)
## Stratify tree data using heights and diameters as structural variables
X = stratifyvegdata(treedata, sizes1=heights, sizes2=diameters, plotColumn="plotID",
speciesColumn="species", size1Column="height", size2Column="diam",
counts=TRUE)
X[[2]]
#> , , [0,0.5]
#>
#> [0,0.5] (0.5,1] (1,1.5] (1.5,2] (2,2.5] (2.5,3] (3,3.5] (3.5,4]
#> H 0 0 0 0 0 0 0 0
#> N 0 0 0 0 0 0 0 0
#> O 0 0 0 0 0 0 0 0
#>
#> , , (0.5,1]
#>
#> [0,0.5] (0.5,1] (1,1.5] (1.5,2] (2,2.5] (2.5,3] (3,3.5] (3.5,4]
#> H 0 0 0 0 0 0 0 0
#> N 0 0 0 0 0 0 0 0
#> O 0 2 0 0 0 0 0 0
#>
#> , , (1,1.5]
#>
#> [0,0.5] (0.5,1] (1,1.5] (1.5,2] (2,2.5] (2.5,3] (3,3.5] (3.5,4]
#> H 0 0 0 0 0 0 0 3
#> N 0 0 0 0 0 0 0 0
#> O 0 0 0 0 0 0 0 0
#>
#> , , (1.5,2]
#>
#> [0,0.5] (0.5,1] (1,1.5] (1.5,2] (2,2.5] (2.5,3] (3,3.5] (3.5,4]
#> H 0 0 0 0 0 0 0 0
#> N 0 0 0 0 0 0 0 0
#> O 0 0 0 0 0 0 0 0
#>
## Build cummulative abundance surface
Y = CAS(X)
Y[[2]]
#> , , [0,0.5]
#>
#> [0,0.5] (0.5,1] (1,1.5] (1.5,2] (2,2.5] (2.5,3] (3,3.5] (3.5,4]
#> H 3 3 3 3 3 3 3 3
#> N 0 0 0 0 0 0 0 0
#> O 2 2 0 0 0 0 0 0
#>
#> , , (0.5,1]
#>
#> [0,0.5] (0.5,1] (1,1.5] (1.5,2] (2,2.5] (2.5,3] (3,3.5] (3.5,4]
#> H 3 3 3 3 3 3 3 3
#> N 0 0 0 0 0 0 0 0
#> O 2 2 0 0 0 0 0 0
#>
#> , , (1,1.5]
#>
#> [0,0.5] (0.5,1] (1,1.5] (1.5,2] (2,2.5] (2.5,3] (3,3.5] (3.5,4]
#> H 3 3 3 3 3 3 3 3
#> N 0 0 0 0 0 0 0 0
#> O 0 0 0 0 0 0 0 0
#>
#> , , (1.5,2]
#>
#> [0,0.5] (0.5,1] (1,1.5] (1.5,2] (2,2.5] (2.5,3] (3,3.5] (3.5,4]
#> H 0 0 0 0 0 0 0 0
#> N 0 0 0 0 0 0 0 0
#> O 0 0 0 0 0 0 0 0
#>
## Extracts the first and second marginal (i.e. CAP on heights or diameters respectively)
Y.M1 = CASmargin(Y, margin = 1)
Y.M1[[2]]
#> [0,0.5] (0.5,1] (1,1.5] (1.5,2] (2,2.5] (2.5,3] (3,3.5] (3.5,4]
#> H 3 3 3 3 3 3 3 3
#> N 0 0 0 0 0 0 0 0
#> O 2 2 0 0 0 0 0 0
Y.M2 = CASmargin(Y, margin = 2)
Y.M2[[2]]
#> [0,0.5] (0.5,1] (1,1.5] (1.5,2]
#> H 3 3 3 0
#> N 0 0 0 0
#> O 2 2 0 0
## For comparison we calculate the same profiles using the stratifyvegdata and CAP functions
Y1 = CAP(stratifyvegdata(treedata, sizes1=heights, plotColumn="plotID",
speciesColumn="species", size1Column="height",
counts=TRUE))
Y1[[2]]
#> [0,0.5] (0.5,1] (1,1.5] (1.5,2] (2,2.5] (2.5,3] (3,3.5] (3.5,4]
#> H 3 3 3 3 3 3 3 3
#> N 0 0 0 0 0 0 0 0
#> O 2 2 0 0 0 0 0 0
Y2 = CAP(stratifyvegdata(treedata, sizes1=diameters, plotColumn="plotID",
speciesColumn="species", size1Column="diam",
counts=TRUE))
Y2[[2]]
#> [0,0.5] (0.5,1] (1,1.5] (1.5,2]
#> H 3 3 3 0
#> N 0 0 0 0
#> O 2 2 0 0
## Compare Y.M1[[2]] with Y1[[2]] and Y.M2[[2]] with Y2[[2]]