Function to compute the covariance matrix, the niche centroid, and volume of an ellipsoid model. ellipsoid model. It uses the values of the niche variables of the occurrence points.

cov_center(data, mve = TRUE, level, vars = NULL)

Arguments

data

A data.frame or a matrix with the numeric values of the variables that will be used to model the niche.

mve

A logical value. If TRUE a minimum volume ellipsoid will be computed using the function cov.rob of the MASS package. If False the covariance matrix of the input data will be used.

level

A numerical value specifying the proportion of the data to be used to compute the ellipsoid.

vars

A numeric or a string vector specifying the columns indexes/names of the variables of the input data which will be used to fit the ellipsoid model. If NULL the user will be asked to enter the indexes. interactively

Value

Returns a list containing the centroid of the ellipsoid, the covariance matrix based on the input data, ellipsoid volume, semi-axis length, and axis coordinates.

Examples

environ_data <- read.csv(system.file("extdata", "nichekmeansCluster.csv", package = "ntbox"))[,-(1:3)] ellipsoid_metadata <- cov_center(environ_data,mve = TRUE, level=0.975, vars = c("bio5","bio6","bio12")) # Ellipsoid center ellipsoid_metadata$centroid
#> bio5 bio6 bio12 #> 280.07242 -79.89831 1022.96148
# Shape matrix ellipsoid_metadata$covariance
#> bio5 bio6 bio12 #> bio5 1134.018 1241.098 1601.125 #> bio6 1241.098 4154.200 7867.481 #> bio12 1601.125 7867.481 66619.534
# Ellipsoid volume ellipsoid_metadata$niche_volume
#> [1] 48137439
if (FALSE) { # Plot ellipsoid rgl::plot3d(rgl::ellipse3d(ellipsoid_metadata$covariance, centre = ellipsoid_metadata$centroid, level = 0.99999), alpha=0.4,col="blue") rgl::points3d(environ_data[,c("bio5","bio6","bio12")]) }