All problems
Forecast Error Variance Share
Problem
Compute the share of forecast error variance at a horizon attributable to one variable, given its MA coefficient path own_psi and the coefficients of the other shocks other_psi: sum(own^2) / (sum(own^2) + sum(other^2)).
Return 0.0 when all coefficients are zero.
Hint
Squared MA coefficients measure each shock contribution to the forecast error.
Test cases
case 1
in: [[1,0.5],[0,0.5]]
expected: 0.8333333333333334
case 2
in: [[1],[1]]
expected: 0.5
case 3
in: [[],[]]
expected: 0
case 4
in: [[0.3,0.4],[0.5,0.12]]
expected: 0.48600311041990674
Starter codePython
def forecast_error_variance_share(own_psi, other_psi):
# Your code here
pass4 test cases · run your code against them in the editor