@@ -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-
123128end # testset
0 commit comments