judithabk6 / med_bench

BSD 3-Clause "New" or "Revised" License
8 stars 3 forks source link

Invalid sum effects for misspecified problems with continuous mediator #24

Closed sami6mz closed 1 year ago

sami6mz commented 1 year ago

Thanks to PR #23, I discovered that the "total = direct + indirect" equality is violated by the simulation function itself. It happens when the mediator is continuous and the problem is misspecified. The equality is always violated for effects[0] == effects[2] + effects[3] i.e. total = theta_0 + delta_1. This may be for theoretical reasons, but I'd rather report it.

Code : data = simulate_data(1000, default_rng(321), True, True, 1, 1, 123, "continuous", 0.5, 0.5, 0.5, 0.5) effects = np.array(data[4:9]) print(effects) effects[0] == pytest.approx(effects[1] + effects[4]) effects[0] == pytest.approx(effects[2] + effects[3])

Output : [1.62116435 1.47413792 1.21991494 0.44107929 0.14702643] True False