corvectors() is a function to obtain a multivariate dataset by specifying the relation between those specified variables.

corvectors(
  data,
  corm,
  tol = 0.005,
  conv = 10000,
  cores = 2,
  splitsize = 1000,
  verbose = FALSE,
  seed
)

Arguments

data

a data matrix containing the data

corm

A value containing the desired correlation or a vector or data matrix containing the desired correlations

tol

A single value or a vector of tolerances with length ncol(data) - 1. The default is 0.005

conv

The maximum iterations allowed. Defaults to 1000.

cores

The number of cores to be used for parallel computing

splitsize

The size to use for splitting the data

verbose

Logical statement. Default is FALSE

seed

An optional seed to set

Value

corvectors() returns a matrix given the specified multivariate relation.

Details

This is liberally copy-pasted from van Kooten and Vink's wonderful-but-no-longer-supported correlate package. They call it correlate() in their package, but I opt for corvectors() here.

Author

Pascal van Kooten and Gerko Vink

Examples

# \donttest{ set.seed(8675309) library(tibble) # bivariate example, start with zero correlation as_tibble(data.frame(corvectors(replicate(2, rnorm(100)), .5)))
#> # A tibble: 100 x 2 #> X1 X2 #> <dbl> <dbl> #> 1 0.722 0.592 #> 2 0.684 -0.958 #> 3 -1.31 -0.827 #> 4 1.57 1.44 #> 5 0.214 1.49 #> 6 -0.415 -0.319 #> 7 -0.652 -2.09 #> 8 -0.151 -0.112 #> 9 -0.00379 -0.261 #> 10 -0.926 0.146 #> # … with 90 more rows
# multivariate example as_tibble(data.frame(corvectors(replicate(4, rnorm(100)), c(.5, .6, .7))))
#> # A tibble: 100 x 4 #> X1 X2 X3 X4 #> <dbl> <dbl> <dbl> <dbl> #> 1 -0.574 0.944 -0.472 -0.143 #> 2 -1.72 -1.15 -1.43 -1.79 #> 3 0.495 -0.776 0.936 0.542 #> 4 0.436 -0.555 3.12 1.32 #> 5 -1.06 -0.770 -0.204 -0.977 #> 6 0.832 -0.344 -0.154 -0.494 #> 7 0.127 -0.000558 0.425 -0.436 #> 8 -0.326 -0.742 -2.73 -0.822 #> 9 0.412 0.625 -0.850 1.07 #> 10 -0.286 -1.38 -0.154 -0.668 #> # … with 90 more rows
# }