All problems
GARCH Multi-Step Variance Forecast
Problem
Forecast GARCH(1,1) conditional variances h steps ahead. Starting from sigma2, the first forecast is omega + alpha * e2 + beta * sigma2; each later forecast replaces the squared shock with its expectation, giving s_next = omega + (alpha + beta) * s.
Return the list of h forecasts, or an empty list when h is not positive.
Hint
Beyond the first step the shock has mean zero, so only persistence alpha + beta matters.
Test cases
case 1
in: [0.1,0.2,0.7,1,0.8,3]
expected: [0.86,0.8739999999999999,0.8865999999999998]
case 2
in: [0.05,0.1,0.8,0.5,0.3,2]
expected: [0.33999999999999997,0.356]
case 3
in: [0.1,0.3,0.6,2,1,1]
expected: [1.2999999999999998]
case 4
in: [0.1,0.2,0.7,1,0.8,0]
expected: []
Starter codePython
def garch_multistep_variance(omega, alpha, beta, e2, sigma2, h):
# Your code here
pass4 test cases · run your code against them in the editor