TuringLang / docs

Documentation and tutorials for the Turing language
https://turinglang.org/docs/
MIT License
229 stars 99 forks source link

[FR] Add hypothesis test tutorial #317

Open KronosTheLate opened 2 years ago

KronosTheLate commented 2 years ago

I would LOVE to see a baysean Turing.jl implementation of some standard frequentist hypothesis tests. E.g. if the mean of some dataset is above 0, or if the difference in mean between both paired and unpaired data are e.g. above 5. The paired case would be the same as the single dataset case, which could be mentioned in a single sentence, making "paired test" searchable.

yebai commented 2 years ago

Thanks, @KronosTheLate for the suggestions - would you like to make your suggestion a bit more concrete, e.g. by listing an existing method/implementation for such a test?

KronosTheLate commented 2 years ago

Something like the following, with the following being performed in a frequentist approach:

julia> using StableRNGs, Random

julia> rng = StableRNG(123);

julia> Random.seed!(rng, 123);

julia> xs = rand(Normal(0.5, 1), 50);

julia> using HypothesisTests

julia> OneSampleTTest(xs)
One sample t-test
-----------------
Population details:
    parameter of interest:   Mean
    value under h_0:         0
    point estimate:          0.559113
    95% confidence interval: (0.2593, 0.8589)

Test summary:
    outcome with 95% confidence: reject h_0
    two-sided p-value:           0.0005

Details:
    number of observations:   50
    t-statistic:              3.7479190960339515
    degrees of freedom:       49
    empirical standard error: 0.1491795406494802

I am looking for some way of comparing two hypotheses, e.g. mean=0 to mean=1, or mean > 0 vs mean < 0, in a bayesian framework.