Skip to contents

Allow user to draw from a random normal distribution correlated with a user specified vector

Usage

rnormcorV(x, rho, ...)

Arguments

x

variable to draw from

rho

correlation coefficient between x and result of function

...

unused, reserved for future extensions

Value

a vector of the same length as x drawn from a normal distribution correlated with x at the level of rho

Details

Rough estimate, biased by known amount for now

Author

Jared E. Knowles

Examples

x <- rnorm(1000, 1, 1)
y <- rnormcorV(x, 0.2)
cor(x,y) # very close to 0.2
#> [1] 0.1947262
mean(y) # close to 0
#> [1] 0.1618008
sd(y)   # close to 1
#> [1] 0.9892702