Skip to content

Instantly share code, notes, and snippets.

@pierreroudier
Created November 15, 2017 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pierreroudier/19d212cf664487174062c22a9e6fe310 to your computer and use it in GitHub Desktop.
Save pierreroudier/19d212cf664487174062c22a9e6fe310 to your computer and use it in GitHub Desktop.
Quick comparison R2-CCC
library(ggplot2)
library(dplyr)
# Creating dummy data
d <- data.frame(
x = rnorm(100,10,3)
) %>%
mutate(
y = jitter(x, factor = 800) - 5 * cos(x/10)
)
# You can see a good fit btw preds and obs, but not with the 1:1 line
d %>%
ggplot(aes(x = x, y = y)) +
geom_abline(slope = 1, intercept = 0, lty = 2, colour = "red") +
geom_smooth(method = "lm", colour = "royalblue") +
geom_point() +
coord_equal()
# This problem in the predictions is overlooked by R-squared,
# but taken into account by the CCC
caret::R2(d$x, d$y)
epiR::epi.ccc(d$x, d$y)$rho.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment