corrio {correlatio} | R Documentation |
Apply and visualize Pearson's product-moment correlation.
Description
Compute all components which are part of Pearson's correlation coefficient and visualize the most important part of what is summarized in the correlation coefficient. This most important part is the difference between the values of each variable from their respective mean. While it may appear superflous for some people to visualize this part, other people may benefit from it. See vignette of this 'correlatio' package for further explanations.
Usage
corrio(data = NULL, visualize = TRUE)
Arguments
data |
A data.frame with two columns, which shall be correlated by Pearson's product-moment method. |
visualize |
A single boolean value (default: TRUE), which determines whether the data shall be visualized. |
Value
a list with a data.frame (name: dat), a list (name: details), and two graphs as elements (plot1 and plot2). dat contains these five columns:
x Values of the first variable (= x).
y Values of the second variable (= y).
x-mean(x) Difference between x and the mean of x.
y-mean(y) Difference between y and the mean of y.
covVec Product of x-mean(x) and y-mean(y).
details is a list with 12 objects, each of which contains an explanation as attribute:
Mean of variable 1 (variable 1 = x).
Mean of variable 2 (variable 2 = y).
Sum of all negative products (negSum): (x-mean(x)) * (y-mean(y)).
Sum of all positive products (posSum): (x-mean(x)) * (y-mean(y)).
Numerator of covariance formula: Sum of negSum and posSum.
Denominator of covariance formula: n - 1.
Covariance: numeratorCov/denominatorCov.
Standard deviation of variable 1 (i.e., x): R command sd().
Standard deviation of variable 2 (i.e., y): R command sd().
Product of standard deviations (prodSD) of variables 1 and 2 (i.e., x and y).
Correlation: Covariance/prodSD.
Percentages of pairwise directions of s, c, n (s = same, c = contrary, n = no)
plot1 and plot2 are two ways of visualizing the connection between the individual values and their respective mean value.
Author(s)
Marcel Miché
References
Curran-Everett D (2010). “Explorations in statistics: correlation.” Advances in physiology education, 34(4), 186–191.
Wickham H, Wickham H (2016). “Programming with ggplot2.” Ggplot2: elegant graphics for data analysis, 241–253.
Examples
simData <- simcor(obs=100, rhos = .6)
corrio(data=simData[[1]], visualize = TRUE)