Generates scenarios from the Student-t distribution that exactly matches the first two moments.

match_t(mu, sigma, nu, n, stochastic = FALSE)

Arguments

mu

A double with the location parameter.

sigma

A variance-covariance matrix the dispersion parameter.

nu

An integer with the degrees of freedom.

n

An integer with the number of scenarios to be generated.

stochastic

A logical flag indicating whether (or not) the stochastic representation should be used. The default if TRUE.

Value

A tibble in the wide format.

See also

Examples

x     <- diff(log(EuStockMarkets))
mu    <- colMeans(x)
sigma <- cov(x)
nu    <- 5
match_t(mu, sigma, nu, 10)
#> # A tibble: 10 × 4
#>         DAX      SMI      CAC     FTSE
#>       <dbl>    <dbl>    <dbl>    <dbl>
#>  1 -0.00396 -0.00689 -0.00752 -0.00270
#>  2 -0.00911  0.00603  0.00729  0.00475
#>  3 -0.00413 -0.0122   0.00906 -0.00264
#>  4 -0.0149  -0.00634 -0.0131  -0.0111 
#>  5  0.00750  0.00516  0.00553 -0.00691
#>  6  0.00887  0.0132   0.0151   0.00591
#>  7  0.00639 -0.00270 -0.00344 -0.00193
#>  8  0.00538  0.0147  -0.00892  0.00439
#>  9  0.0128   0.00610  0.0114   0.00986
#> 10 -0.00480 -0.00344 -0.00318  0.00646

cor(x)
#>            DAX       SMI       CAC      FTSE
#> DAX  1.0000000 0.7031219 0.7344304 0.6394674
#> SMI  0.7031219 1.0000000 0.6160454 0.5847791
#> CAC  0.7344304 0.6160454 1.0000000 0.6485679
#> FTSE 0.6394674 0.5847791 0.6485679 1.0000000
cor(match_t(mu, sigma, nu, 100000))
#>            DAX       SMI       CAC      FTSE
#> DAX  1.0000000 0.7043184 0.7353029 0.6430057
#> SMI  0.7043184 1.0000000 0.6144276 0.5870772
#> CAC  0.7353029 0.6144276 1.0000000 0.6477045
#> FTSE 0.6430057 0.5870772 0.6477045 1.0000000

mu
#>          DAX          SMI          CAC         FTSE 
#> 0.0006520417 0.0008178997 0.0004370540 0.0004319851 
colMeans(match_t(mu, sigma, nu, 100000, TRUE))
#>          DAX          SMI          CAC         FTSE 
#> 0.0006525741 0.0007998605 0.0004610506 0.0004380022