Computes stochastic superiority between two numeric vectors as the empirical
probability that an observation from x exceeds an observation from
y, with optional tie adjustment and optional confidence intervals via
maximum entropy bootstrap.
Arguments
- x
a numeric vector.
- y
a numeric vector.
- confidence.interval
logical;
FALSE(default) returns only the empirical stochastic superiority measures. Set toTRUEto compute bootstrap confidence intervals forp_star.- reps
numeric; number of maximum entropy bootstrap replicates used when
confidence.interval = TRUE. Default is999.- ci
numeric in \((0, 1)\); confidence level used for the bootstrap interval when
confidence.interval = TRUE. Default is0.95.- rho
numeric; dependence target passed to
NNS.meboot. Default is1.
Value
If confidence.interval = FALSE, returns a list containing:
p_gtempirical probability that
x > y.p_tieempirical probability that
x = y.p_startie-adjusted stochastic superiority probability.
If confidence.interval = TRUE, returns a list containing:
p_gtempirical probability that
x > y.p_tieempirical probability that
x = y.p_startie-adjusted stochastic superiority probability.
lowerlower confidence bound for
p_star.upperupper confidence bound for
p_star.ciconfidence level used.
repsnumber of bootstrap replicates used.
boot_valsbootstrap replicate values of
p_star.
Details
NNS.SS returns:
$$P(X > Y),$$
the tie probability
$$P(X = Y),$$
and the tie-adjusted stochastic superiority measure
$$P^* = P(X > Y) + \frac{1}{2} P(X = Y).$$
When confidence.interval = TRUE, confidence bounds for P^*
are computed from NNS.meboot bootstrap replicates using
LPM.VaR and UPM.VaR with degree = 0.
Missing values are removed from both x and y using
stats::na.omit. The empirical estimates are computed via a fast sorted
comparison routine rather than explicit pairwise expansion of all
x-y combinations.
For continuous data, p_tie will typically be zero, so p_star
and p_gt will be identical up to numerical precision. For discrete
data, p_star provides the standard tie-adjusted superiority measure.
When confidence.interval = TRUE, the interval is constructed from the
empirical bootstrap distribution of p_star, where
\(\alpha = 1 - ci\). The lower bound is obtained from
LPM.VaR evaluated at \(\alpha / 2\), and the upper bound is
obtained from UPM.VaR evaluated at \(\alpha / 2\), both with
degree = 0.
Note
This function measures stochastic superiority as a pairwise exceedance
probability. This is distinct from first-, second-, or third-degree
stochastic dominance; see NNS.FSD, NNS.SSD, and
NNS.TSD for dominance testing.
References
Vinod, H.D. and Viole, F. (2020) Arbitrary Spearman's Rank Correlations in Maximum Entropy Bootstrap and Improved Monte Carlo Simulations. doi:10.2139/ssrn.3621614
Viole, F. and Nawrocki, D. (2013) Nonlinear Nonparametric Statistics: Using Partial Moments. ISBN: 1490523995, 2nd edition: https://ovvo-financial.github.io/NNS/book/.
Examples
if (FALSE) { # \dontrun{
set.seed(123)
x <- rnorm(200, mean = 0.4, sd = 1)
y <- rnorm(200, mean = 0.0, sd = 1)
# Empirical stochastic superiority
NNS.SS(x, y)
# With confidence intervals
NNS.SS(x, y, confidence.interval = TRUE, reps = 999, ci = 0.95)
# Discrete example with ties
x <- sample(1:5, 100, replace = TRUE)
y <- sample(1:5, 100, replace = TRUE)
NNS.SS(x, y)
} # }