get_corvars: Generate normal, correlated variables

Description Usage Arguments Value Author(s) Examples

Description

[Stable]

Given the mean and desired correlations, generate normal, correlated variables.

Usage

1
get_corvars(n = 10, mu, sigma, tol = 1e-06, seed = NULL)

Arguments

n

The number of samples required.

mu

A vector with the means for the variables.

sigma

A symmetric, positive-definite matrix with the (co)variance or correlation matrix of the variables.

tol

Tolerance (relative to largest variance) for numerical lack of positive-definiteness in sigma.

seed

An integer value interpreted as seed.

Value

A tibble containing the simulated data.

Author(s)

Tiago Olivoto tiagoolivoto@gmail.com

Examples

1
2
3
4
5
6
7
8
sigma <- matrix(c(1,  .3,  0,
                  .3,   1, .9,
                  0,   .9,  1),3,3)
mu <- c(6,50,5)

df <- get_corvars(n = 10000, mu = mu, sigma = sigma, seed = 101010)
means_by(df)
cor(df)

metan documentation built on Nov. 10, 2021, 9:11 a.m.