All problems
Mediation Direct Effect
Problem
Return the direct effect c - a*b, where a is the treatment-to-mediator path, b is the mediator-to-outcome path, and c is the total effect.
Hint
Strip the indirect path out of the total effect.
Test cases
case 1
in: [0.5,0.4,2]
expected: 1.8
case 2
in: [0,0.4,2]
expected: 2
case 3
in: [0.5,0,1]
expected: 1
case 4
in: [-0.3,0.5,1]
expected: 1.15
case 5
in: [1,1,1]
expected: 0
Starter codePython
def direct_effect(a, b, c):
# Your code here
pass5 test cases · run your code against them in the editor