Learn R Programming

ecodist (version 1.1.0)

corgen: Generate correlated data

Description

Generate correlated data vectors of a given length.

Usage

corgen(len, r, population = FALSE, epsilon = 0)

Arguments

len
Length of data vectors.
r
Correlation between data vectors.
population
TRUE for vectors drawn from two populations with correlation r, otherwise r is the sample correlation.
epsilon
If epsilon = 0, it has no effect, otherwise the sampling process is repeated until the sample correlation is within epsilon of r. This option allows the production of exactly-correlated data, within the limits of epsilon.

Value

  • If it is a LIST, use
  • xFirst data vector.
  • ySecond data vector.
  • ...

Details

This function is more sophisticated that the corgen function available in the stats package.

See Also

~~objects to See Also as help, ~~~

Examples

Run this code
# create two random variables of length 100 with correlation 
# of 0.10 +/- 0.00001
corgen(100, .1, epsilon=0.00001)

Run the code above in your browser using DataLab