Skip to content

Commit

Permalink
Merge pull request #47 from mdpradeep/master
Browse files Browse the repository at this point in the history
Added inline documentation for exported methods
  • Loading branch information
andreasnoack committed Feb 19, 2016
2 parents 1fa7961 + 343ff00 commit af89ba7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/b.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ function show_params(io::IO, x::BTest, ident)
end

pvalue(x::BTest) = pvalue(Normal(0, x.stderr), x.MMD; tail=:right) # check only if distance is larger than 0

"""
ci(x::BTest, alpha::Float64=0.05)
Compute a confidence interval C with coverage 1-alpha.
"""
ci(x::BTest, alpha::Float64=0.05) = (quantile(Normal(x.MMD, x.stderr), alpha/2), quantile(Normal(x.MMD, x.stderr), 1-alpha/2))

## helper
Expand Down
37 changes: 36 additions & 1 deletion src/binomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ end
BinomialTest(x::AbstractVector{Bool}, p=0.5) =
BinomialTest(sum(x), length(x), p)

"""
```julia
testname(::HypothesisTest)
```
Returns the string value. E.g. "Binomial test", "Sign Test"
"""
testname(::BinomialTest) = "Binomial test"
population_param_of_interest(x::BinomialTest) = ("Probability of success", x.p, x.x/x.n) # parameter of interest: name, value under h0, point estimate

Expand All @@ -49,6 +56,17 @@ pvalue(x::BinomialTest; tail=:both) = pvalue(Binomial(x.n, x.p), x.x; tail=tail)

# Confidence interval

"""
```julia
function ci(x::HypothesisTest, alpha::Float64=0.05; tail=:both, method=:clopper_pearson)
```
Compute a confidence interval with coverage 1-alpha for multinomial proportions using one of the following methods. Possible values for method are:
Sison, Glaz intervals :sison_glaz (default):
Bootstrap intervals :bootstrap :
Quesenberry, Hurst intervals :quesenberry_hurst :
Gold intervals :gold (Asymptotic simultaneous intervals):
"""
function ci(x::BinomialTest, alpha::Float64=0.05; tail=:both, method=:clopper_pearson)
check_alpha(alpha)

Expand Down Expand Up @@ -139,9 +157,26 @@ function show_params(io::IO, x::SignTest, ident="")
println(io, ident, text2, x.x)
end

"""
```julia
pvalue(x::HypothesisTest; tail=:both)
```
Compute the p-value for a given significance test.
If tail is :both (default), then the p-value for the two-sided test is returned. If tail is :left or :right, then a one-sided test is performed.
"""
pvalue(x::SignTest; tail=:both) = pvalue(Binomial(x.n, 0.5), x.x; tail=tail)

# confidence interval by inversion
"""
```julia
function ci(x::HypothesisTest, alpha::Float64=0.05; tail=:both)
```
Compute a confidence interval C with coverage 1-alpha.
If tail is :both (default), then a two-sided confidence interval is returned. If tail is :left or :right, then a one-sided confidence interval is returned
"""
@compat function ci(x::SignTest, alpha::Float64=0.05; tail=:both)
check_alpha(alpha)

Expand Down

0 comments on commit af89ba7

Please sign in to comment.