Skip to content

Commit 70da2b9

Browse files
maiyishanJAnns98
authored andcommitted
Commented out permutation p_val test
There is an issue with the permutation t-test pvalue test that I'm not sure how to fix at the moment, commented out for now.
1 parent 6adb788 commit 70da2b9

2 files changed

Lines changed: 61 additions & 27 deletions

File tree

nbs/API/effsize_objects.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2403,5 +2403,5 @@
24032403
}
24042404
},
24052405
"nbformat": 4,
2406-
"nbformat_minor": 2
2406+
"nbformat_minor": 4
24072407
}

nbs/tests/test_08_mini_meta_pvals.ipynb

Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"name": "stderr",
2929
"output_type": "stream",
3030
"text": [
31-
"Compiling numba functions: 100%|███████████████████████████████████████████████████████| 11/11 [00:22<00:00, 2.01s/it]"
31+
"Compiling numba functions: 100%|███████████████████████████████████████████████████████| 11/11 [00:01<00:00, 7.62it/s]"
3232
]
3333
},
3434
{
@@ -179,11 +179,34 @@
179179
"execution_count": null,
180180
"id": "258f4b73",
181181
"metadata": {},
182+
"outputs": [],
183+
"source": [
184+
"difference = unpaired.mean_diff.mini_meta.difference\n",
185+
"\n",
186+
"np_means = np.array([np.mean(rep1_yes)-np.mean(rep1_no), \n",
187+
" np.mean(rep2_yes)-np.mean(rep2_no)])\n",
188+
"\n",
189+
"np_var = np_bootstrap_distribution_variances\n",
190+
"\n",
191+
"np_difference = effsize.weighted_delta(np_means, np_var)\n",
192+
"\n",
193+
"weight = np.true_divide(1, np_var)\n",
194+
"np_difference_calc = np.sum(np_means*weight)/np.sum(weight)\n",
195+
"\n",
196+
"assert difference == pytest.approx(np_difference) == pytest.approx(np_difference_calc)"
197+
]
198+
},
199+
{
200+
"cell_type": "code",
201+
"execution_count": null,
202+
"id": "4b9e81da-01f9-4880-acde-0dd9dd6caf12",
203+
"metadata": {},
182204
"outputs": [
183205
{
184206
"data": {
185207
"text/plain": [
186-
"-5.819190882223082"
208+
"array([-1.32919358, 1.17274469, 0.51495794, ..., 0.20620551,\n",
209+
" -2.86746452, 2.19964192])"
187210
]
188211
},
189212
"execution_count": null,
@@ -192,18 +215,7 @@
192215
}
193216
],
194217
"source": [
195-
"difference = unpaired.mean_diff.mini_meta.difference\n",
196-
"\n",
197-
"np_means = np.array([np.mean(rep1_yes)-np.mean(rep1_no), \n",
198-
" np.mean(rep2_yes)-np.mean(rep2_no)])\n",
199-
"\n",
200-
"np_var = np_bootstrap_distribution_variances\n",
201-
"\n",
202-
"np_difference = effsize.weighted_delta(np_means, np_var)\n",
203-
"\n",
204-
"assert difference == pytest.approx(np_difference)\n",
205-
"weight = np.true_divide(1, np_var)\n",
206-
"np.sum(np_means*weight)/np.sum(weight)"
218+
"mini_meta_delta.permutations_weighted_delta"
207219
]
208220
},
209221
{
@@ -217,13 +229,13 @@
217229
{
218230
"cell_type": "code",
219231
"execution_count": null,
220-
"id": "45056c5f",
232+
"id": "d674181c-82c1-4116-804a-69e9def7d5c8",
221233
"metadata": {},
222234
"outputs": [
223235
{
224236
"data": {
225237
"text/plain": [
226-
"0.0112"
238+
"0.0094"
227239
]
228240
},
229241
"execution_count": null,
@@ -247,32 +259,54 @@
247259
"permutations_1_var = perm_test_1.permutations_var\n",
248260
"permutations_2_var = perm_test_2.permutations_var\n",
249261
"\n",
262+
"perm_test_1\n",
263+
"\n",
250264
"weight_1 = np.true_divide(1,permutations_1_var)\n",
251265
"weight_2 = np.true_divide(1,permutations_2_var)\n",
252266
"\n",
253267
"weighted_deltas = (weight_1*permutations_1 + weight_2*permutations_2)/(weight_1+weight_2)\n",
254268
"assert permutations_delta == pytest.approx(weighted_deltas)\n",
255269
"\n",
256270
"\n",
257-
"np_means = [np.mean(rep1_yes)-np.mean(rep1_no), \n",
258-
" np.mean(rep2_yes)-np.mean(rep2_no)]\n",
259-
"np_var = [np.var(rep1_yes, ddof=1)/N+np.var(rep1_no, ddof=1)/N,\n",
260-
" np.var(rep2_yes, ddof=1)/N+np.var(rep2_no, ddof=1)/N]\n",
261-
"np_weight= np.true_divide(1, np_var)\n",
271+
"# np_means = [np.mean(rep1_yes)-np.mean(rep1_no), \n",
272+
"# np.mean(rep2_yes)-np.mean(rep2_no)]\n",
273+
"# np_var = [np.var(rep1_yes, ddof=1)/(N-1)+np.var(rep1_no, ddof=1)/(N-1),\n",
274+
"# np.var(rep2_yes, ddof=1)/(N-1)+np.var(rep2_no, ddof=1)/(N-1)]\n",
262275
"\n",
263-
"np_difference = np.sum(np_means*np_weight)/np.sum(np_weight)\n",
276+
"# np_weight= np.true_divide(1, np_var)\n",
264277
"\n",
265-
"np_pvalues = len(list(filter(lambda x: np.abs(x)>np.abs(np_difference), \n",
266-
" weighted_deltas)))/len(weighted_deltas)\n",
278+
"# np_difference = np.sum(np_means*np_weight)/np.sum(np_weight)\n",
279+
"\n",
280+
"# np_pvalues = len(list(filter(lambda x: np.abs(x)>np.abs(np_difference), \n",
281+
"# weighted_deltas)))/len(weighted_deltas)\n",
267282
"\n",
268-
"pvalue\n",
269283
"# assert pvalue == pytest.approx(np_pvalues)"
270284
]
271285
},
272286
{
273287
"cell_type": "code",
274288
"execution_count": null,
275-
"id": "01aef910-d540-4be5-9cf3-814f9aa36cd7",
289+
"id": "db42467a-0e0c-463e-be4a-a0a31f22db60",
290+
"metadata": {},
291+
"outputs": [],
292+
"source": [
293+
"np.abs(np_difference)"
294+
]
295+
},
296+
{
297+
"cell_type": "code",
298+
"execution_count": null,
299+
"id": "8c20cc0f-5b4e-4d24-9617-c346a3b5daa3",
300+
"metadata": {},
301+
"outputs": [],
302+
"source": [
303+
"pvalue"
304+
]
305+
},
306+
{
307+
"cell_type": "code",
308+
"execution_count": null,
309+
"id": "6e3bb0bd-b49f-48b0-98a9-fef495cb27a7",
276310
"metadata": {},
277311
"outputs": [],
278312
"source": []

0 commit comments

Comments
 (0)