- Notifications
You must be signed in to change notification settings - Fork6
Mean and Covariance Matrix Estimation under Heavy Tails
License
convexfi/fitHeavyTail
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Robust estimation methods for the mean vector, scatter matrix,and covariance matrix (if it exists) from data (possibly containing NAs)under multivariate heavy-tailed distributions such as angular Gaussian(via Tyler's method), Cauchy, and Student's t distributions. Additionally,a factor model structure can be specified for the covariance matrix. Thelatest revision also includes the multivariate skewed t distribution.
The package can be installed fromCRAN orGitHub:
# install stable version from CRANinstall.packages("fitHeavyTail")# install development version from GitHubdevtools::install_github("convexfi/fitHeavyTail")
To get help:
library(fitHeavyTail)help(package="fitHeavyTail")?fit_mvt
To citefitHeavyTail in publications:
citation("fitHeavyTail")To illustrate the simple usage of the packagefitHeavyTail, let's start by generating some multivariate data under a Student's
library(mvtnorm)# package for multivariate t distributionN<-10# number of variablesT<-80# number of observationsnu<-4# degrees of freedom for heavy tailsset.seed(42)mu<- rep(0,N)U<- t(rmvnorm(n= round(0.3*N),sigma=0.1*diag(N)))Sigma_cov<-U%*% t(U)+ diag(N)# covariance matrix with factor model structureSigma_scatter<- (nu-2)/nu*Sigma_covX<- rmvt(n=T,delta=mu,sigma=Sigma_scatter,df=nu)# generate data
We can first estimate the mean vector and covariance matrix via the traditional sample estimates (i.e., sample mean and sample covariance matrix):
mu_sm<- colMeans(X)Sigma_scm<- cov(X)
Then we can compute the robust estimates via the packagefitHeavyTail:
library(fitHeavyTail)fitted<- fit_mvt(X)
We can now compute the estimation errors and see the significant improvement:
sum((mu_sm-mu)^2)#> [1] 0.2857323sum((fitted$mu-mu)^2)#> [1] 0.1487845sum((Sigma_scm-Sigma_cov)^2)#> [1] 5.861138sum((fitted$cov-Sigma_cov)^2)#> [1] 4.663539
To get a visual idea of the robustness, we can plot the shapes of the covariance matrices (true and estimated ones) on two dimensions. Observe how the heavy-tailed estimation follows the true one more closely than the sample covariance matrix:
For more detailed information, please check thevignette.
README file:GitHub-readme.
Vignette:CRAN-vignette andGitHub-vignette.
About
Mean and Covariance Matrix Estimation under Heavy Tails
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors2
Uh oh!
There was an error while loading.Please reload this page.
