svsim is used to produce realizations of a stochastic volatility (SV) process.

svsim(len, mu = -10, phi = 0.98, sigma = 0.2, nu = Inf, rho = 0)

Arguments

len

length of the simulated time series.

mu

level of the latent log-volatility AR(1) process. The defaults value is -10.

phi

persistence of the latent log-volatility AR(1) process. The default value is 0.98.

sigma

volatility of the latent log-volatility AR(1) process. The default value is 0.2.

nu

degrees-of-freedom for the conditional innovations distribution. The default value is Inf, corresponding to standard normal conditional innovations.

rho

correlation between the observation and the increment of the log-volatility. The default value is 0, corresponding to the basic SV model with symmetric “log-returns”.

Value

The output is a list object of class svsim containing

y

vector of length len containing the simulated data, usually interpreted as “log-returns”.

vol

vector of length len containing the simulated instantaneous volatilities. These are \(e^{h_t/2}\) if nu == Inf, and they are \(e^{h_t/2} \sqrt{\tau_t}\) for finite nu.

vol0

The initial volatility exp(h_0/2), drawn from the stationary distribution of the latent AR(1) process.

para

a named list with five elements mu, phi, sigma, nu, and rho, containing the corresponding arguments.

latent

vector of the latent state space \(h_t\) for \(t > 0\).

latent0

initial element of the latent state space \(h_0\).

tau

vector of length len containing the simulated auxiliary variables for the Student-t residuals when nu is finite. More precisely, \(\tau_t\sim\text{Gamma}^{-1}(\text{shape}=\nu/2, \text{rate}=\nu/2-1)\).

Details

This function draws an initial log-volatility h_0 from the stationary distribution of the AR(1) process defined by phi, sigma, and mu. Then the function jointly simulates the log-volatility series h_1,...,h_n with the given AR(1) structure, and the “log-return” series y_1,...,y_n with mean 0 and standard deviation exp(h/2). Additionally, for each index i, y_i can be set to have a conditionally heavy-tailed residual (through nu) and/or to be correlated with (h_{i+1}-h_i) (through rho, the so-called leverage effect, resulting in asymmetric “log-returns”).

Note

The function generates the “log-returns” by y <- exp(-h/2)*rt(h, df=nu). That means that in the case of nu < Inf the (conditional) volatility is sqrt(nu/(nu-2))*exp(h/2), and that corrected value is shown in the print, summary and plot methods.

To display the output use print, summary and plot. The print method simply prints the content of the object in a moderately formatted manner. The summary method provides some summary statistics (in %), and the plot method plots the the simulated 'log-returns' y along with the corresponding volatilities vol.

See also

Author

Gregor Kastner gregor.kastner@wu.ac.at

Examples

## Simulate a highly persistent SV process of length 500
sim <- svsim(500, phi = 0.99, sigma = 0.1)

print(sim)
#> 
#> Simulated time series consisting of 500 observations.
#> 
#> Parameters: level of latent variable                  mu = -10
#>             persistence of latent variable           phi = 0.99
#>             standard deviation of latent variable  sigma = 0.1
#>             degrees of freedom parameter              nu =Inf
#>             leverage effect parameter                rho =0
#> 
#> Simulated initial volatility:  
#> 
#> Simulated volatilities:
#>   [1] 0.010308259 0.010009401 0.009411251 0.008883394 0.008589876 0.008358430
#>   [7] 0.008432230 0.008133990 0.008586075 0.009044852 0.008002161 0.008654785
#>  [13] 0.008717485 0.008152561 0.007998345 0.008637942 0.008289495 0.007822695
#>  [19] 0.007758995 0.007725299 0.007134593 0.006723009 0.006666668 0.006761311
#>  [25] 0.006684848 0.006856724 0.006561032 0.006116170 0.006115629 0.006796245
#>  [31] 0.006991076 0.006695724 0.006146689 0.006133814 0.006057509 0.006299713
#>  [37] 0.006379071 0.006692678 0.006548709 0.006609135 0.006335853 0.006112483
#>  [43] 0.006342100 0.006528172 0.006389441 0.006740126 0.006833368 0.006524560
#>  [49] 0.006271691 0.006092097 0.006415374 0.006272430 0.006273305 0.006136283
#>  [55] 0.006294538 0.006174264 0.006271141 0.006330003 0.005846127 0.006041079
#>  [61] 0.006186624 0.006516086 0.006457669 0.006059247 0.006243588 0.006080370
#>  [67] 0.006422151 0.006416028 0.006424466 0.006472367 0.006520562 0.006371134
#>  [73] 0.006478275 0.006806480 0.006283960 0.006049703 0.005896588 0.005744510
#>  [79] 0.005842283 0.006001151 0.006424349 0.006108826 0.006015157 0.006336819
#>  [85] 0.006281629 0.006036409 0.006026957 0.006005296 0.005937941 0.005866327
#>  [91] 0.005372271 0.005114692 0.005210454 0.005248385 0.005429484 0.005920793
#>  [97] 0.005748921 0.005402004 0.005394619 0.005843232
#>  [ reached getOption("max.print") -- omitted 400 entries ]
#> 
#> Simulated data (usually interpreted as 'log-returns'):
#>   [1] -4.804832e-03  1.106811e-02 -4.533550e-03  4.287945e-03 -8.287433e-03
#>   [6]  1.611522e-03 -7.134526e-03  1.490611e-03 -1.033175e-02 -1.034945e-02
#>  [11] -1.985365e-04 -6.876359e-03  8.302713e-03 -1.117179e-02  1.289384e-02
#>  [16] -2.573972e-03  6.354959e-04 -5.966331e-03  3.878454e-03  5.116454e-03
#>  [21] -1.197449e-03  8.304420e-03 -7.911121e-03  1.099383e-02 -1.205957e-03
#>  [26]  9.871569e-03 -3.690863e-03 -2.933220e-03 -4.496707e-03 -1.864355e-03
#>  [31]  6.974898e-03 -1.481696e-03 -4.022132e-03  8.075905e-03  5.868623e-03
#>  [36] -2.211351e-03 -1.803133e-03  5.483004e-03 -3.718360e-03  1.256969e-02
#>  [41]  9.801023e-04  1.542190e-02  6.152055e-03 -1.984011e-03  1.367793e-02
#>  [46]  6.076041e-03 -2.995953e-03 -1.560721e-03  7.206368e-03 -1.645111e-02
#>  [51] -4.034825e-03  3.418131e-03  1.824775e-03  5.064981e-03 -2.622961e-03
#>  [56]  7.270094e-03  1.368405e-02 -6.047007e-03  2.714441e-03 -6.237954e-03
#>  [61] -5.300928e-03 -5.198108e-03  4.239617e-03  4.103640e-03 -2.030837e-03
#>  [66] -3.968976e-05  1.414879e-02  3.019929e-03 -3.260621e-03  7.594530e-03
#>  [71]  8.761650e-04 -1.008272e-03  7.649386e-04 -3.253849e-03  8.944122e-03
#>  [76] -8.974044e-03 -4.165743e-03  3.757160e-03 -5.078772e-04  6.573651e-03
#>  [81]  6.572551e-03  9.541607e-04 -9.506589e-03 -5.498405e-03  3.582713e-04
#>  [86]  3.441308e-04  6.521742e-03  5.819241e-03  3.143645e-03 -6.504444e-03
#>  [91] -4.563965e-03 -3.215570e-03 -1.442546e-03  3.121922e-04 -1.098801e-02
#>  [96] -1.003797e-02  2.061944e-03  3.328366e-04 -5.372354e-03 -1.374265e-03
#>  [ reached getOption("max.print") -- omitted 400 entries ]
summary(sim)
#> 
#> Simulated time series consisting of 500 observations.
#> 
#> Parameters: level of latent variable                  mu = -10
#>             persistence of latent variable           phi = 0.99
#>             standard deviation of latent variable  sigma = 0.1
#>             degrees of freedom parameter              nu = Inf
#>             leverage effect parameter                rho = 0
#> 
#> Simulated initial volatility (in %): 0.9124062 
#> 
#> Summary of simulated volatilities (in %):
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>  0.4161  0.5654  0.6518  0.7245  0.8197  1.9333 
#> 
#> Summary of simulated data (in %):
#>     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
#> -2.89244 -0.40719  0.01640  0.02468  0.45368  6.37432 
plot(sim)


## Simulate an SV process with leverage
sim <- svsim(200, phi = 0.94, sigma = 0.15, rho = -0.6)

print(sim)
#> 
#> Simulated time series consisting of 200 observations.
#> 
#> Parameters: level of latent variable                  mu = -10
#>             persistence of latent variable           phi = 0.94
#>             standard deviation of latent variable  sigma = 0.15
#>             degrees of freedom parameter              nu =Inf
#>             leverage effect parameter                rho =-0.6
#> 
#> Simulated initial volatility:  
#> 
#> Simulated volatilities:
#>   [1] 0.008374675 0.007980486 0.008666331 0.008491619 0.008285836 0.007156319
#>   [7] 0.007236020 0.006250681 0.005979842 0.005885045 0.006271787 0.005992049
#>  [13] 0.006443709 0.007384661 0.007520188 0.007406614 0.007572975 0.006699512
#>  [19] 0.007127106 0.006356766 0.007263278 0.007028762 0.006319005 0.006830762
#>  [25] 0.006943136 0.007135284 0.007115497 0.007502327 0.008400624 0.007787995
#>  [31] 0.007432982 0.005912012 0.006336818 0.007003879 0.007962002 0.008456192
#>  [37] 0.008910444 0.008231109 0.008558021 0.007988190 0.007214810 0.006661277
#>  [43] 0.006288934 0.005576233 0.005523081 0.004792849 0.004510969 0.004892259
#>  [49] 0.005302454 0.004943901 0.005189551 0.005586151 0.005889390 0.005271117
#>  [55] 0.005017912 0.004439796 0.004661883 0.004468083 0.005205547 0.005263293
#>  [61] 0.005547090 0.006130272 0.004790070 0.004586918 0.004694772 0.004825579
#>  [67] 0.004602733 0.005142686 0.005334237 0.005052182 0.004924023 0.005224020
#>  [73] 0.005019978 0.005055088 0.005154895 0.005180944 0.005642867 0.006023433
#>  [79] 0.006436116 0.006242136 0.006003279 0.005589251 0.005976478 0.006278196
#>  [85] 0.005691717 0.005475039 0.005849164 0.005935789 0.006442432 0.006283570
#>  [91] 0.005703124 0.005807849 0.005630083 0.006496619 0.006086198 0.005609829
#>  [97] 0.005207691 0.005028792 0.004575757 0.004539992
#>  [ reached getOption("max.print") -- omitted 100 entries ]
#> 
#> Simulated data (usually interpreted as 'log-returns'):
#>   [1]  4.436399e-03 -9.155525e-03  1.610024e-02  7.792191e-03  1.476073e-02
#>   [6] -8.783362e-04  7.616712e-03  9.608832e-03  4.526723e-05 -3.106654e-03
#>  [11]  1.486837e-03 -4.125672e-03 -1.229541e-02 -3.712359e-04  4.901784e-03
#>  [16] -7.219276e-03  1.498065e-02  3.872379e-03  5.502532e-03 -1.105744e-02
#>  [21] -1.524992e-03  6.716484e-03 -3.504816e-03  4.535027e-03 -2.296322e-03
#>  [26]  6.067096e-03 -5.383150e-03 -8.769809e-03  3.825941e-03  1.122348e-03
#>  [31]  1.983052e-02 -8.857542e-03 -5.921138e-03 -1.274984e-02  9.135400e-04
#>  [36] -1.065299e-02  1.007172e-02  1.443066e-03 -1.764665e-03  9.970310e-04
#>  [41]  8.666008e-03  1.152574e-02  2.881912e-03  1.571172e-03  4.853320e-03
#>  [46]  2.422255e-03 -2.279357e-03 -6.296165e-03  1.940364e-03 -4.455351e-03
#>  [51]  3.600213e-03  2.679404e-03  1.119074e-02  7.216369e-03  1.039911e-02
#>  [56] -3.727775e-03  5.107124e-03 -7.192475e-03  1.923232e-03 -8.992649e-03
#>  [61] -6.778903e-03  1.708481e-02 -2.461975e-03  5.762782e-04  3.409955e-03
#>  [66] -2.154789e-03 -6.682699e-03 -1.692232e-03 -4.019865e-03  1.008652e-03
#>  [71]  8.895351e-04  6.569989e-03 -7.766435e-04 -3.052818e-03  8.475069e-03
#>  [76] -2.405240e-03 -9.373586e-03 -8.767927e-04  1.427571e-02  5.469442e-04
#>  [81]  1.754719e-03  2.510200e-03 -5.075964e-03 -4.357281e-04  4.469405e-03
#>  [86] -1.907349e-04 -8.633267e-04 -1.042470e-02  3.311868e-03  5.606489e-03
#>  [91] -3.274916e-04  6.388307e-03 -9.340672e-03  1.677246e-02  5.462964e-03
#>  [96]  1.197832e-02 -6.138148e-04  2.595147e-05 -1.410057e-03 -2.170690e-03
#>  [ reached getOption("max.print") -- omitted 100 entries ]
summary(sim)
#> 
#> Simulated time series consisting of 200 observations.
#> 
#> Parameters: level of latent variable                  mu = -10
#>             persistence of latent variable           phi = 0.94
#>             standard deviation of latent variable  sigma = 0.15
#>             degrees of freedom parameter              nu = Inf
#>             leverage effect parameter                rho = -0.6
#> 
#> Simulated initial volatility (in %): 0.7671656 
#> 
#> Summary of simulated volatilities (in %):
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>  0.4440  0.5632  0.6491  0.6569  0.7390  0.9836 
#> 
#> Summary of simulated data (in %):
#>     Min.  1st Qu.   Median     Mean  3rd Qu.     Max. 
#> -1.39706 -0.51277  0.01506  0.06042  0.52334  1.98305 
plot(sim)


## Simulate an SV process with conditionally heavy-tails
sim <- svsim(250, phi = 0.91, sigma = 0.05, nu = 5)

print(sim)
#> 
#> Simulated time series consisting of 250 observations.
#> 
#> Parameters: level of latent variable                  mu = -10
#>             persistence of latent variable           phi = 0.91
#>             standard deviation of latent variable  sigma = 0.05
#>             degrees of freedom parameter              nu =5
#>             leverage effect parameter                rho =0
#> 
#> Simulated initial volatility:  
#> 
#> Simulated volatilities:
#>   [1] 0.004619307 0.005335778 0.006188869 0.005615938 0.003173798 0.005782844
#>   [7] 0.007811229 0.008755215 0.007147892 0.008545696 0.005572796 0.007570275
#>  [13] 0.004271683 0.005315423 0.005370006 0.006689740 0.009148576 0.006133111
#>  [19] 0.013311753 0.005358010 0.006287665 0.005309812 0.007395196 0.008443126
#>  [25] 0.007016668 0.003989852 0.007677396 0.005107099 0.031783065 0.004144746
#>  [31] 0.007670313 0.004413676 0.005987618 0.005382919 0.002890184 0.006916670
#>  [37] 0.004296875 0.006619563 0.007837161 0.005300284 0.004876098 0.006431780
#>  [43] 0.007988301 0.005015403 0.006304154 0.004196013 0.005835706 0.004683254
#>  [49] 0.003787832 0.004834938 0.005408869 0.005084058 0.005828229 0.003263511
#>  [55] 0.003805596 0.004104200 0.005324617 0.005272607 0.003501138 0.004239064
#>  [61] 0.003146070 0.003297297 0.004000925 0.004310036 0.006368322 0.007154465
#>  [67] 0.011375653 0.005316064 0.003099324 0.004761677 0.008534658 0.007702741
#>  [73] 0.004318417 0.007139918 0.006291584 0.005642954 0.005721722 0.004750624
#>  [79] 0.004536244 0.007516594 0.004729035 0.004117147 0.005841131 0.009113720
#>  [85] 0.006601619 0.005930370 0.004117813 0.007372154 0.004788917 0.006343189
#>  [91] 0.013020638 0.003459603 0.004287950 0.003558063 0.005701899 0.004945349
#>  [97] 0.003341632 0.008557253 0.005321142 0.005213324
#>  [ reached getOption("max.print") -- omitted 150 entries ]
#> 
#> Simulated data (usually interpreted as 'log-returns'):
#>   [1] -5.808214e-03 -1.004583e-02 -4.145181e-04  1.164962e-02  2.473624e-03
#>   [6] -1.178701e-02 -9.254086e-04 -1.252382e-03  5.200570e-03 -8.715682e-04
#>  [11] -4.691060e-03 -1.897618e-03 -4.547441e-03  4.053090e-03  9.796710e-03
#>  [16]  7.998138e-03  2.143241e-03  1.060631e-02 -7.963015e-05  3.449401e-03
#>  [21] -2.153593e-04  3.826189e-04  3.061289e-04  5.488026e-03  3.760581e-04
#>  [26]  8.207825e-03  1.258276e-02 -5.248495e-03  4.189010e-02  6.563916e-03
#>  [31]  3.676632e-03  4.826998e-04 -6.752034e-04 -1.577908e-03 -4.143089e-03
#>  [36]  5.445791e-03  5.963613e-03  2.109646e-03  7.790382e-03  4.300497e-03
#>  [41] -5.644867e-03 -2.239121e-02  1.250198e-03  8.755254e-03 -1.960107e-03
#>  [46] -9.238096e-03  8.641754e-04  2.149809e-03 -3.955010e-03 -3.831106e-03
#>  [51] -3.890604e-03 -4.784457e-03  6.957932e-03 -1.067639e-03  3.189064e-03
#>  [56] -1.251848e-03 -2.958615e-03  4.644346e-03 -1.693205e-03  8.764105e-04
#>  [61] -1.623288e-04 -1.812882e-03 -9.344675e-03 -3.317090e-04 -4.157014e-03
#>  [66]  8.292565e-04 -9.335607e-03 -3.166706e-03 -6.315585e-03 -3.816325e-03
#>  [71] -4.604013e-03  1.994609e-02 -1.534531e-03 -1.035300e-02 -6.825172e-03
#>  [76] -1.002597e-02 -6.907941e-03  4.559910e-03  7.401209e-03  7.394273e-03
#>  [81]  9.282513e-04  6.729885e-04 -1.111273e-02 -9.165389e-03 -5.086917e-03
#>  [86]  1.518689e-03  3.630063e-04  1.209369e-02  2.085619e-03  1.141328e-02
#>  [91]  2.117290e-02 -7.594539e-04 -1.881284e-03 -4.343455e-03 -6.421230e-03
#>  [96]  2.931719e-03 -5.943606e-03 -1.850949e-03 -8.741504e-04  2.694156e-04
#>  [ reached getOption("max.print") -- omitted 150 entries ]
summary(sim)
#> 
#> Simulated time series consisting of 250 observations.
#> 
#> Parameters: level of latent variable                  mu = -10
#>             persistence of latent variable           phi = 0.91
#>             standard deviation of latent variable  sigma = 0.05
#>             degrees of freedom parameter              nu = 5
#>             leverage effect parameter                rho = 0
#> 
#> Simulated initial volatility (in %): 0.711794 
#> 
#> Summary of simulated volatilities (in %):
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>  0.2134  0.4312  0.5364  0.6003  0.6980  3.1783 
#> 
#> Summary of simulated data (in %):
#>      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
#> -2.239121 -0.398024  0.004759  0.036864  0.399950  4.189010 
plot(sim)