All problems
Mediation Effect Product
Problem
Compute the indirect (mediation) effect as the product of the path coefficients a (treatment to mediator) and b (mediator to outcome).
Hint
The indirect effect flows from treatment through the mediator to the outcome.
Test cases
case 1
in: [0.5,0.8]
expected: 0.4
case 2
in: [2,-0.5]
expected: -1
case 3
in: [0,3]
expected: 0
case 4
in: [1.5,1.5]
expected: 2.25
Starter codePython
def mediation_effect(a, b):
# Your code here
pass4 test cases · run your code against them in the editor