Description Usage Arguments Details Author(s) Examples
Create correlation of specified size (parameter input)
1 2 | sim_cor_param(N, dist, arglist, r, shuffles = 1000, dist2 = NULL,
arglist2 = NULL)
|
N |
Size of the two vectors to be created. |
dist |
A character string determining the distribution the first vector should be sampled from. Can be set to 'normal' or 'unif'. See details. |
arglist |
A list of arguments provided to the distribution function that is used to create the first vector. See details. |
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. |
dist2 |
A character string determining the distribution the second vector should be sampled from. Can be set to 'normal' or 'unif'. See details. If not provided, the same distribution as for the first vector is used. |
arglist2 |
Optional: a list of arguments provided to the distribution function that is used to create the second vector. See details. If not provided, the same parameters as for the first vector are used. |
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).
Vectors of a desired size are drawn from a specified distribution.
Parameters for the distribution like mean, standard deviation or min/max
are provided as arguments in a list. Experimental danger zone, as there
will not always be error messages when parameters in arglist are not provided
correctly. When in doubt, generate vectors to be correlated outside the function
and then use sim_cor_vec
.
Distributions to choose from
- standard normal distribution as implemented in rnorm
(dist =
'normal'
). See rnorm
for possible arguments to be passed
in arglist
.
- uniform distribution as implemented in runif
(dist =
'unif'
). See runif
for possible arguments to be passed
in arglist
.
Juli Tkotz juliane.tkotz@hhu.de
1 2 3 4 5 6 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.