-
Notifications
You must be signed in to change notification settings - Fork 19
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
New data structures to support multiple replicate methods. #297
Conversation
adding a new abstract type `InferenceMethod`.
The main crux of the code has been added; now I'll work on the documentation and modifying the tests. |
inference method `JackknifeReplicates` in `jackknife_variance`.
Codecov Report
@@ Coverage Diff @@
## main #297 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 13 13
Lines 242 245 +3
=========================================
+ Hits 242 245 +3
|
src/jackknife.jl
Outdated
@@ -127,7 +127,7 @@ julia> jackknife_variance(:api00, weightedmean, rstrat) | |||
# Reference | |||
pg 380-382, Section 9.3.2 Jackknife - Sharon Lohr, Sampling Design and Analysis (2010) | |||
""" | |||
function jackknife_variance(x::Symbol, func::Function, design::ReplicateDesign) | |||
function jackknife_variance(x::Symbol, func::Function, design::ReplicateDesign{JackknifeReplicates}) |
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.
It should just be called variance. There should be 2 dispatches.
variance(x::Symbol, func::Function, design::ReplicateDesign{JackknifeReplicates})
variance(x::Symbol, func::Function, design::ReplicateDesign{BootstrapReplicates})
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.
Okay, but we don't have a variance
method for BootstrapReplicates
method yet, do we?
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.
Also, should I rewrite the mean function using multiple dispatch now, or should that be done as a separate 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.
We should rewrite the functions now.
And we need a variance function for BootstrapReplicates
. It's pretty simple, it's just the simple variable of the estimates.
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.
We should rewrite the functions now. And we need a variance function for
BootstrapReplicates
. It's pretty simple, it's just the simple variable of the estimates.
Okay. Also, just to confirm: haven't we already implemented the variance function for BootstrapReplicates
in the mean
function in line 48 of this file?: https://github.com/xKDR/Survey.jl/blob/main/src/mean.jl
So we should probably get rid of this mean
function right?
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.
Yes, we should get rid of it, and
function variance(x::Symbol, func::Function, design::ReplicateDesign{BootstrapReplicates})
...
variance = sum((θ̂t .- θ̂) .^ 2) / design.replicates
end
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
`variance` functions of `bootstrap.jl` and `jackknife.jl`.
`variance` function for bootstrap replicate.
This PR introduces a "replicate type" for every
ReplicateDesign
object. The purpose is mainly to help with multiple dispatch on difference replicate methods.We have introduced a new abstract type called
InferenceMethod
, which will be a supertype for all inference types. For now, the package only supports two inference methods, which we've encoded by theBootstrapReplicates
andJackknifeReplicates
structs.Relevant changes have been made to the
ReplicateDesign
struct to incorporate the new structure.Also, the
mean
,total
andquantile
functions have now been written using the genericvariance
function. Sinceratio
takes two columns as it's arguments, it can't be implemented usingvariance
as of now (see #295 ).Closes #261