Skip to content

Commit a2f2d60

Browse files
authored
Merge pull request #85 from adam2392/dev-lqrt
Adding Likelihood Q Ratio Test (LQRT)
2 parents 7015b81 + 39d9b00 commit a2f2d60

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Byte-compiled / optimized / DLL files
22
__pycache__/
3+
.idea/*
34
*.py[cod]
45
*$py.class
56

dabest/_classes.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ def __init__(self, control, test, effect_size,
470470
from numpy.random import choice, seed
471471

472472
import scipy.stats as spstats
473+
import lqrt
473474

474475
# import statsmodels.stats.power as power
475476

@@ -658,6 +659,20 @@ def __init__(self, control, test, effect_size,
658659
# in terms of rank (eg. all zeros.)
659660
pass
660661

662+
# Likelihood Q-Ratio test:
663+
# Assumes a gross-error model of distributions
664+
try:
665+
if self.__is_paired:
666+
lqrt_ratio = lqrt.lqrtest_rel(control, test)
667+
else:
668+
lqrt_ratio = lqrt.lqrtest_ind(control, test)
669+
self.__pvalue_lqrt = lqrt_ratio.pvalue
670+
self.__statistic_lqrt = lqrt_ratio.statistic
671+
except ImportError:
672+
# did not install necessary library to run robust lqrt statistic
673+
# warnings.warn("To get")
674+
pass
675+
661676
standardized_es = es.cohens_d(control, test, is_paired=False)
662677
# self.__power = power.tt_ind_solve_power(standardized_es,
663678
# len(control),
@@ -874,6 +889,21 @@ def statistic_wilcoxon(self):
874889
except AttributeError:
875890
return npnan
876891

892+
@property
893+
def pvalue_lqrt(self):
894+
from numpy import nan as npnan
895+
try:
896+
return self.__pvalue_lqrt
897+
except AttributeError:
898+
return npnan
899+
900+
@property
901+
def statistic_lqrt(self):
902+
from numpy import nan as npnan
903+
try:
904+
return self.__statistic_lqrt
905+
except AttributeError:
906+
return npnan
877907

878908

879909
@property

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
'pandas~=0.25,!=0.25.2',
4545

4646
'matplotlib~=3.0',
47-
'seaborn~=0.9'
47+
'seaborn~=0.9',
48+
'lqrt>=0.3.2'
4849
],
4950
extras_require={'dev': ['pytest~=5.2', 'pytest-mpl~=0.10']},
5051
python_requires='~=3.5',

0 commit comments

Comments
 (0)