View source: R/MVNH_functions.R
MVNH_det | R Documentation |
This function calculates the determinant of the covariance matrix (generalized variance), as well as the univariate variances and a correlation component.
MVNH_det(data,cov,var.names,cov.matrix,log)
data |
Dataset with rows as observations and columns as variables. Not used when cov.matrix=T. |
cov.matrix |
Logical value, the default is False. To supply a covariance matrix instead of the dataset for calculation. |
cov |
The covariance matrix supplied for the calculation. Only used when cov.matrix is TRUE. |
log |
Logical value, the default is False. Whether the log-value should be returned. |
var.names |
Names of the variables provided by user. The default is NULL, which takes the column names of the matrix or the dataset, or use 'variable1', 'variable2'... when no names are associated with the data. |
total |
The determinant of the covariance matrix. |
variable i |
The variance of variable i. |
cor |
The correlation component which is the determinant devided by the product of all univariate variances. |
When the covariance matrix is singular (high collinearity), the metric is not reliable because the determinant will aprroximate 0.
Muyang Lu (muyang.lu@yale.edu), Kevin Winner, Walter Jetz
Lu, M., Winner, K., & Jetz, W. (2020). A unifying framework for quantifying and comparing n-dimensional hypervolumes. BioRxiv. https://doi.org/10.1101/2020.11.21.392696
## two multivariate normal distributions as toy example
library(MASS)
# db1 for dataframe1 db2 for dataframe2
# two random matrixes generated by 2 mutivariate normal distributions
db1 = mvrnorm(n=50,mu=c(1,1),Sigma=matrix(c(1,0,0,1),nrow=2))
db2 = mvrnorm(n=50,mu=c(2,2),Sigma=matrix(c(2,0.6,0.6,0.5),nrow=2))
MVNH_det(db1)
MVNH_det(db2)
# or directly supply the covariance matrices
MVNH_det(cov=matrix(c(1,0,0,1),nrow=2),cov.matrix=TRUE)
MVNH_det(cov=matrix(c(2,0.6,0.6,0.5),nrow=2),cov.matrix=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.