biostats.median_test#

biostats.median_test(data, variable, expect)[source]#

Test whether the mean value of a variable is different from the expected value with nonparametric methods.

Parameters:
datapandas.DataFrame

The input data. Must contain at least one numeric column.

variablestr

The numeric variable that we want to calculate the mean value of.

expectfloat or int

The expected value.

Returns:
summarypandas.DataFrame

The count, mean value, standard deviation, minimum, first quartile, median, third quartile, and maximum of the variable.

resultpandas.DataFrame

The rank sums, z statistic, and p-values of the normal and exact tests.

See also

wilcoxon_rank_sum_test

Compare the mean values between two groups with nonparametric methods.

wilcoxon_signed_rank_test

Compare the mean values between two paired groups with nonparametric methods.

one_sample_t_test

The parametric version of median test.

Examples

>>> import biostats as bs
>>> data = bs.dataset("median_test.csv")
>>> data
   Value
0      3
1      4
2      5
3      4
4      4
5      4
6      4
7      3
8      2
9      5

We want to test whether the mean value of Value is different from 3 with nonparametric methods.

>>> summary, result = bs.median_test(data=data, variable="Value", expect=3)
>>> summary
       Count  Mean  Std. Deviation  Minimum  1st Quartile  Median  3rd Quartile  Maximum
Value     10   3.8        0.918937        2          3.25       4             4        5

The mean value and some descriptive statistics are given.

>>> result
        Rank Sum  z Statistic   p-value   
Normal      32.5      2.05306  0.040067  *
Exact       32.5          NaN  0.039062  *

The p-value < 0.05, so the mean value of Value is significantly different from the expected value.