From 0c322054698d1fee650e0c1e2ac6e9892202737b Mon Sep 17 00:00:00 2001 From: Iulia Dumitru Date: Tue, 6 Dec 2022 11:06:30 +0200 Subject: [PATCH] Remove old design --- src/Survey.jl | 2 -- src/design.jl | 79 --------------------------------------------------- 2 files changed, 81 deletions(-) delete mode 100644 src/design.jl diff --git a/src/Survey.jl b/src/Survey.jl index 5150ca45..331eaa31 100644 --- a/src/Survey.jl +++ b/src/Survey.jl @@ -11,7 +11,6 @@ using AlgebraOfGraphics using CategoricalArrays include("SurveyDesign.jl") -include("design.jl") include("mean.jl") include("quantile.jl") include("total.jl") @@ -25,7 +24,6 @@ include("show.jl") export load_data export AbstractSurveyDesign, SimpleRandomSample, StratifiedSample export SurveyDesign -export design export by export ht_calc export dim, colnames, dimnames diff --git a/src/design.jl b/src/design.jl deleted file mode 100644 index 6a50e913..00000000 --- a/src/design.jl +++ /dev/null @@ -1,79 +0,0 @@ -""" - design - -Type incorporating all necessary information to describe a survey design. -``` -""" -struct design - id - variables::DataFrame - nest::Bool - check_strat::Bool -end - -function get_weights(data, wt::Vector) - if nrow(data) == length(wt) - return wt - else - @error "length of the weights vector is not equal to the number of rows in the dataset" - end -end - -function get_weights(data, wt::Nothing) - return ones(nrow(data)) -end - -function get_weights(data, wt::Symbol) - wt = data[!, String(wt)] -end - -function get_probs(data, wt, probs::Symbol) - return data[!, String(probs)] -end - -function get_probs(data, wt, probs::Nothing) - return 1 ./ wt -end - -function get_fpc(data, fpc::Symbol) - return data[!, String(fpc)] -end - -function get_fpc(data, fpc::Nothing) - return repeat([nothing], nrow(data)) -end - -function get_fpc(data, fpc::Vector) - return fpc -end - -function get_fpc(data, fpc::Real) - return repeat([fpc], nrow(data)) -end - -function get_strata(data, strata::Symbol) - return data[!, String(strata)] -end - -function get_strata(data, strata::Vector) - return strata -end - -function get_strata(data, strata::Nothing) - return repeat([1], nrow(data)) -end - -function design(; data = DataFrame(), id = Symbol(), probs = nothing, strata = nothing, fpc = nothing, nest = false, check_strat = !nest, weights = nothing) - wt = get_weights(data, weights) - if isnothing(probs) & isnothing(weights) - # THIS WARNING IS NOT NECESSARY - @warn "No weights or probabilities supplied, assuming equal probability" - end - df = data - df.probs = ProbabilityWeights(get_probs(data, wt, probs)) - df.weights = FrequencyWeights(get_weights(data, weights)) - df.popsize = get_fpc(data, fpc) - df.sampsize = repeat([nrow(data)], nrow(data)) - df.strata = get_strata(data, strata) - return design(id, df, nest, check_strat) -end