Style fixups
This commit is contained in:
parent
255ad100fd
commit
a753761675
@ -14,7 +14,7 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from .bayes_factors import BayesFactor, bayesfactor_afbf
|
from .bayes_factors import bayesfactor_afbf
|
||||||
from .distributions import beta_oddsratio, beta_ratio, hdi, transformed_dist
|
from .distributions import beta_oddsratio, beta_ratio, hdi, transformed_dist
|
||||||
from .fs import pickle_read_compressed, pickle_read_encrypted, pickle_write_compressed, pickle_write_encrypted
|
from .fs import pickle_read_compressed, pickle_read_encrypted, pickle_write_compressed, pickle_write_encrypted
|
||||||
from .regress import PenalisedLogit, regress, vif
|
from .regress import PenalisedLogit, regress, vif
|
||||||
|
@ -15,9 +15,7 @@
|
|||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
class BayesFactor:
|
class BayesFactor:
|
||||||
"""
|
"""A Bayes factor"""
|
||||||
A Bayes factor
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, factor, num_symbol, num_desc, denom_symbol, denom_desc):
|
def __init__(self, factor, num_symbol, num_desc, denom_symbol, denom_desc):
|
||||||
self.factor = factor
|
self.factor = factor
|
||||||
|
@ -284,9 +284,7 @@ transformed_dist = transformed_gen(name='transformed')
|
|||||||
ConfidenceInterval = collections.namedtuple('ConfidenceInterval', ['lower', 'upper'])
|
ConfidenceInterval = collections.namedtuple('ConfidenceInterval', ['lower', 'upper'])
|
||||||
|
|
||||||
def hdi(distribution, level=0.95):
|
def hdi(distribution, level=0.95):
|
||||||
"""
|
"""Get the highest density interval for the distribution, e.g. for a Bayesian posterior, the highest posterior density interval (HPD/HDI)"""
|
||||||
Get the highest density interval for the distribution, e.g. for a Bayesian posterior, the highest posterior density interval (HPD/HDI)
|
|
||||||
"""
|
|
||||||
|
|
||||||
# For a given lower limit, we can compute the corresponding 95% interval
|
# For a given lower limit, we can compute the corresponding 95% interval
|
||||||
def interval_width(lower):
|
def interval_width(lower):
|
||||||
|
@ -188,9 +188,7 @@ class PearsonChiSquaredResult:
|
|||||||
self.ct, self.dof, self.statistic, fmt_p(self.pvalue, html=False))
|
self.ct, self.dof, self.statistic, fmt_p(self.pvalue, html=False))
|
||||||
|
|
||||||
def chi2(df, dep, ind, *, nan_policy='warn'):
|
def chi2(df, dep, ind, *, nan_policy='warn'):
|
||||||
"""
|
"""Perform a Pearson chi-squared test"""
|
||||||
Perform a Pearson chi-squared test
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Check for/clean NaNs
|
# Check for/clean NaNs
|
||||||
df = check_nan(df[[ind, dep]], nan_policy)
|
df = check_nan(df[[ind, dep]], nan_policy)
|
||||||
@ -209,7 +207,7 @@ def chi2(df, dep, ind, *, nan_policy='warn'):
|
|||||||
|
|
||||||
if ct.shape == (2,2):
|
if ct.shape == (2,2):
|
||||||
# 2x2 table
|
# 2x2 table
|
||||||
# Use statsmodels to get OR andRR
|
# Use statsmodels to get OR and RR
|
||||||
|
|
||||||
smct = sm.stats.Table2x2(np.flip(ct.to_numpy()), shift_zeros=False)
|
smct = sm.stats.Table2x2(np.flip(ct.to_numpy()), shift_zeros=False)
|
||||||
result = smct.test_nominal_association()
|
result = smct.test_nominal_association()
|
||||||
|
Loading…
Reference in New Issue
Block a user