Type: | Package |
Title: | Data Transformation or Simulation with Empirical Covariance Matrix |
Version: | 1.0.1 |
Date: | 2020-02-02 |
Author: | Anthony Christidis <anthony.christidis@stat.ubc.ca>, Stefan Van Aelst <stefan.vanaelst@kuleuven.be>, Ruben Zamar <ruben@stat.ubc.ca> |
Maintainer: | Anthony Christidis <anthony.christidis@stat.ubc.ca> |
Description: | Transforms or simulates data with a target empirical covariance matrix supplied by the user. The method to obtain the data with the target empirical covariance matrix is described in Section 5.1 of Christidis, Van Aelst and Zamar (2019) <doi:10.48550/arXiv.1812.05678>. |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Biarch: | true |
Imports: | MASS, stats |
RoxygenNote: | 7.0.2 |
Suggests: | testthat |
NeedsCompilation: | no |
Packaged: | 2020-02-05 18:06:01 UTC; antho |
Repository: | CRAN |
Date/Publication: | 2020-02-05 19:00:02 UTC |
Data Transformation or Simulation with Target Empirical Covariance Matrix
Description
simTargetCov
transforms or simulates data with a target empirical covariance matrix supplied by the user.
Usage
simTargetCov(n, p, target, X = NULL)
Arguments
n |
Number of observations for data matrix output. |
p |
Number of variables for data matrix output. |
target |
Target empirical covariance for data matrix output. |
X |
Data matrix for transformation. |
Author(s)
Anthony-Alexander Christidis, anthony.christidis@stat.ubc.ca
Examples
# Function to create target covariance matrix with kernel set to r
target_cor <- function(r, p){
Gamma <- diag(p)
for(i in 1:(p-1)){
for(j in (i+1):p){
Gamma[i,j] <- Gamma[j,i] <- r^(abs(i-j))
}
}
return(Gamma)
}
# Transformation of data to target empirical covariance
dat.target.cov <- simTargetCov(X = MASS::mvrnorm(30, mu = rep(0,6),
Sigma = target_cor(0.5,6)),
target = target_cor(0.5,6))
round(cov(dat.target.cov), 2)
# Simulation of data with target empirical covariance
sim.target.cov <- simTargetCov(n = 30, p = 6, target = target_cor(0.5,6))
round(cov(sim.target.cov), 2)