Hypothesis testing about means (HtestAboutMeans
)¶
- class cerebstats.hypothesis_testings.aboutmeans.HtestAboutMeans(observation, prediction, test_statistic, side='not_equal')¶
Hypothesis Testing (significance testing) about means.
1. Verify necessary data conditions.
Statistic
Interpretation
sample size, n
experiment/observed n
optionally: raw data
experiment/observed data array
Is \(n \geq 30\)?
If not, check if data is from normal distribution.
If both returns NO, you can’t perform hypothesis testing about means. Instead use sign test.
If either of the above two question returns YES continue below.
2. Defining null and alternate hypotheses.
Statistic
Interpretation
sample statistic, \(\mu\)
experiment/observed mean
null value/population parameter, \(\mu_0\)
model prediction
null hypothesis, \(H_0\)
\(\mu = \mu_0\)
alternate hypothesis, \(H_a\)
\(\mu \neq or < or > \mu_0\)
- Two-sided hypothesis (default)
\(H_0\): \(\mu = \mu_0\) and \(H_a\): \(\mu \neq \mu_0\)
- One-side hypothesis (left-sided)
\(H_0\): \(\mu = \mu_0\) and \(H_a\): \(\mu < \mu_0\)
- One-side hypothesis (right-sided)
\(H_0\): \(\mu = \mu_0\) and \(H_a\): \(\mu > \mu_0\)
3. Assuming H0 is true, find p-value.
Statistic
Interpretation
sample size, n
experiment/observed n
standard error, SE
experiment/observed SE = \(\frac{SD}{\sqrt{n}}\)
or
or
standard deviation, SD
experiment/observed SD
t-statistic, t
test score, \(t = \frac{\mu - \mu_0}{SE}\)
degree of freedom, df
\(df = n - 1\)
z-statistic, z (standard)
test score, \(z = \frac{\mu - \mu_0}{SD}\)
Using t and df look up table for t-distrubution which will return its corresponding p. If the denominator is
SD
then value of z is seen in a normal distribution to return its corresponding p.4. Report and Answer the question, based on the p-value is the result (true H0) statistically significant?
Answer is not provided by the class but its is up to the person viewing the reported result. The results are obtained calling the attributed
.statistics
and.description
. This is illustrated below.ht = HtestAboutMeans( observation, prediction, score, side="less_than" ) # side is optional score.description = ht.outcome score.statistics = ht.statistics
Arguments
Argument
Representation
Value type
first
experiment/observation
dictionary that must have keys; “mean” and “sample_size”
second
model prediction
float
third
test score/z or t-statistic
dictionary with key; “z” or “t”
fourth
sidedness of test
string; “not_equal” (default) or “less_than”, “greater_than”
The constructor method generates
statistics
andoutcome
(which is then assigned todescription
within the validation test class where this hypothesis test class is implemented).- static alternate_hypothesis(side, symbol_null_value, symbol_sample_statistic)¶
Returns the statement for the alternate hypothesis, Ha.
- static null_hypothesis(symbol_null_value, symbol_sample_statistic)¶
Returns the statement for the null hypothesis, H0.
- test_outcome()¶
Puts together the returned values of
null_hypothesis()
,alternate_hypothesis()
, and_compute_pvalue()
. Then returns the string value for.outcome
.