I am running a correlation analysis to find the entities in the dataset that are similar to each other.
In the next step I want to check the correlations, just to see how reliable the numbers are.
That's easy for strict linear (aka Pearson) correlation, using geom_smooth(method = "lm), however is there an easy way to approximate or show the outcome of a non-linear fit, e.g. Spearman or Kendall.
Using loess with a wide span?
Toy example:
cor(mtcars$disp, mtcars$mpg) # default is pearson
# [1] -0.8475514
cor(mtcars$disp, mtcars$mpg, method = "spearman")
# [1] -0.9088824
cor(mtcars$disp, mtcars$mpg, method = "kendall")
# [1] -0.7681311
# linear fit
ggplot(mtcars,
aes(x = disp,
y = mpg)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) # linear fit is equivalent to pearson correlation
# nonlinear fit - does this match spearman?
ggplot(mtcars,
aes(x = disp,
y = mpg)) +
geom_point() +
geom_smooth(method = "loess",
span = 2,
se = FALSE)
example real world outcome: