View source: R/Stochastic_superiority.R
| NNS.SS | R Documentation |
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.
NNS.SS(
x,
y,
confidence.interval = FALSE,
reps = 999,
ci = 0.95,
rho = 1
)
x |
a numeric vector. |
y |
a numeric vector. |
confidence.interval |
logical; |
reps |
numeric; number of maximum entropy bootstrap replicates used when
|
ci |
numeric in |
rho |
numeric; dependence target passed to |
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.
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.
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.
Fred Viole, OVVO Financial Systems
Vinod, H.D. and Viole, F. (2020) Arbitrary Spearman's Rank Correlations in Maximum Entropy Bootstrap and Improved Monte Carlo Simulations. \Sexpr[results=rd]{tools:::Rd_expr_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/.
## Not run:
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)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.