Skip to content

WIP: Adding Likelihood Q Ratio Test (LQRT) #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Byte-compiled / optimized / DLL files
__pycache__/
.idea/*
*.py[cod]
*$py.class

Expand Down
30 changes: 30 additions & 0 deletions dabest/_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ def __init__(self, control, test, effect_size,
from numpy.random import choice, seed

import scipy.stats as spstats
import lqrt

# import statsmodels.stats.power as power

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

# Likelihood Q-Ratio test:
# Assumes a gross-error model of distributions
try:
if self.__is_paired:
lqrt_ratio = lqrt.lqrtest_rel(control, test)
else:
lqrt_ratio = lqrt.lqrtest_ind(control, test)
self.__pvalue_lqrt = lqrt_ratio.pvalue
self.__statistic_lqrt = lqrt_ratio.statistic
except ImportError:
# did not install necessary library to run robust lqrt statistic
# warnings.warn("To get")
pass

standardized_es = es.cohens_d(control, test, is_paired=False)
# self.__power = power.tt_ind_solve_power(standardized_es,
# len(control),
Expand Down Expand Up @@ -874,6 +889,21 @@ def statistic_wilcoxon(self):
except AttributeError:
return npnan

@property
def pvalue_lqrt(self):
from numpy import nan as npnan
try:
return self.__pvalue_lqrt
except AttributeError:
return npnan

@property
def statistic_lqrt(self):
from numpy import nan as npnan
try:
return self.__statistic_lqrt
except AttributeError:
return npnan


@property
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
'pandas~=0.25,!=0.25.2',

'matplotlib~=3.0',
'seaborn~=0.9'
'seaborn~=0.9',
'lqrt>=0.3.2'
],
extras_require={'dev': ['pytest~=5.2', 'pytest-mpl~=0.10']},
python_requires='~=3.5',
Expand Down