Skip to content

Commit 75ac45f

Browse files
Jingjing TangJingjing Tang
Jingjing Tang
authored and
Jingjing Tang
committed
add jeffreys correction
1 parent 071db0f commit 75ac45f

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

quidel_covidtest/delphi_quidel_covidtest/data_tools.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ def raw_positive_prop(positives, tests, min_obs):
166166
# nan out any days where there are insufficient observations
167167
# this also elegantly sidesteps 0/0 division.
168168
tests[tests < min_obs] = np.nan
169-
positive_prop = positives / tests
169+
# Jeffreys Correction for estimates
170+
positive_prop = (positives+0.5) / (tests+1)
170171
se = np.sqrt(_prop_var(positive_prop, tests))
171172
sample_size = tests
172173
return positive_prop, se, sample_size

quidel_covidtest/tests/test_data_tools.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ def test__geographical_pooling(self, min_obs, expected):
9191

9292
@pytest.mark.parametrize("min_obs, expected_pos_prop, expected_se, expected_sample_sz", [
9393
(3, # one case of tests < min_obs
94-
np.array([np.nan, 1/2, 1/2, 4/10]),
95-
np.array([np.nan, np.sqrt(0.25/4), np.sqrt(0.25/6), np.sqrt(0.24/10)]),
94+
np.array([np.nan, 2.5/5, 3.5/7, 4.5/11]),
95+
np.array([np.nan, np.sqrt(2.5**2/5**2/4), np.sqrt(3.5**2/7**2/6), np.sqrt(4.5*6.5/11**2/10)]),
9696
np.array([np.nan, 4, 6, 10])),
9797
(1, # no cases of tests < min_obs
98-
np.array([1/2, 2/4, 3/6, 4/10]),
99-
np.array([np.sqrt(0.25/2), np.sqrt(0.25/4), np.sqrt(0.25/6), np.sqrt(0.24/10)]),
98+
np.array([1.5/3, 2.5/5, 3.5/7, 4.5/11]),
99+
np.array([np.sqrt(1.5**2/3**2/2), np.sqrt(2.5**2/5**2/4), np.sqrt(3.5**2/7**2/6), np.sqrt(4.5*6.5/11**2/10)]),
100100
np.array([2, 4, 6, 10])),
101101
])
102102
def test_raw_positive_prop(self, min_obs, expected_pos_prop, expected_se, expected_sample_sz):
@@ -123,16 +123,16 @@ def test_raw_positive_prop(self, min_obs, expected_pos_prop, expected_se, expect
123123
2,
124124
None,
125125
None,
126-
np.array([np.nan, 1/2, 1/2, 7/16]),
127-
np.array([np.nan, np.sqrt(0.25/6), np.sqrt(0.25/10), np.sqrt(63/256/16)]),
126+
np.array([np.nan, 3.5/7, 5.5/11, 7.5/17]),
127+
np.array([np.nan, np.sqrt(3.5**2/7**2/6), np.sqrt(5.5**2/11**2/10), np.sqrt(7.5*9.5/17**2/16)]),
128128
np.array([np.nan, 6, 10, 16]),
129129
),
130130
(3, # parents case
131131
2,
132132
np.array([3, 7, 9, 11]),
133133
np.array([5, 10, 15, 20]),
134-
np.array([1.6/3, 1/2, 1/2, 7/16]),
135-
np.array([np.sqrt(56/225/3), np.sqrt(0.25/6), np.sqrt(0.25/10), np.sqrt(63/256/16)]),
134+
np.array([(1 + 0.6 + 0.5)/(2 + 1 + 1), 3.5/7, 5.5/11, 7.5/17]),
135+
np.array([np.sqrt(2.1 * 1.9/4**2/3), np.sqrt(3.5**2/7**2/6), np.sqrt(5.5**2/11**2/10), np.sqrt(7.5*9.5/17**2/16)]),
136136
np.array([3, 6, 10, 16]),
137137
),
138138
])

0 commit comments

Comments
 (0)