nlcor | R Documentation |
Compute nonlinear correlation using adaptive spatial sampling.
nlcor( x, y, refine = NA, plt = T, line_thickness = 1, line_opacity = 1, chart_title = NA )
x |
A numeric vector. NAs are not allowed. The length of the vector should be more than 10. |
y |
A numeric vector. NAs are not allowed. Length should be same as 'x'. The order of 'x' and 'y' are relevant. 'nlcor(x, y)“ is not equal to 'nlcor(y, x)'. Therefore, 'x' should be a causal and 'y' should be a dependent variable. |
refine |
Optional. If manually set, a small value, e.g., 0.01, increases the granularity of local correlation computation. The runtime is faster if 'refine' is manually set. Otherwise, the algorithm automatically finds the best refinement. |
plt |
Optional. Default value FALSE. Set TRUE to return ggplot2 object for the data correlation visualization. |
line_thickness |
Optional. Default 1. Thickness of the correlation lines. It is a float argument > 0. |
line_opacity |
Optional. Default 1, completely opaque. The opacity of the correlation lines. A float between 0-1. 0 is transparent. |
The output is a list containing the nonlinear correlation cor.estimate
, adjusted.p.value
, and cor.plot
. cor.estimate
is between 0 and 1 (a negative nonlinear correlation is undefined). The
adjusted.p.value
shows the statistical significance of the
cor.estimate
. If adjusted.p.value > 0.05
, the nonlinear
correlation estimate can be considered as noise (statistically not
significant). If plt = T
, ggplot2
object is return for
plotting the identified local linear correlations in the data.
cor
library(nlcor) library(ggplot2) ncor <- nlcor(x1, y1) ncor <- nlcor(x2, y2, plt = TRUE) ncor <- nlcor(x3, y3, refine = 0.01, plt = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.