-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move method descriptions to docstrings #106
Conversation
da3b980
to
9e0e6af
Compare
9e0e6af
to
09aabcd
Compare
One idea for question (1) would be to put a "fake" general method in
And similarly for |
A way to generally attach docstrings to functions is to either forward-declare the function with no methods, e.g. """
confint(...)
...
"""
function confint end or attach it to the function after methods have been defined for it, e.g.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing this, that's very useful! I've taken this opportunity to review the docstrings, so I've noted many small issues which were already present in the docs. Feel free to fix only those which are introduced by your PR, but if you feel like it it would be great to fix the others too. At any rate it's good to have a commit just to copy the existing docstrings, and one or more commits improving them, so that we can easily track the changes.
src/anderson_darling.jl
Outdated
`xs` comes from the same distribution against the alternative hypothesis that the samples | ||
comes from different distributions. | ||
|
||
`modified` paramater enables a modified test calculation for samples whose observations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"parameter". Do you have more details about what's that modified calculation?
src/t.jl
Outdated
OneSampleTTest(xbar::Real, stdev::Real, n::Int, mu0::Real = 0) | ||
|
||
Perform a one sample t-test of the null hypothesis that `n` values with mean `xbar` and | ||
sample standard deviation `stdev` come from a distribution with `mu0` against the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"with mean mu0
". Also better use μ0
and stddev
as in the code.
src/anderson_darling.jl
Outdated
@@ -30,6 +30,15 @@ immutable OneSampleADTest <: ADTest | |||
A²::Float64 # Anderson-Darling test statistic | |||
end | |||
|
|||
""" | |||
OneSampleADTest{T<:Real}(x::AbstractVector{T}, d::UnivariateDistribution) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general better do ::AbstractVector{<:Real}
and remove T
. Same elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only in the docstrings or should I also go through the function definitions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could do both if T
isn't used in the body of functions, but to keep this PR focused better only touch docstrings.
src/anderson_darling.jl
Outdated
""" | ||
KSampleADTest{T<:Real}(xs::AbstractVector{T}...; modified=true) | ||
|
||
Perform a k-sample Anderson–Darling test of the null hypothesis that the data in vectors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"in the k vectors" would be clearer. You can use double backticks around k
for each of its uses.
src/anderson_darling.jl
Outdated
|
||
Perform a k-sample Anderson–Darling test of the null hypothesis that the data in vectors | ||
`xs` comes from the same distribution against the alternative hypothesis that the samples | ||
comes from different distributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"come". Same for previous occurrence (I guess).
src/t.jl
Outdated
Most of the implemented confidence intervals are *strongly consistent*, that is, the | ||
confidence interval with coverage 1-`alpha` does not contain the test statistic under | ||
``h_0`` if and only if the corresponding test rejects the null hypothesis | ||
``h_0: \\theta=\\theta_0``: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can write alpha and theta directly using greek letters.
src/t.jl
Outdated
EqualVarianceTTest(x::AbstractVector{T<:Real}, y::AbstractVector{T<:Real}) | ||
|
||
Perform a two-sample t-test of the null hypothesis that `x` and `y` come from a | ||
distributions with the same mean and equal variances against the alternative hypothesis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"a distributions with the same mean and equal variances" -> "distributions with equal means and variances". Same below.
src/wilcoxon.jl
Outdated
When there are no tied ranks and ≤50 samples, or tied ranks and ≤15 samples, | ||
`SignedRankTest` performs an exact signed rank test. In all other cases, `SignedRankTest` | ||
performs an approximate signed rank test. Behavior may be further controlled by using | ||
`ExactSignedRankTest` or `ApproximateSignedRankTest` directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use @ref
.
src/mann_whitney.jl
Outdated
|
||
The Mann-Whitney U test is sometimes known as the Wilcoxon rank sum test. | ||
|
||
When there are no tied ranks and ≤50 samples, or tied ranks and ≤10 samples, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use @ref
.
src/wilcoxon.jl
Outdated
""" | ||
ExactSignedRankTest(x::AbstractVector{T<:Real}[, y::AbstractVector{T<:Real}]) | ||
|
||
Perform an exact signed rank U test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeat the definition of the test. Same below.
The usual solution to that is to define
I'd say that's OK as long as the repeated content is not too long. If the REPL output isn't clear, it should be improved, rather than working around it in packages (the HTML manual looks better in general).
IIRC it depends on the order in which the methods are defined. Using the trick I gave above, you should be able to define it in the right place.
Agreed. Also check that it works in the HTML manual though.
Yes, the best way to give her credit is to merge here PR, which I just did. Thanks for pointing it out! |
Ok, I have (hopefully) addressed all points directly related to the PR. I have also updated the documentation more generally along the lines suggested by @nalimilan in a separate commit. However, I'm not able to answer the specific questions about the Power Divergence test so there, I only addressed the formatting issues. Could we deal with these specific questions in separate PR by someone more qualified? |
f8f6b1a
to
2caa23e
Compare
src/kruskal_wallis.jl
Outdated
The p-value is computed using a ``χ^2`` approximation to the distribution of the test | ||
statistic ``H_c=\\frac{H}{C}``: | ||
```math | ||
\\begin{align} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forget, does align
number the lines and align*
doesn't?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, align
numbers (although the Jupyter notebook doesn't print them). I'll change it to align*
in the next iteration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. We can always improve docstrings later; that doesn't have to all happen at once here.
Thanks for the hint about zero-method functions. One related question. In Documenter.jl, it's possible to include a certain method via ```@docs
length(::T)
``` So if I now define a general docstring for ```@docs
pvalue(::HypothesisTest)
``` but that didn't work. |
🙂 |
But that prints the docstrings for all defined methods of |
Ah, I see. I think you should be able to do this: """
pvalue(...)
Some general description
"""
pvalue(::HypothesisTest; kwargs...) after methods have been defined for |
Thanks, but even if I put the definition at the end of
when I add |
Hmmmmm, maybe
|
src/t.jl
Outdated
OneSampleTTest(xbar::Real, stddev::Real, n::Int, μ0::Real = 0) | ||
|
||
Perform a one sample t-test of the null hypothesis that `n` values with mean `xbar` and | ||
sample standard deviation `stddev` come from a distribution with `μ0` against the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to fix "with mean μ0
".
src/binomial.jl
Outdated
- Agresti Coull interval `:agresti_coull`: Simplified version of the Wilson interval; | ||
they are centered around the same value. The Agresti Coull interval has higher or | ||
equal coverage. | ||
- Arcsine transformation `:arcsine`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, let's leave this for somebody else then. ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Looks almost ready, I've just noted a few remaining details.
src/power_divergence.jl
Outdated
|
||
If `x` is a matrix with at least two rows and columns, it is taken as a two-dimensional | ||
contingency table. Otherwise, `x` and `y` must be vectors of the same length. The contingency | ||
table is calculated using `counts` from [`Statsbase`](@ref). Then the power divergence test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"StatsBase". Also, I meant writing[`StatsBase.counts`](@ref)
(I'm not sure a link to a module works).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Documenter.jl
documentation states
Note that depending on what the CurrentModule is set to, a docstring @ref may need to be prefixed by the module which defines it.
However, at least in my local build, links like [`StatsBase.counts`](@ref)
don't seem to work. But maybe we can figure this out in the next PR that will actually set up Documenter.jl
.
src/power_divergence.jl
Outdated
/\\hat{n}_{ij})^λ -1\\right] | ||
``` | ||
where ``n_{ij}`` is the cell count in the ``i`` th row and ``j`` th column and ``λ`` is a | ||
real number determing the nature of the test to be performed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"determining"
src/power_divergence.jl
Outdated
""" | ||
MultinomialLRT(x [,y] [,theta0]) | ||
|
||
Convenience function for power divergence test with ``λ=0``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please at least copy the relevant docs from PowerDivergenceTest
and fix the signature.
Thanks @ararslan and @nalimilan for the thorough review. I have hopefully addressed all points now. Once this PR is merged, I will open a new PR to build the docs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one more issue. Can you rebase and fix the conflicts so that I can merge?
src/fisher.jl
Outdated
@@ -71,7 +71,8 @@ immutable FisherExactTest <: HypothesisTest | |||
end | |||
|
|||
testname(::FisherExactTest) = "Fisher's exact test" | |||
population_param_of_interest(x::FisherExactTest) = ("Odds ratio", 1.0, x.ω) # parameter of interest: name, value under h0, point estimate | |||
population_param_of_interest(x::FisherExactTest) = ("Odds ratio", 1.0, x.ω) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better not change this since that's unrelated. Or at least put the comment before the function rather than after. Same below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I have reverted it.
565bc79
to
a02607a
Compare
Done. Let me know if I should do anything else. |
this is great! but... why is this package not being tested on julia 0.6? |
Will be. Once this is merged we should drop 0.5 support, test on 0.6, and have FemtoCleaner do a deprecation fixing pass. |
src/fisher.jl
Outdated
The one-sided p-values are based on Fisher's non-central hypergeometric distribution | ||
``f_ω(i)`` with odds ratio ``ω``: | ||
```math | ||
\\begin{align} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess if you're moving everything to align*
this should be as well? Aside from that, this all LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed.
a02607a
to
c452f6b
Compare
src/fisher.jl
Outdated
|*Y2*| c | d | | ||
|
||
!!! note | ||
The [`Base.show`](@ref) output contains the conditional maximum likelihood estimate of the odds ratio |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you build the docs, what does this end up linking to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted above
The Documenter.jl documentation states
"Note that depending on what the CurrentModule is set to, a docstring @ref may need to be prefixed by the module which defines it."
However, at least in my local build, links likeStatsBase.counts
don't seem to work. But maybe we can figure this out in the next PR that will actually set up Documenter.jl.
So, at least for now the links to outside modules don't work. Those are:
[`StatsBase.counts`](@ref)
and[`Base.show`](@ref)
for which the error is that!! No doc found for reference
[`Rmath.pwilcox`](@ref)
and[`Rmath.psignrank`](@ref)
for which it saysERROR: UndefVarError(:Rmath)
, so this is maybe not the correct module call.
The Documenter.jl documentation unfortunately doesn't give an example how to link to other modules and I also couldn't find an example in other packages.
Besides these dead links, the docs are still built correctly and everything looks ok. If you have an idea on how to fix it, I can push the fix here. If it takes us longer to figure it out, we might want to merge here and then fix the links in the follow-up PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just remove the dead ref links for now, e.g. in this case just say "The show
output contains..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. But you explain this to @nalimilan ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did Milan tell you to link to things that can't be properly linked...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No no, of course not. I was joking. He told me to include the links but wasn't sure whether it would work. Let's leave them out and we can figure the linking out later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately it seems it's not possible at the moment: JuliaDocs/Documenter.jl#425. Let's go without links for now.
c452f6b
to
84195ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good to go as far as I'm concerned. Thanks as always!
Thanks Alex. Sorry for the back and forth. |
No problem at all! That's just how PR reviews go. You've done awesome work here, as usual. |
@nalimilan Good to merge? Any further cleanup that's necessary can always happen later. |
Sorry for the delay. It's fine with me! Though conflicts have to be fixed first. |
Weird, I'm not seeing any merge conflicts? |
In this pull request, I have copied all available documentation on tests, pvalues, and confidence intervals to docstrings. Please note that I have only done some reformatting. I have not checked the documentation for correctness. This is the first step in the transition to Documenter.jl as discussed in #103.
When reviewing, please consider the following questions.
pvalue()
andconfint()
somewhat arbitrarily to two of the tests (Binomial.jl
andt.jl
). Is there a better place to put them?OneSampleTTest()
. If possible, I have combined them in one docstring, but sometimes, for clarity reasons, I have included different docstrings for the methods. Is that ok, or should we combine them somehow into one docstring? The disadvantage of having them in different docstrings is that the help output in the REPL can get convoluted, especially as there is not much spacing between the output for the different methods.pvalue
andconfint
also have different methods with a number of separate docstrings. Is there a way to ensure that the general method, e.g.pvalue(x::HypothesisTests)
, is the first shown when typing?pvalue
? As some of the more specialised methods have long docstrings, it could get lost otherwise.!!! note
doesn't work in the Jupyter notebook (at least not for me using Safari). It works in the REPL and Juno. Maybe someone can try it. If it's a general problem, we can file an issue with IJulia (or at the appropriate place).Thanks in advance for your input!