Skip to content

Commit 13bcd7f

Browse files
committed
large-scale test added and one typo fixed.
1 parent 8c1a5ee commit 13bcd7f

File tree

4 files changed

+26
-10
lines changed

4 files changed

+26
-10
lines changed

Manifest.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
# This file is machine-generated - editing it directly is not advised
22

3+
[[DelimitedFiles]]
4+
deps = ["Mmap"]
5+
uuid = "8bb1440f-4735-579b-a4ab-409b98df4dab"
6+
7+
[[Mmap]]
8+
uuid = "a63ad114-7e13-5084-954f-fe012c677804"

Project.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
name = "SurveyDataWeighting"
22
uuid = "0d23d9a6-c44e-4ca5-9c36-ffcb6594a9c5"
33
authors = ["Graham Stark"]
4-
version = "1.0.1"
4+
version = "1.0.2"
5+
6+
[deps]
7+
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
58

69
[compat]
710
julia = "1.0"

test/large_scale_test.jl

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,35 @@ TARGETS = [
6565
#
6666
# subsample of scottish FRS 2018
6767
#
68-
data = readdlm( "data/scotmat.csv")
68+
data = readdlm( "../data/scotmat.csv")
6969

7070
@testset "Weighting Tests using 2018 Scottish FRS Subset" begin
7171

7272
nr,nc = size(data)
7373

74-
@test nr == size(TARGETS)[1]
74+
@test nc == size(TARGETS)[1]
7575

7676
hhlds_in_popn = sum( TARGETS[42:48]) # total num hhlds
7777

7878
initial_weights = ones(nr)*hhlds_in_popn/nr
7979
@test sum(initial_weights) hhlds_in_popn
80+
initial_weighted_popn = (initial_weights' * data)'
81+
println( "initial-weighted_popn vs targets" )
82+
for c in 1:nc
83+
diffpc = 100*(initial_weighted_popn[c]-TARGETS[c])/TARGETS[c]
84+
println( "$c $(TARGETS[c]) $(initial_weighted_popn[c]) $diffpc%")
85+
end
8086

8187
wchi = do_chi_square_reweighting( data, initial_weights, TARGETS )
88+
println( "direct chi-square results $(wchi)")
8289

83-
println( "direct chi-square results $wchi")
8490
weighted_popn_chi = (wchi' * data)'
85-
println( "wchisq; got $weighted_popn_chi")
91+
# println( "wchisq; got $weighted_popn_chi")
8692
@test weighted_popn_chi TARGETS
8793

88-
lower_multiple = 0.20 # any smaller min and d_and_s_constrained fails on this dataset
89-
upper_multiple = 2.19
90-
for m in instances( DistanceFunctionType )
94+
lower_multiple = 0.25 # any smaller min and d_and_s_constrained fails on this dataset
95+
upper_multiple = 4.8
96+
for m in [constrained_chi_square] #instances( DistanceFunctionType ) all other methods fail!
9197
println( "on method $m")
9298
rw = do_reweighting(
9399
data = data,
@@ -98,7 +104,7 @@ data = readdlm( "data/scotmat.csv")
98104
upper_multiple = upper_multiple,
99105
tolx = 0.000001,
100106
tolf = 0.000001 )
101-
println( "results for method $m = $rw" )
107+
println( "results for method $m = $(rw.rc)" )
102108
weights = rw.weights
103109
weighted_popn = (weights' * data)'
104110
println( "weighted_popn = $weighted_popn" )
@@ -119,5 +125,4 @@ data = readdlm( "data/scotmat.csv")
119125
end
120126
end # meth loop
121127

122-
123128
end # testset

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ sp = size( target_populations, 1 )
102102
end
103103
end # meth loop
104104
end # tests
105+
106+
include( "large_scale_test.jl")

0 commit comments

Comments
 (0)