Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-215

Engle-Granger Residual

Problem

Compute the Engle-Granger cointegration residuals for a known cointegrating coefficient: residual[t] = y[t] - beta * x[t].

Return the residual list, which is later tested for stationarity.

Hint

A stationary residual supports a cointegrating relationship.

Test cases

case 1
in: [[1,2,3],[1,2,3],1]
expected: [0,0,0]
case 2
in: [[2,4,6],[1,2,3],2]
expected: [0,0,0]
case 3
in: [[1,2,3],[1,2,3],0.5]
expected: [0.5,1,1.5]
case 4
in: [[],[],1]
expected: []
Starter codePython
def engle_granger_residual(y, x, beta):
    # Your code here
    pass

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