Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import scipy.stats
- import itertools
- from pprint import pprint
- n_treat_hyper, n_treat_non = 11, 39
- n_control_hyper, n_control_non = 15, 11
- icu_treat_total = 1
- icu_control_total = 13
- corrected_pvals = {}
- for icu_treat_hyper, icu_control_hyper in\
- itertools.product(range(1+icu_treat_total), range(1+icu_control_total)):
- icu_treat_non = icu_treat_total - icu_treat_hyper
- icu_control_non = icu_control_total - icu_control_hyper
- if n_control_hyper - icu_control_hyper < 0 or n_control_non - icu_control_non < 0:
- continue
- pval_hyper = scipy.stats.fisher_exact(
- [[icu_treat_hyper, n_treat_hyper - icu_treat_hyper],
- [icu_control_hyper, n_control_hyper - icu_control_hyper]])[1]
- pval_non = scipy.stats.fisher_exact(
- [[icu_treat_non, n_treat_non - icu_treat_non],
- [icu_control_non, n_control_non - icu_control_non]])[1]
- corrected_pvals[icu_treat_hyper, icu_control_hyper] = [2*pval_hyper, 2*pval_non]
- #print(corrected_pvals)
- print(max(corrected_pvals.items(), key=lambda tup: min(tup[1])))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement