Learn R Programming

RSD

RSD (R Stochastic Dominance) is designed and developed to calculate Stochastic Dominance (SD) and Almost Stochastic Dominance (ASD) in general. In more details, given two probability mass functions (PMF), this package helps with:

  • Calculate the first and second order SD values (FSD and SSD, respectively),
  • Calculate the first and second order ASD values (AFSD and ASSD, respectively),
  • Compare two probability distributions by these methods.

Installation

Install the released version of RSD from CRAN by:

install.packages("RSD")

Or from GitHub by:

install.packages("pak")
pak::pkg_install("ShayanTohidi/RSD")

Getting Started

RSD provides a function, createStochasticDominance() to create the SD object to be used in all other functions of this package. This function requires two discrete distributions. Here, the example data set data_ex will be used for creating the object:

library(RSD)
outcome1 = data_ex$yield[data_ex$gen == 'B73/PHM49']
outcome2 = data_ex$yield[data_ex$gen == 'LH74/PHN82']
pr = rep(1/29,29)
sd.obj = createStochasticDominance(outcome1, outcome2, pr, pr)

Using this code, we can compare the distributions of the performance (yield) of two cultivars. The output of this code snippet, sd.obj contains all information for performing SD and ASD comparisons. This is the main argument in the other functions of this package.

Copy Link

Version

Install

install.packages('RSD')

Monthly Downloads

157

Version

0.2.0

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Shayan Tohidi

Last Published

June 21st, 2025

Functions in RSD (0.2.0)

ssd.calc

Calculates the SSD values for a prospect.
pos.neg.area.assd.ll

Calculates positive and negative area between CDFs for ASSD-LL
comparison

Comparing two numeric vectors
createStochasticDominance

Constructor of StochasticDominance Class
ssd.plot

Drawing the SSD
has.intersection

If two lines have intersection or no.
ssd.test

Compares random prospects by SSD
modif.outcome.ssd.calc

Modify outcome and SSD vectors
afsd.test

Compares prospects based on AFSD
StochasticDominance-class

StochasticDominance Class
area.btwn.cdfs.calc

Calculates area between CDFs
assd.ths.test

Compares random prospects by ASSD-THS
assd.test

Compares prospects based on ASSD methods
area.below.ssd.calc

Calculates area below SSD function
calc.area.below.line

Calculates the area between x-axis and a straight line
assd.ll.test

Compares random prospects by ASSD-LL
calc.intersection

Calculates the intersection point of two lines.
area.btwn.ssd.calc

Calculates area between SSD functions
fsd.plot

Drawing the CDFs
fsd.test

Compares random prospects by FSD
data_ex

The example dataset
expected.values

Calculating Expected value