Advertisement
Guest User

Untitled

a guest
Apr 6th, 2021
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. import numpy as np
  2. import scipy.stats
  3. import itertools
  4. from pprint import pprint
  5.  
  6. n_treat_hyper, n_treat_non = 11, 39
  7. n_control_hyper, n_control_non = 15, 11
  8.  
  9.  
  10. icu_treat_total = 1
  11. icu_control_total = 13
  12.  
  13.  
  14. corrected_pvals = {}
  15. for icu_treat_hyper, icu_control_hyper in\
  16.         itertools.product(range(1+icu_treat_total), range(1+icu_control_total)):
  17.     icu_treat_non = icu_treat_total - icu_treat_hyper
  18.     icu_control_non = icu_control_total - icu_control_hyper
  19.  
  20.     if n_control_hyper - icu_control_hyper < 0 or n_control_non - icu_control_non < 0:
  21.         continue
  22.  
  23.     pval_hyper = scipy.stats.fisher_exact(
  24.             [[icu_treat_hyper, n_treat_hyper - icu_treat_hyper],
  25.              [icu_control_hyper, n_control_hyper - icu_control_hyper]])[1]
  26.     pval_non = scipy.stats.fisher_exact(
  27.             [[icu_treat_non, n_treat_non - icu_treat_non],
  28.              [icu_control_non, n_control_non - icu_control_non]])[1]
  29.  
  30.     corrected_pvals[icu_treat_hyper, icu_control_hyper] = [2*pval_hyper, 2*pval_non]
  31.  
  32. #print(corrected_pvals)
  33. print(max(corrected_pvals.items(), key=lambda tup: min(tup[1])))
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement