How to generate a sequence of numbers, which would have a specific correlation (for example 0.56) and would consist of.. say 50 numbers with R program?
Ty.
How to generate a sequence of numbers, which would have a specific correlation (for
Share
Assuming you mean two normal/Gaussian vectors of values with correlation 0.56
We can use
mvrnorm()from package MASSwhich gives
The
empirical = TRUEbit is important otherwise the actual correlation achieved is subject to randomness too and will not be exactly the stated value with larger discrepancies for smaller samples.Assuming you mean a lag 1 correlation of 0.56 & Gaussian random variables
For this one you can use the
arima.sim()function: