xKDR / Survey.jl

Analysis of complex surveys
https://xkdr.github.io/Survey.jl/
GNU General Public License v3.0
50 stars 19 forks source link

WIP: Abstract type for summary statistics (Mean) #277

Closed nadiaenh closed 1 year ago

nadiaenh commented 1 year ago

Resolves #275, #184, #274 Partial implementation of @smishr's confidence interval function Implemented Mean structure as an abstract SummaryStat

Remaining to do on this PR :

Can implement Total, Quantile, and Ratio later

ayushpatnaikgit commented 1 year ago

Have you considered how this would work with domain estimation? Where we have mean(:variable, :domain, design)?

ayushpatnaikgit commented 1 year ago

Overall, I think it's a good idea to be able to do ans.estimate, ans.CI and ans.SE. Need to think through the implementation.

It will need a few show methods to make it beautiful.

ayushpatnaikgit commented 1 year ago

I suggest having

struct Estimate
   value::Number
   SE::Number
end

Instead of SummaryStat and Mean

mean, quantile and total can be factory functions for the structure.

For domain estimation, we'll need a separate struct perhaps

struct DomainEstimates
   values::Vector{Number}
   SE::Vector{Number}
end

After this, we can have a function confint(x::Estimate).

smishr commented 1 year ago
struct Estimate
    value::Number
    SE::Number
end

How does this broadcast to estimates which are vectors?

asinghvi17 commented 1 year ago

Any reason not to use https://github.com/JuliaPhysics/Measurements.jl here? It's fundamentally the same data structure but probably supported more widely across the ecosystem. In this case a vector estimate would be a vector of Measurements.

codecov-commenter commented 1 year ago

Codecov Report

Merging #277 (bc220b2) into next_release (e9362f9) will decrease coverage by 4.48%. The diff coverage is 0.00%.

@@               Coverage Diff                @@
##           next_release     #277      +/-   ##
================================================
- Coverage        100.00%   95.52%   -4.48%     
================================================
  Files                12       14       +2     
  Lines               200      268      +68     
================================================
+ Hits                200      256      +56     
- Misses                0       12      +12     
Impacted Files Coverage Δ
src/SummaryStats.jl 0.00% <0.00%> (ø)

... and 3 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

smishr commented 1 year ago

Any reason not to use https://github.com/JuliaPhysics/Measurements.jl here? It's fundamentally the same data structure but probably supported more widely across the ecosystem. In this case a vector estimate would be a vector of Measurements.

Ayush and I looked at the Measurements.jl package, we see where you are coming from. Except for the pretty printing of uncertainty, their class would not be useful for other aspects of Survey.jl. But some ideas can be adapted from them