Skip to content
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

Updated variance( ) function #308

Closed
wants to merge 32 commits into from
Closed

Conversation

nadiaenh
Copy link
Collaborator

@nadiaenh nadiaenh commented Jul 14, 2023

  • Add documentation for Jackknife survey design
  • Add support for design-based variance for bootstrap and jackknife replicate designs
  • Update bydomain to use with statistical summary functions
  • Update mean, quantile, total, and ratio to use with bydomain
  • Renamed variance to stderr

Closes #295 and #301

@ayushpatnaikgit ayushpatnaikgit marked this pull request as draft July 17, 2023 18:15
@nadiaenh
Copy link
Collaborator Author

nadiaenh commented Jul 19, 2023

@ayushpatnaikgit My doctests are failing most of the time but I can't figure out why, here is one of the error messages :

┌ Error: doctest failure in ~/Survey.jl/src/mean.jl:47-55
│
│ ```jldoctest; setup = :(using Survey, StatsBase; apiclus1 = load_data("apiclus1"); dclus1 = SurveyDesign(apiclus1; clusters = :dnum, weights = :pw); bclus1 = dclus1 |> bootweights;)

│ julia> mean(:api00, bclus1)
│ 1×2 DataFrame
│  Row │ mean     SE
│      │ Float64  Float64
│ ─────┼──────────────────
│    1 │ 644.169  23.4107
```
│
│ Subexpression:
│
│ mean(:api00, bclus1)
│
│ Evaluated output:
│
│ 1×2 DataFrame
│  Row │ mean     SE
│      │ Float64  Float64
│ ─────┼──────────────────
│    1644.169  23.4107
│
│ Expected output:
│
│
│
│   diff =1×2 DataFrame
│     Row │ mean     SE
│         │ Float64  Float64
│    ─────┼──────────────────
│       1644.169  23.4107
└ @ Documenter.DocTests ~/Survey.jl/src/mean.jl:47

and here is that doctest:

jldoctest; setup = :(using Survey, StatsBase; apiclus1 = load_data("apiclus1"); dclus1 = SurveyDesign(apiclus1; clusters = :dnum, weights = :pw); bclus1 = dclus1 |> bootweights;)

julia> mean(:api00, bclus1)
1×2 DataFrame
 Row │ mean     SE
     │ Float64  Float64
─────┼──────────────────
   1 │ 644.169  23.4107

They are failing for all the updated files with the same kind of error message (expected X, evaluated X).
Running the doctest manually in Julia (after dev .) works, and running julia make.jl sometimes doesn't give error message but most of the times does.

@codecov-commenter
Copy link

codecov-commenter commented Jul 19, 2023

Codecov Report

Merging #308 (ae2daa1) into main (735613e) will decrease coverage by 2.34%.
The diff coverage is 91.54%.

@@             Coverage Diff             @@
##              main     #308      +/-   ##
===========================================
- Coverage   100.00%   97.66%   -2.34%     
===========================================
  Files           14       14              
  Lines          242      257      +15     
===========================================
+ Hits           242      251       +9     
- Misses           0        6       +6     
Files Changed Coverage Δ
src/quantile.jl 87.50% <57.14%> (-12.50%) ⬇️
src/ratio.jl 76.92% <72.72%> (-23.08%) ⬇️
src/SurveyDesign.jl 100.00% <100.00%> (ø)
src/bootstrap.jl 100.00% <100.00%> (ø)
src/by.jl 100.00% <100.00%> (ø)
src/jackknife.jl 100.00% <100.00%> (ø)
src/mean.jl 100.00% <100.00%> (ø)
src/total.jl 100.00% <100.00%> (ø)

README.md Outdated
@@ -92,7 +92,7 @@ to compute the standard errors.

```julia
julia> bootsrs = bootweights(srs; replicates=1000)
ReplicateDesign:
ReplicateDesign{BoootstrapReplicates}:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a triple “o” in BoootstrapReplicates?

src/jackknife.jl Outdated Show resolved Hide resolved
src/mean.jl Outdated Show resolved Hide resolved
@ayushpatnaikgit
Copy link
Member

@ayushpatnaikgit My doctests are failing most of the time but I can't figure out why, here is one of the error messages :

┌ Error: doctest failure in ~/Survey.jl/src/mean.jl:47-55
│
│ ```jldoctest; setup = :(using Survey, StatsBase; apiclus1 = load_data("apiclus1"); dclus1 = SurveyDesign(apiclus1; clusters = :dnum, weights = :pw); bclus1 = dclus1 |> bootweights;)

│ julia> mean(:api00, bclus1)
│ 1×2 DataFrame
│  Row │ mean     SE
│      │ Float64  Float64
│ ─────┼──────────────────
│    1 │ 644.169  23.4107
```
│
│ Subexpression:
│
│ mean(:api00, bclus1)
│
│ Evaluated output:
│
│ 1×2 DataFrame
│  Row │ mean     SE
│      │ Float64  Float64
│ ─────┼──────────────────
│    1644.169  23.4107
│
│ Expected output:
│
│
│
│   diff =1×2 DataFrame
│     Row │ mean     SE
│         │ Float64  Float64
│    ─────┼──────────────────
│       1644.169  23.4107
└ @ Documenter.DocTests ~/Survey.jl/src/mean.jl:47

and here is that doctest:

jldoctest; setup = :(using Survey, StatsBase; apiclus1 = load_data("apiclus1"); dclus1 = SurveyDesign(apiclus1; clusters = :dnum, weights = :pw); bclus1 = dclus1 |> bootweights;)

julia> mean(:api00, bclus1)
1×2 DataFrame
 Row │ mean     SE
     │ Float64  Float64
─────┼──────────────────
   1 │ 644.169  23.4107

They are failing for all the updated files with the same kind of error message (expected X, evaluated X). Running the doctest manually in Julia (after dev .) works, and running julia make.jl sometimes doesn't give error message but most of the times does.

“sometimes doesn't give error message but most of the times does”, is a little weird. It difficult for me to help you on this remotely. Generally speaking, doctests are a bit difficult to get around.

@nadiaenh nadiaenh marked this pull request as ready for review August 21, 2023 04:40
@ayushpatnaikgit
Copy link
Member

PR #304 addresses this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jackknife_variance hardcoded for binary func
3 participants