The goal of agreeable is to provide a set of simple tools to assess agreement between two matching datasets. The specific use case under which this package was developed is to assess the agreement between modeled and observed datasets.
Computations following Ji and Gallo 2006.
Here are some of the basic tools made available by agreeable…
library(agreeable)
library(ggplot2)
library(knitr)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(data.table)
#>
#> Attaching package: 'data.table'
#> The following objects are masked from 'package:dplyr':
#>
#> between, first, last
set.seed(123)
data <- data.table(
observed = sort(rnorm(500, mean = 300, sd = 75)),
predicted_systematic = sort(rnorm(500, mean = 275, sd = 100))
)
sds <- c(1, 5, 10, 30, 50, 75, 100, 150)
data$predicted_unsystematic <- sort(rnorm(500, mean = 300, sd = sds))
Compute AC (agreement coefficient), ACs (systematic agreement), ACu (unsystematic agreement), PUD (percentage of unsystematic difference), and PSD (percentage of systematic difference):
Systematic differences dominate:
knitr::kable(
data.table::data.table(
AC = data %>% ac(observed, predicted_systematic),
ACs = data %>% acs(observed, predicted_systematic),
ACu = data %>% acu(observed, predicted_systematic),
PUD = data %>% pud(observed, predicted_systematic),
PSD = data %>% psd(observed, predicted_systematic)
)
)
AC | ACs | ACu | PUD | PSD |
---|---|---|---|---|
0.8659736 | 0.8691102 | 0.9968634 | 0.0234028 | 0.9765972 |
Unsystematic (random) differences dominate:
knitr::kable(
data.table::data.table(
AC = data %>% ac(observed, predicted_unsystematic),
ACs = data %>% acs(observed, predicted_unsystematic),
ACu = data %>% acu(observed, predicted_unsystematic),
PUD = data %>% pud(observed, predicted_unsystematic),
PSD = data %>% psd(observed, predicted_unsystematic)
)
)
AC | ACs | ACu | PUD | PSD |
---|---|---|---|---|
0.8553422 | 0.9967902 | 0.858552 | 0.9778108 | 0.0221892 |
Scatter plot with 1:1 and Geometric Mean Functional Relationship (GMFR) lines:
Systematic differences dominate:
inter <- data %>% gmfr_intercept(observed, predicted_systematic)
slope <- data %>% gmfr_slope(observed, predicted_systematic)
ggplot2::ggplot(data, aes(x=observed, y = predicted_systematic)) +
ggplot2::geom_point(
alpha = 0.7,
color = "black"
) +
ggplot2::geom_abline(aes(slope = 1, intercept = 0, color = "black")) +
ggplot2::geom_abline(aes(slope = slope, intercept = inter, color = "orange")) +
ggplot2::scale_color_identity(
labels=c("1:1", "GMFR"),
guide="legend",
name = ""
)
Unsystematic (random) differences dominate:
inter <- data %>% gmfr_intercept(observed, predicted_unsystematic)
slope <- data %>% gmfr_slope(observed, predicted_unsystematic)
ggplot2::ggplot(data, aes(x = observed, y = predicted_unsystematic)) +
ggplot2::geom_point(
alpha = 0.7,
color = "black"
) +
ggplot2::geom_abline(aes(slope = 1, intercept = 0, color = "black")) +
ggplot2::geom_abline(aes(slope = slope, intercept = inter, color = "orange")) +
ggplot2::scale_color_identity(
labels=c("1:1", "GMFR"),
guide="legend",
name = ""
)
There is no released version of agreeable yet.
You can install the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("lucas-johnson/agreeable")