Description Usage Arguments Details Author(s) Examples
Create correlation of specified size (vector input)
1 | sim_cor_vec(vector1, r, shuffles = 1000, vector2 = NULL)
|
vector1 |
A vector for which a correlated vector should be created. |
r |
Desired size of the correlation. Only takes values between -1 and 1. |
shuffles |
Specifies how many times vector2 should be shuffled at every step of the function. Defaults to 1000. |
vector2 |
Optional: a vector that should be reshuffled in order to create a correlation with vector1. If not provided, vector1 will we duplicated as vector2. |
Reshuffles a vector until a correlation of desired size with another vector is created. Does so by taking the shuffled version of the vector that comes closest to the desired correlation, then only reshuffles part of the data, depending on how close to a sufficient solution the result is.
Returns the two vectors with the desired correlation (one left untouched), the other reshuffled along with additional information like mean and SD of the two vectors as well as the desired and actual correlation.
Based on linear correlations (pearson).
Juli Tkotz juliane.tkotz@hhu.de
1 2 3 | vec1 <- 1:100
vec2 <- 101:200
cor.7 <- sim_cor_vec(vector1 = vec1, vector2 = vec2, r = .7, shuffles = 1000)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.