This function generates random data for the variance vector given by $$ \boldsymbol{\sigma}^{2} = \exp \left( \boldsymbol{\mu} + \boldsymbol{\varepsilon} \right) \quad \text{with} \quad \boldsymbol{\varepsilon} \sim \mathcal{N} \left( \boldsymbol{0}, \boldsymbol{\Sigma} \right) $$.
Arguments
- n
Integer. Number of samples to generate.
- location
Numeric vector. The constant term \(\boldsymbol{\mu}\).
- chol_scale
Numeric matrix. Cholesky decomposition of the covariance matrix \(\boldsymbol{\Sigma}\) for the multivariate normal random error \(\boldsymbol{\varepsilon}\).
Details
The SimVariance() function generates random data
for the variance vector
based on the exponential of a multivariate normal distribution.
Given the number of samples n,
the constant term \(\boldsymbol{\mu}\) represented
by the location vector,
and the Cholesky decomposition matrix \(\boldsymbol{\Sigma}\)
for the multivariate normal random error \(\boldsymbol{\varepsilon}\),
the function simulates \(n\) independent samples
of the variance vector \(\boldsymbol{\sigma}^{2}\).
Each sample of the variance vector \(\boldsymbol{\sigma}^{2}\)
is obtained by
calculating the exponential of random variations
to the mean vector \(\boldsymbol{\mu}\).
The random variations are generated using the Cholesky decomposition
of the covariance matrix \(\boldsymbol{\Sigma}\).
Finally, the function returns a matrix with each column
containing the simulated
variance vector for each sample.
See also
Other Simulation of Autoregressive Data Functions:
CheckARCoef(),
CheckVARCoef(),
SimARCoef(),
SimAR(),
SimMVN(),
SimPD(),
SimVARCoef(),
SimVARExo(),
SimVARZIPExo(),
SimVARZIP(),
SimVAR(),
YXExo(),
YX()
Examples
set.seed(42)
n <- 10L
location <- c(0.5, -0.2, 0.1)
chol_scale <- chol(
matrix(
data = c(1.0, 0.3, 0.3, 0.3, 1.0, 0.2, 0.3, 0.2, 1.0),
nrow = 3,
byrow = TRUE
)
)
SimVariance(n = n, location = location, chol_scale = chol_scale)
#> [,1] [,2] [,3]
#> [1,] 0.9689893 0.7585272 0.7924305
#> [2,] 3.7481137 0.9996338 4.4895809
#> [3,] 15.1416573 1.5035656 3.7702369
#> [4,] 2.2227268 1.7495933 2.7601779
#> [5,] 2.4715825 0.3260724 0.4488846
#> [6,] 0.8823452 8.3900712 5.4739282
#> [7,] 4.4290116 0.4908520 2.8647444
#> [8,] 5.9940375 1.2395299 2.0092362
#> [9,] 1.1732917 0.6006879 0.1449625
#> [10,] 9.6204947 2.9934125 0.7456370