% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/network.confusion.R
\name{network.confusion}
\alias{network.confusion}
\title{Confusion Matrix Metrics for Edge Comparison and Recovery}
\usage{
network.confusion(
  base,
  comparison,
  metric = c("all", "sen", "spec", "ppv", "npv", "fdr", "fom", "ba", "f1", "csi", "mcc"),
  full.names = FALSE
)
}
\arguments{
\item{base}{Matrix or data frame.
Network that will be treated as the "ground truth" such that
a false positive represents an edge that is present in \code{comparison}
but not in this network}

\item{comparison}{Matrix or data frame.
Network that will be treated as the estimator such that a
false positive represents an edge that is present in this network
but not in \code{base}}

\item{metric}{Character vector.
Defaults to \code{"all"} metrics.
Available options:

\itemize{

\item \code{"all"} --- All available metrics (default)

\item \code{"sen"} --- Sensitivity (True Positive Rate):
\deqn{\frac{TP}{TP + FN}}

\item \code{"spec"} --- Specificity (True Negative Rate):
\deqn{\frac{TN}{TN + FP}}

\item \code{"ppv"} --- Positive Predictive Value (Precision):
\deqn{\frac{TP}{TP + FP}}

\item \code{"npv"} --- Negative Predictive Value:
\deqn{\frac{TN}{TN + FN}}

\item \code{"fdr"} --- False Discovery Rate:
\deqn{1 - PPV = \frac{FP}{TP + FP}}

\item \code{"fom"} --- False Omission Rate:
\deqn{1 - NPV = \frac{FN}{TN + FN}}

\item \code{"ba"} --- Balanced Accuracy:
\deqn{\frac{Sensitivity + Specificity}{2}}

\item \code{"f1"} --- F1 Score (harmonic mean of PPV and Sensitivity):
\deqn{\frac{2TP}{2TP + FP + FN}}

\item \code{"csi"} --- Critical Success Index (Jaccard / Threat Score):
\deqn{\frac{TP}{TP + FP + FN}}

\item \code{"mcc"} --- Matthews Correlation Coefficient:
\deqn{\frac{TP \times TN - FP \times FN}{\sqrt{(TP+FP)(TP+FN)(TN+FP)(TN+FN)}}}

}}

\item{full.names}{Boolean (length = 1).
Whether full or abbreviated names should be used.
Defaults to \code{FALSE}.
Set to \code{TRUE} for full names}
}
\value{
Returns a named vector of confusion matrix metrics
}
\description{
Computes many commonly used confusion matrix metrics
}
\examples{
# Load data
wmt <- wmt2[,7:24]

# Set split
split <- sample(1:nrow(wmt), round(nrow(wmt) / 2))

# Estimate networks
split1 <- network.estimation(wmt[split,])
split2 <- network.estimation(wmt[-split,])

# Estimate metrics
network.confusion(split1, split2)

}
\author{
Hudson Golino <hfg9s at virginia.edu> and Alexander P. Christensen <alexpaulchristensen@gmail.com>
}
