You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To illustrate the simple usage of the package `fitHeavyTail`, let’s
51
-
start by generating some multivariate data under a Student’s *t*
52
-
distribution with significant heavy tails (*ν* = 4):
54
+
## Quick Start
55
+
To illustrate the simple usage of the package `fitHeavyTail`, let's start by generating some multivariate data under a Student's $t$ distribution with significant heavy tails ($\nu=4$):
53
56
54
-
```r
57
+
```r
55
58
library(mvtnorm) # package for multivariate t distribution
X<- rmvt(n=T, delta=mu, sigma=Sigma_scatter, df=nu) # generate data
66
69
```
67
70
68
-
We can first estimate the mean vector and covariance matrix via the
69
-
traditional sample estimates (i.e., sample mean and sample covariance
70
-
matrix):
71
+
We can first estimate the mean vector and covariance matrix via the traditional sample estimates (i.e., sample mean and sample covariance matrix):
71
72
72
-
```r
73
+
```r
73
74
mu_sm<- colMeans(X)
74
75
Sigma_scm<- cov(X)
75
76
```
76
77
77
78
Then we can compute the robust estimates via the package `fitHeavyTail`:
78
79
79
-
```r
80
+
```r
80
81
library(fitHeavyTail)
81
82
fitted<- fit_mvt(X)
82
83
```
83
84
84
85
We can now compute the estimation errors and see the big improvement:
85
86
86
-
```r
87
+
```r
87
88
sum((mu_sm-mu)^2)
88
89
#> [1] 0.2857323
89
90
sum((fitted$mu-mu)^2)
@@ -95,26 +96,21 @@ sum((fitted$cov - Sigma)^2)
95
96
#> [1] 2.957443
96
97
```
97
98
98
-
To get a visual idea of the robustness, we can plot the shapes of the
99
-
covariance matrices (true and estimated ones) projected on two
100
-
dimensions. Observe how the heavy-tailed estimation follows the true one
101
-
more closely than the sample covariance matrix:
99
+
To get a visual idea of the robustness, we can plot the shapes of the covariance matrices (true and estimated ones) projected on two dimensions. Observe how the heavy-tailed estimation follows the true one more closely than the sample covariance matrix:
> This vignette illustrates the usage of the package [`portfolioBacktest`](https://CRAN.R-project.org/package=fitHeavyTail)
44
+
> This vignette illustrates the usage of the package [`fitHeavyTail`](https://CRAN.R-project.org/package=fitHeavyTail)
45
45
to estimate the mean vector and covariance matrix of heavy-tailed multivariate distributions such as the angular Gaussian, Cauchy, or Student's $t$ distribution. The results are compared against existing benchmark functions from different packages.
46
46
47
47
@@ -87,7 +87,6 @@ Sigma_scm <- cov(X)
87
87
Then we can compute the robust estimates via the package `fitHeavyTail`:
<p>This vignette illustrates the usage of the package <ahref="https://CRAN.R-project.org/package=fitHeavyTail"><code>portfolioBacktest</code></a> to estimate the mean vector and covariance matrix of heavy-tailed multivariate distributions such as the angular Gaussian, Cauchy, or Student’s <spanclass="math inline">\(t\)</span> distribution. The results are compared against existing benchmark functions from different packages.</p>
134
+
<p>This vignette illustrates the usage of the package <ahref="https://CRAN.R-project.org/package=fitHeavyTail"><code>fitHeavyTail</code></a> to estimate the mean vector and covariance matrix of heavy-tailed multivariate distributions such as the angular Gaussian, Cauchy, or Student’s <spanclass="math inline">\(t\)</span> distribution. The results are compared against existing benchmark functions from different packages.</p>
0 commit comments