Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-288

VAR(2) Coefficient Apply

Problem

Apply a VAR(2) coefficient set to produce the next state vector: c + A1 * x_t + A2 * x_prev, where c is the intercept vector and A1, A2 are row-major coefficient matrices.

Return the resulting list of length len(c).

Hint

The VAR(2) forecast stacks both lags, each with its own coefficient matrix.

Test cases

case 1
in: [[1,0.5],[[0.5,0.1],[0.2,0.4]],[[0.1,0],[0,0.1]],[2,3],[1,1]]
expected: [2.4,2.2]
case 2
in: [[0,0],[[1,0],[0,1]],[[0,0],[0,0]],[4,5],[1,2]]
expected: [4,5]
case 3
in: [[1],[[0.5]],[[0.25]],[8],[4]]
expected: [6]
Starter codePython
def var2_apply(c, a1, a2, x_t, x_prev):
    # Your code here
    pass

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