Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-311

Mediation Indirect Effect

Problem

Return the indirect (mediated) effect a*b, the product of the treatment-to-mediator and mediator-to-outcome path coefficients.

Hint

The indirect effect is the product of the two path coefficients.

Test cases

case 1
in: [0.5,0.4]
expected: 0.2
case 2
in: [0,0.4]
expected: 0
case 3
in: [-0.5,0.4]
expected: -0.2
case 4
in: [2,3]
expected: 6
Starter codePython
def indirect_effect(a, b):
    # Your code here
    pass

4 test cases · run your code against them in the editor