Compute z-statistic for z-test on proportions as the categorical variable (ZScoreForProportionZTest)

class cerebunit.statistics.stat_scores.zPropScore.ZScoreForProportionZTest(*args, **kwargs)

Compute z-statistic for z-Test of proportions.

For single population.

Definitions Interpretation
\(n\) sample size
\(p_0\) some specified value
\(\hat{p}\) sample proportion (with characteristic of interest), i.e, sample statistic
\(se_{H_0}\) standard error of \(\hat{p}\) if \(p_0\) is the true value of p \(se_{H_0} = \sqrt{\frac{p_0(1-p_0)}{n}}\)
z-statistic, z z = \(\frac{ \hat{p} - p_0 }{ \sqrt{\frac{p_0(1-p_0)}{n}} }\)

For two populations.

Definitions Interpretation
\(n_1\) sample size for first population (experimental data)
\(n_2\) sample size for second population (prediction data)
\(x_1\) numbers in first population’s sample having the trait in question
\(x_2\) numbers in second population’s sample having the trait in question
\(p_0\) 0
\(\hat{p_1}\) sample 1 proportion:math:hat{p_1} = frac{x_1}{n}
\(\hat{p_2}\) sample 2 proportion:math:hat{p_2} = frac{x_2}{n}
\(\hat{p_1}-\hat{p_2}\) sample statistic (with characterisic of interest)
\(\hat{p}\)
estimate of common population proportion; if \(H_0\) is true
\(p_1 = p_2 = p\) and estimate \(\hat{p}\) is \(\hat{p} = \frac{n_1\hat{p_1} + n_2\hat{p_2}}{n_1 + n_2}\) \(\hat{p} = \frac{x_1 + x_2}{n_1 + n_2}\)
\(se_{H_0}\) standard error of \(\hat{p_1}-\hat{p_2}\) if \(H_0\) is true \(se_{H_0} = \sqrt{\frac{\hat{p}(1-\hat{p})}{n_1} + \frac{\hat{p}(1-\hat{p})}{n_2}}\)
z-statistic, z z = \(\frac{ \hat{p_1} - \hat{p_2} - p_0 }{ se_{H_0} }\)

Use Case:

x = ZScoreForProportionZTest.compute( observation, prediction )
score = ZScoreForProportionZTest(x)

Note: As part of the SciUnit framework this custom TScore should have the following methods,

  • compute() (class method)
  • sort_key() (property)
  • __str__()
classmethod compute(observation, prediction)
Argument Value type
first argument dictionary; observation/experimental data must have keys “sample_size” and “phat”
second argument floating number or array

Note:

  • observation must have the key “raw_data” whose value is the list of numbers