A Python Package for Stochastic Dominance Tests
PySDTest is a Python 3 implementation of routines for Stochastic Dominance tests. This package was created by Kyungho Lee in collaboration with Yoon-Jae Whang.
This package implements stochastic dominance tests proposed by Barrett and Donald (2003, BD), Linton, Maasoumi and Whang (2005, LMW), Linton, Song and Whang (2010, LSW), Donald and Hsu (2014, DH). PySDTest also contains stochastic dominance tests by applying the numerical delta method (Hong and Li (2018, HL)).
PySDTest is listed on the Python Package Index (PyPI) which is a repository of software for the Python programming language. If Python is installed on your computer, you can install PySDTest by entering:
pip install PySDTest
in Windows cmd or Mac (or Linux) terminal. For detailed information about installing a Python package, see Python Package User Guide in PyPI.
After installing PySDTest, an user can import it through the following code:
import pysdtest
- Stochastic dominance (SD) testing via imposing the least favorable case (BD, LMW)
- SD testing via Contact-set approach (LSW)
- SD testing via Selective recentering approach (DH)
- SD testing via Numerical delta method (HL)
- Advanced hypotheses testing (Joint hypotheses testing)
- Plotting (s-th order) CDFs
- Resampling: bootstrap, subsampling, and paired-bootstrap
Python provides significant advantage regarding interaction with other programming languages and statistical software. Our package can be used in MATLAB, R, Julia, and Stata.
In MATLAB, an user can implement PySDTest as:
% Calling PySDTest in MATLAB
py.pysdtest
The reticulate library in R and the PyCall package in Julia serve similar feature, which calls Python modules in R and Julia, respectively:
# Calling PySDTest in R
library(reticulate)
pysdtest <- import("pysdtest")
# Calling PySDTest in Julia
using PyCall
pysdtest = pyimport("pysdtest")
In Stata, an user can call PySDTest by plugging python codes in between Python: and end. For example, the following codes work for importing PySDTest:
" Calling PySDTest in Stata "
python:
import pysdtest
end
In addition, a user can use python command in Stata to activate Python environment in Stata. For more detailed information, please refer to the Using MATLAB with Python in MATLAB, reticulate library in R, PyCall package in Julia and Python integration feature in Stata.