spotify_metal_deephouse |>
specify(formula = popular_or_not ~ track_genre, success = "popular")the same infer verbs, with one more step
the null distribution p-value
specify()hypothesize()generate()calculate()get_p_value()Are metal tracks more often popular than deep house tracks?
Assume nothing is going on, then ask how surprising your data would be.
Assume Nothing, Then Check
The one verb hypothesis testing adds. null = “independence” says the two variables are unrelated; null = “point” tests a single value.
Assume No Difference
Like specify(), it changes no data. It only records the assumption.
For a two-variable test, give a formula and say which outcome counts as a success.
Example
the data frame
the verb (function) response ~ explanatory which level counts as a success
type = “permute” shuffles the explanatory variable, breaking any link between the two. That is what the null hypothesis claims is true.
Example
the verb (function) how many shuffles shuffle, do not resample
assume no relationship
Reduce each shuffle to one number. For two groups, order says which one is subtracted from which.
One Number Per Shuffle
Get the order backwards and the sign of every difference flips.
the null distribution, saved for later
the verb (function) which statistic metal minus deep house
The same pipeline without hypothesize() and generate() gives the difference actually seen in the data.
Example
no shuffling: this is your data
The fraction of the null distribution at least as extreme as what you observed.
Example
# A tibble: 1 × 1
p_value
<dbl>
1 0.065
the verb (function) what you actually saw which tail to count
Show the same number as an area under the null distribution.
Example
plot the null distribution
shade everything at least this extreme
And the four things it is not.
Reading The p-value