All problems
AR(2) Forecast Error Variances to Horizon Two
Problem
Compute the forecast error variances for horizons zero, one, and two of a stationary AR(2) with innovation variance sigma2 and coefficients phi1 and phi2. The psi weights are 1, phi1, and phi1^2 + phi2, so the variances are sigma2 times 1, 1 + phi1^2, and 1 + phi1^2 + (phi1^2 + phi2)^2.
Return the three variances as a list in horizon order.
Hint
Each psi weight comes from the recursion psi[k] = phi1 * psi[k-1] + phi2 * psi[k-2] with psi[0] = 1.
Test cases
case 1
in: [1,0.5,0.2]
expected: [1,1.25,1.4525]
case 2
in: [2,0,0]
expected: [2,2,2]
case 3
in: [1,-0.5,0.25]
expected: [1,1.25,1.5]
case 4
in: [0,1,1]
expected: [0,0,0]
Starter codePython
def ar2_error_variances(sigma2, phi1, phi2):
# Your code here
pass4 test cases · run your code against them in the editor