sim_cor_vec: Create correlation of specified size (vector input)

Description Usage Arguments Details Author(s) Examples

Description

Create correlation of specified size (vector input)

Usage

1
sim_cor_vec(vector1, r, shuffles = 1000, vector2 = NULL)

Arguments

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.

Details

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).

Author(s)

Juli Tkotz juliane.tkotz@hhu.de

Examples

1
2
3
vec1 <- 1:100
vec2 <- 101:200
cor.7 <- sim_cor_vec(vector1 = vec1, vector2 = vec2, r = .7, shuffles = 1000)

einGlasRotwein/cmonCorr documentation built on May 6, 2019, 8:29 p.m.