MIMIC-IV

Testing MIMIC-IV

F-Test

The one-way ANOVA tests the null hypothesis that two or more groups have the same population mean. The test is applied to samples from two or more groups, possibly with differing sizes

The ANOVA test has important assumptions that must be satisfied in order for the associated p-value to be valid.

from scipy.stats import f_oneway
tillamook = [0.0571, 0.0813, 0.0831, 0.0976, 0.0817, 0.0859, 0.0735, 0.0659, 0.0923, 0.0836]
newport = [0.0873, 0.0662, 0.0672, 0.0819, 0.0749, 0.0649, 0.0835, 0.0725]
petersburg = [0.0974, 0.1352, 0.0817, 0.1016, 0.0968, 0.1064, 0.105]
magadan = [0.1033, 0.0915, 0.0781, 0.0685, 0.0677, 0.0697, 0.0764, 0.0689]
tvarminne = [0.0703, 0.1026, 0.0956, 0.0973, 0.1039, 0.1045]
statistic, pvalue = f_oneway(tillamook, newport, petersburg, magadan, tvarminne)

Link reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.f_oneway.html

Kruskal-Test

The Kruskal-Wallis H-test tests the null hypothesis that the population median of all of the groups are equal. It is a non-parametric version of ANOVA. The test works on 2 or more independent samples, which may have different sizes. Note that rejecting the null hypothesis does not indicate which of the groups differs. Post hoc comparisons between groups are required to determine which groups are different.

rom scipy.stats import kruskal
x = [1, 3, 5, 7, 9]
y = [2, 4, 6, 8, 10]
statistic, pvalue = kruskal(x, y)

Reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.kruskal.html#scipy.stats.kruskal

Chi-square test

Chi-square test of independence of variables in a contingency table.

This function computes the chi-square statistic and p-value for the hypothesis test of independence of the observed frequencies in the contingency table [1] observed. The expected frequencies are computed based on the marginal sums under the assumption of independence;

from scipy.stats import chi2_contingency
obs = np.array([[10, 10, 20], [20, 20, 20]])
statistic, pvalue, dof, expected_freq = chi2_contingency(obs)

Reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chi2_contingency.html

Kolmogorov-Smirnov test

Performs the two-sample Kolmogorov-Smirnov test for goodness of fit.

This test compares the underlying continuous distributions F(x) and G(x) of two independent samples. See Notes for a description of the available null and alternative hypotheses.

from scipy.stats import ks_2samp
simulated_normal = np.random.normal(df[var].mean(), df[var].std(), size=len(df))
stat, p_value = ks_2samp(df[var], simulated_normal)

Reference: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.ks_2samp.html

Quantile

df['NPAR_group'] = qcut(df['NPAR'], q = 4, labels=['Q1', 'Q2', 'Q3', 'Q4'])